You are here

public function MetatagCoreWithI18nConfigTest::testI18nDeleteEntityBundle in Metatag 7

Confirm that translations will be deleted when entity bundles are deleted.

File

tests/MetatagCoreWithI18nConfigTest.test, line 215
Tests for Metatag's i18n integration for the configurations.

Class

MetatagCoreWithI18nConfigTest
Tests for Metatag's i18n integration for the configurations.

Code

public function testI18nDeleteEntityBundle() {

  // Plan out the different translation string tests.
  $string_en = 'Hey, an article!';
  $string_fr = 'Alors! Un article!';
  $config_name = 'metatag_config:node:article:title';

  // Create a config for the 'article' content type's meta tags.
  $content_type = 'article';
  $content_type_label = t('Article');
  $instance = 'node:article';
  $instance_label = t('Node: Article');
  $config = new StdClass();
  $config->instance = $instance;
  $config->api_version = 1;
  $config->disabled = FALSE;
  $config->export_module = 'metatag';
  $config->config = array();

  // Set something specific as the page title.
  $config->config['title']['value'] = $string_en;
  metatag_config_save($config);

  // Confirm the string is present now.
  $this
    ->searchTranslationPage($string_en, $config_name);

  // Load the 'delete' page.
  $this
    ->drupalGet('admin/structure/types/manage/' . $content_type);
  $this
    ->assertResponse(200);

  // Confirm this is the correct page.
  $this
    ->assertFieldByName('op', t('Delete content type'));

  // Submit the form.
  $this
    ->drupalPost(NULL, array(), t('Delete content type'));
  $this
    ->assertResponse(200);

  // Confirm this is the correct page.
  $this
    ->assertText(t('Are you sure you want to delete the content type @label?', array(
    '@label' => $content_type_label,
  )));
  $this
    ->assertText(t('This action cannot be undone.'));
  $this
    ->assertFieldByName('op');
  $this
    ->assertFieldByName('op', t('Delete'));

  // Submit the form.
  $this
    ->drupalPost(NULL, array(), t('Delete'));
  $this
    ->assertResponse(200);
  $this
    ->assertText(t('The content type @label has been deleted.', array(
    '@label' => $content_type_label,
  )));

  // Confirm the config was deleted.
  $config = metatag_config_load($instance);
  $this
    ->assertEqual($config, array());

  // Confirm the string has been removed.
  $this
    ->searchTranslationPage($string_en, $config_name, FALSE);
}