public function BlockLanguageTest::testLanguageBlockVisibilityLanguageDelete

Tests if the visibility settings are removed if the language is deleted.

File

drupal/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php, line 91
Definition of Drupal\block\Tests\BlockLanguageTest.

Class

BlockLanguageTest
Functional tests for the language list configuration forms.

Namespace

Drupal\block\Tests

Code

public function testLanguageBlockVisibilityLanguageDelete() {

  // Enable a standard block and set the visibility setting for one language.
  $edit = array(
    'visibility' => array(
      'language' => array(
        'language_type' => 'language_interface',
        'langcodes' => array(
          'fr' => 'fr',
        ),
      ),
    ),
    'machine_name' => 'language_block_test',
  );
  $block = $this
    ->drupalPlaceBlock('system_powered_by_block', $edit);

  // Check that we have the language in config after saving the setting.
  $visibility = $block
    ->get('visibility');
  $language = $visibility['language']['langcodes']['fr'];
  $this
    ->assertTrue('fr' === $language, 'Language is set in the block configuration.');

  // Delete the language.
  $this
    ->drupalPost('admin/config/regional/language/delete/fr', array(), t('Delete'));

  // Check that the language is no longer stored in the configuration after
  // it is deleted.
  $block = entity_load('block', $block
    ->id());
  $visibility = $block
    ->get('visibility');
  $this
    ->assertTrue(empty($visibility['language']['langcodes']['fr']), 'Language is no longer not set in the block configuration after deleting the block.');
}