diff --git a/lib/Drupal/config_translation/Tests/ConfigTranslationListUITest.php b/lib/Drupal/config_translation/Tests/ConfigTranslationListUITest.php index b0a67a2..b7ae442 100644 --- a/lib/Drupal/config_translation/Tests/ConfigTranslationListUITest.php +++ b/lib/Drupal/config_translation/Tests/ConfigTranslationListUITest.php @@ -19,13 +19,13 @@ class ConfigTranslationListUITest extends WebTestBase { * * @var array */ - public static $modules = array('block', 'contact', 'config_translation', 'menu', 'taxonomy', 'views', 'views_ui'); + public static $modules = array('block', 'contact', 'config_translation', 'menu', 'taxonomy'); public static function getInfo() { return array( - 'name' => 'Configuration translation lists', + 'name' => 'Configuration Translation lists', 'description' => 'Visit all lists.', - 'group' => 'Configuration translation lists', + 'group' => 'Configuration Translation', ); } @@ -42,7 +42,6 @@ class ConfigTranslationListUITest extends WebTestBase { 'administer menu', 'administer site configuration', 'administer taxonomy', - 'administer views', 'translate configuration', ); @@ -51,46 +50,30 @@ class ConfigTranslationListUITest extends WebTestBase { $this->drupalLogin($admin_user); } - /* - * Tests all lists of config to see if Translate link is added to operations. + /** + * Test the Block listing for the Translate Operation. + * + * There are no blocks placed in the testing profile. Add one, then check + * for Translate operation. */ - function testTranslateOperationInListUI() { - $translate_operation_title = 'Translate'; - - // All lists from config_translation_config_translation_group_info(). - - // Block 'admin/structure/block'. - // There are no blocks placed in the minimal profile. Add one, then check - // for Translate operation. - // Add a test block, any block will do. Take out the login block if can - // get a test block added so that the test here is independent of user - // login block. - // Set the machine name so later can know what the translate link is. + protected function doBlockListTest() { + // Add a test block, any block will do. + // Set the machine name so later the translate link can be build. $block_machine_name = drupal_strtolower($this->randomName(16)); - $this->drupalPlaceBlock('user_login_block', array('machine_name' => $block_machine_name)); + $this->drupalPlaceBlock('system_powered_by_block', array('machine_name' => $block_machine_name)); - $list_url = 'admin/structure/block'; - $this->drupalGet($list_url); - // Test if Translate appears anywhere on the page. - $this->assertText($translate_operation_title); + // Get the Block listing. + $this->drupalGet('admin/structure/block'); $translate_link = 'admin/structure/block/manage/stark.' . $block_machine_name . '/translate'; // Test if the link to translate the block is on the page. $this->assertLinkByHref($translate_link); + } - // Custom block 'admin/structure/custom-blocks'. - // @todo Create a test custom block. - - // Contact 'admin/structure/contact'. - // @todo Add tests for contact forms. - - // Filter 'admin/config/content/formats'. - // @todo Add test for formats. - - // Menu 'admin/structure/menu'. - $list_url = 'admin/structure/menu'; - $this->drupalGet($list_url); - + /** + * Test the Menu listing for the Translate Operation. + */ + protected function doMenuListTest() { // Create a test menu to decouple looking for Translate operations // link so this does not test more than necessary. $this->drupalGet('admin/structure/menu/add'); @@ -103,26 +86,23 @@ class ConfigTranslationListUITest extends WebTestBase { 'description' => '', 'label' => $label, ); + // Create the menu by posting the form. $this->drupalPost('admin/structure/menu/add', $edit, t('Save')); - $this->drupalGet($list_url); - // Simple test for 'Translate' anywhere on the menu list page. - $this->assertText($translate_operation_title); + // Get the Menu listing. + $this->drupalGet('admin/structure/menu'); + // Custom Menus are automatically prefixed by 'menu-'. + $menu_name = 'menu-' . $menu_name; $translate_link = 'admin/structure/menu/manage/' . $menu_name . '/translate'; // Test if the link to translate the menu is on the page. $this->assertLinkByHref($translate_link); + } - // Shortcut 'admin/config/user-interface/shortcut'. - // @todo Add test for shortcut list. - - // System 'admin/config/development/maintenance' and - // 'admin/config/system/site-information'. - // @todo Add test for system. - - // Taxonomy 'admin/structure/taxonomy'. - $list_url = 'admin/structure/taxonomy'; - + /** + * Tests the Vocabulary listing for the Translate Operation. + */ + protected function doVocabularyListTest() { // Create a test vocabulary to decouple looking for Translate operations // link so this does not test more than necessary. $vocabulary = entity_create('taxonomy_vocabulary', array( @@ -132,23 +112,43 @@ class ConfigTranslationListUITest extends WebTestBase { )); $vocabulary->save(); - // Simple test for 'Translate' anywhere on the taxonomy list page. - $this->drupalGet($list_url); - $this->assertText($translate_operation_title); + // Get the Taxonomy listing. + $this->drupalGet('admin/structure/taxonomy'); $translate_link = 'admin/structure/taxonomy/manage/' . $vocabulary->id() . '/translate'; // Test if the link to translate the vocabulary is on the page. $this->assertLinkByHref($translate_link); + } + + /* + * Tests all lists of config to see if Translate link is added to operations. + */ + function testTranslateOperationInListUI() { + + // All lists from config_translation_config_translation_group_info(). + + $this->doBlockListTest(); + $this->doMenuListTest(); + $this->doVocabularyListTest(); + + // Custom block 'admin/structure/custom-blocks'. + // @todo Create a test custom block. + + // Contact 'admin/structure/contact'. + // @todo Add tests for contact forms. + + // Filter 'admin/config/content/formats'. + // @todo Add test for formats. + + // Shortcut 'admin/config/user-interface/shortcut'. + // @todo Add test for shortcut list. + + // System 'admin/config/development/maintenance' and + // 'admin/config/system/site-information'. + // @todo Add test for system. // User 'admin/config/people/accounts' and 'admin/people/roles'. // @todo Add test for user. - - // Views 'admin/structure/views'. - // Frontpage view is enabled in test minimal profile, so do not need to add - // a test view. - $list_url = 'admin/structure/views'; - $this->drupalGet($list_url); - $this->assertText($translate_operation_title); } } diff --git a/lib/Drupal/config_translation/Tests/ConfigTranslationViewListUITest.php b/lib/Drupal/config_translation/Tests/ConfigTranslationViewListUITest.php new file mode 100644 index 0000000..c50fb36 --- /dev/null +++ b/lib/Drupal/config_translation/Tests/ConfigTranslationViewListUITest.php @@ -0,0 +1,50 @@ + 'Configuration Translation view list', + 'description' => 'Visit view list and test if translate is available.', + 'group' => 'Configuration Translation', + ); + } + + /* + * Tests views_ui list to see if Translate link is added to operations. + */ + function testTranslateOperationInViewListUI() { + // Views UI List 'admin/structure/views'. + $this->drupalGet('admin/structure/views'); + $translate_link = 'admin/structure/views/view/test_view/translate'; + // Test if the link to translate the test_view is on the page. + $this->assertLinkByHref($translate_link); + } + +}