diff --git a/lib/Drupal/config_translation/Tests/ConfigTranslationListUITest.php b/lib/Drupal/config_translation/Tests/ConfigTranslationListUITest.php new file mode 100644 index 0000000..b205876 --- /dev/null +++ b/lib/Drupal/config_translation/Tests/ConfigTranslationListUITest.php @@ -0,0 +1,152 @@ + 'Configuration Translation lists', + 'description' => 'Visit all lists.', + 'group' => 'Configuration Translation', + ); + } + + function setUp() { + parent::setUp(); + + $permissions = array( + 'access site-wide contact form', + 'administer blocks', + 'administer contact forms', + 'administer menu', + 'administer site configuration', + 'administer taxonomy', + 'translate configuration', + ); + + // Create and log in user. + $admin_user = $this->drupalCreateUser($permissions); + $this->drupalLogin($admin_user); + } + + /** + * Tests the block listing for the translate operation. + * + * There are no blocks placed in the testing profile. Add one, then check + * for Translate operation. + */ + 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('system_powered_by_block', array('machine_name' => $block_machine_name)); + + // 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); + } + + /** + * Tests 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'); + // Lowercase the machine name. + $menu_name = drupal_strtolower($this->randomName(16)); + $label = $this->randomName(16); + $edit = array( + 'id' => $menu_name, + 'description' => '', + 'label' => $label, + ); + // Create the menu by posting the form. + $this->drupalPost('admin/structure/menu/add', $edit, t('Save')); + + // 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); + } + + /** + * 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( + 'name' => $this->randomName(), + 'description' => $this->randomName(), + 'vid' => drupal_strtolower($this->randomName()), + )); + $vocabulary->save(); + + // 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. + } + +} diff --git a/lib/Drupal/config_translation/Tests/ConfigTranslationViewListUITest.php b/lib/Drupal/config_translation/Tests/ConfigTranslationViewListUITest.php new file mode 100644 index 0000000..0895188 --- /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); + } + +}