diff --git a/lib/Drupal/config_translation/Tests/ConfigTranslationListUITest.php b/lib/Drupal/config_translation/Tests/ConfigTranslationListUITest.php new file mode 100644 index 0000000..b0a67a2 --- /dev/null +++ b/lib/Drupal/config_translation/Tests/ConfigTranslationListUITest.php @@ -0,0 +1,154 @@ + 'Configuration translation lists', + 'description' => 'Visit all lists.', + 'group' => 'Configuration translation lists', + ); + } + + 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', + 'administer views', + 'translate configuration', + ); + + // Create and log in user. + $admin_user = $this->drupalCreateUser($permissions); + $this->drupalLogin($admin_user); + } + + /* + * Tests all lists of config to see if Translate link is added to operations. + */ + 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. + $block_machine_name = drupal_strtolower($this->randomName(16)); + $this->drupalPlaceBlock('user_login_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); + + $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); + + // 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')); + $this->drupalGet($list_url); + + // Simple test for 'Translate' anywhere on the menu list page. + $this->assertText($translate_operation_title); + + $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'; + + // 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($list_url); + $this->assertText($translate_operation_title); + + $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); + + // 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); + } + +}