Tests the visibility settings for the blocks based on language.
public function testLanguageBlockVisibility() {
// Check if the visibility setting is available.
$default_theme = config('system.theme')
->get('default');
$this
->drupalGet('admin/structure/block/add/system_powered_by_block' . '/' . $default_theme);
$this
->assertField('visibility[language][langcodes][en]', 'Language visibility field is visible.');
// Enable a standard block and set the visibility setting for one language.
$edit = array(
'visibility[language][langcodes][en]' => TRUE,
'machine_name' => strtolower($this
->randomName(8)),
'region' => 'sidebar_first',
);
$this
->drupalPost('admin/structure/block/add/system_powered_by_block' . '/' . $default_theme, $edit, t('Save block'));
// Change the default language.
$edit = array(
'site_default_language' => 'fr',
);
$this
->drupalpost('admin/config/regional/settings', $edit, t('Save configuration'));
// Reset the static cache of the language list.
drupal_static_reset('language_list');
// Check that a page has a block.
$this
->drupalget('', array(
'language' => language_load('en'),
));
$this
->assertText('Powered by Drupal', 'The body of the custom block appears on the page.');
// Check that a page doesn't has a block for the current language anymore.
$this
->drupalGet('', array(
'language' => language_load('fr'),
));
$this
->assertNoText('Powered by Drupal', 'The body of the custom block does not appear on the page.');
}