diff --git a/lib/Drupal/config_translation/Tests/ConfigTranslationListUITest.php b/lib/Drupal/config_translation/Tests/ConfigTranslationListUITest.php new file mode 100644 index 0000000..c039bd9 --- /dev/null +++ b/lib/Drupal/config_translation/Tests/ConfigTranslationListUITest.php @@ -0,0 +1,143 @@ + 'Configuration Translation lists', + 'description' => 'Visit all lists.', + 'group' => 'Configuration Translation', + ); + } + + function setUp() { + parent::setUp(); + + // If using standard profile doesn't help, try user 1, see node access patch + // for example, older one. + + $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); + } + + protected function doBlockListTest() { + // 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. + $block_machine_name = drupal_strtolower($this->randomName(16)); + $this->drupalPlaceBlock('user_login_block', array('machine_name' => $block_machine_name)); + + $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); + } + + 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. Find the issue that is supposed to be making + // randomMachineName(). + $menu_name = drupal_strtolower($this->randomName(16)); + $label = $this->randomName(16); + $edit = array( + 'id' => $menu_name, + 'description' => '', + 'label' => $label, + ); + $this->drupalPost('admin/structure/menu/add', $edit, t('Save')); + // Menu 'admin/structure/menu' + $this->drupalGet('admin/structure/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); + } + + 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(); + + // Simple test for 'Translate' anywhere on the taxonomy list page. + $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..d600336 --- /dev/null +++ b/lib/Drupal/config_translation/Tests/ConfigTranslationViewListUITest.php @@ -0,0 +1,36 @@ + 'Configuration Translation view list', + 'description' => 'Visit view list and test if translate is available.', + 'group' => 'Configuration Translation', + ); + } + + /* + * Tests all lists of config to see if Translate link is added to operations. + */ + function testTranslateOperationInViewListUI() { + // Views 'admin/structure/views'. + $this->drupalGet('admin/structure/views'); + $translate_link = 'admin/structure/views/view/views_test_data/translate'; + // Test if the link to translate the vocabulary is on the page. + $this->assertLinkByHref($translate_link); + } + +}