Loading tests/src/Functional/TourUITest.php +31 −25 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ class TourUITest extends BrowserTestBase { * * @var array */ public static $modules = ['tour_ui', 'tour_test']; protected static $modules = ['tour_ui', 'tour_test']; /** Loading Loading @@ -62,11 +62,11 @@ class TourUITest extends BrowserTestBase { // jQuery('table > tbody > tr:first').hasClass('tour-test') // jQuery('table > tbody > tr.tip-edit > td:first').text() $elements = $this->xpath('//table/tbody/tr[contains(@class, :class)]/td[1]', [':class' => 'tour-test']); $this->assertIdentical($elements[0]->getText(), 'tour-test'); $this->assertSame($elements[0]->getText(), 'tour-test'); // The second column contains the title. $elements = $this->xpath('//table/tbody/tr[contains(@class, :class)]/td[2]', [':class' => 'tour-test']); $this->assertIdentical($elements[0]->getText(), t('Tour test english')->render()); $this->assertSame($elements[0]->getText(), t('Tour test english')->render()); // The third column contains the routes. // Running "jQuery('table > tbody > tr.tour-test > td:nth(2)').html()" Loading @@ -78,8 +78,8 @@ class TourUITest extends BrowserTestBase { // The fourth column contains the number of tips. $elements = $this->xpath('//table/tbody/tr[contains(@class, :class)]/td[4]', [':class' => 'tour-test']); $this->assertIdentical($elements[0]->getText(), '1', 'Core tour_test/config/tour-test-2 has 1 tip'); $this->assertIdentical($elements[1]->getText(), '3', 'Core tour_test/config/tour-test-1 has 3 tips'); $this->assertSame($elements[0]->getText(), '1', 'Core tour_test/config/tour-test-2 has 1 tip'); $this->assertSame($elements[1]->getText(), '3', 'Core tour_test/config/tour-test-1 has 3 tips'); } /** Loading @@ -92,15 +92,16 @@ class TourUITest extends BrowserTestBase { 'id' => strtolower($this->randomMachineName()), 'module' => strtolower($this->randomMachineName()), ]; $this->drupalPostForm('admin/config/user-interface/tour/add', $edit, t('Save')); $this->assertRaw(t('The %tour tour has been created.', ['%tour' => $edit['label']])); $this->drupalGet('admin/config/user-interface/tour/add'); $this->submitForm($edit, t('Save')); $this->assertSession()->responseContains(t('The %tour tour has been created.', ['%tour' => $edit['label']])); $elements = $this->xpath('//table/tbody/tr'); $this->assertEquals(1, count($elements)); // Edit and re-save an existing tour. $this->assertTitle(t('Edit tour | @site-name', ['@site-name' => \Drupal::config('system.site')->get('name')])); $this->drupalPostForm(NULL, [], t('Save')); $this->assertRaw(t('Updated the %tour tour', ['%tour' => $edit['label']])); $this->assertSession()->titleEquals(t('Edit tour | @site-name', ['@site-name' => \Drupal::config('system.site')->get('name')])); $this->submitForm([], t('Save')); $this->assertSession()->responseContains(t('Updated the %tour tour', ['%tour' => $edit['label']])); // Reorder the tour tips. $this->drupalGet('admin/config/user-interface/tour/manage/tour-test'); Loading @@ -108,7 +109,7 @@ class TourUITest extends BrowserTestBase { 'tips[tour-test-1][weight]' => '2', 'tips[tour-test-3][weight]' => '1', ]; $this->drupalPostForm(NULL, $weights, t('Save')); $this->submitForm($weights, t('Save')); $this->drupalGet('admin/config/user-interface/tour/manage/tour-test'); $elements = $this->xpath('//tr[@class=:class and ./td[contains(., :text)]]', [ ':class' => 'draggable odd', Loading @@ -124,7 +125,7 @@ class TourUITest extends BrowserTestBase { 'tips[tour-test-1][weight]' => '1', 'tips[tour-test-3][weight]' => '2', ]; $this->drupalPostForm(NULL, $weights, t('Save')); $this->submitForm($weights, t('Save')); $this->drupalGet('admin/config/user-interface/tour/manage/tour-test'); $elements = $this->xpath('//tr[@class=:class and ./td[contains(., :text)]]', [ ':class' => 'draggable odd', Loading @@ -136,21 +137,22 @@ class TourUITest extends BrowserTestBase { ':text' => 'The awesome image', ]); $this->assertEquals(1, count($elements), 'Found even tip "The awesome image".'); $this->drupalGet('admin/config/user-interface/tour/add'); // Attempt to create a duplicate tour. $this->drupalPostForm('admin/config/user-interface/tour/add', $edit, t('Save')); $this->assertRaw(t('The machine-readable name is already in use. It must be unique.')); $this->submitForm($edit, t('Save')); $this->assertSession()->responseContains(t('The machine-readable name is already in use. It must be unique.')); // Delete a tour. $this->drupalGet('admin/config/user-interface/tour/manage/' . $edit['id']); $this->drupalPostForm(NULL, NULL, t('Delete')); $this->assertRaw(t('Are you sure you want to delete the %tour tour?', ['%tour' => $edit['label']])); $this->submitForm(NULL, t('Delete')); $this->assertSession()->responseContains(t('Are you sure you want to delete the %tour tour?', ['%tour' => $edit['label']])); $this->clickLink(t('Cancel')); $this->clickLink(t('Delete')); $this->drupalPostForm(NULL, NULL, t('Delete')); $this->submitForm(NULL, t('Delete')); $elements = $this->xpath('//table/tbody/tr'); $this->assertEquals(2, count($elements)); $this->assertRaw(t('Deleted the %tour tour.', ['%tour' => $edit['label']])); $this->assertSession()->responseContains(t('Deleted the %tour tour.', ['%tour' => $edit['label']])); } /** Loading @@ -164,21 +166,23 @@ class TourUITest extends BrowserTestBase { 'module' => $this->randomString(), 'paths' => '', ]; $this->drupalPostForm('admin/config/user-interface/tour/add', $edit, t('Save')); $this->assertRaw(t('The %tour tour has been created.', ['%tour' => $edit['label']])); $this->drupalGet('admin/config/user-interface/tour/add'); $this->submitForm($edit, t('Save')); $this->assertSession()->responseContains(t('The %tour tour has been created.', ['%tour' => $edit['label']])); // Add a new tip. $tip = [ 'new' => 'image', ]; $this->drupalPostForm('admin/config/user-interface/tour/manage/' . $edit['id'], $tip, t('Add')); $this->drupalGet('admin/config/user-interface/tour/manage/' . $edit['id']); $this->submitForm($tip, t('Add')); $tip = [ 'label' => 'a' . $this->randomString(), 'id' => 'tour-ui-test-image-tip', 'url' => 'http://testimage.png', 'alt' => 'Testing a new image tip through Tour UI.', ]; $this->drupalPostForm(NULL, $tip, t('Save')); $this->submitForm($tip, t('Save')); $elements = $this->xpath('//tr[@class=:class and ./td[contains(., :text)]]', [ ':class' => 'draggable odd', ':text' => $tip['label'], Loading @@ -189,20 +193,22 @@ class TourUITest extends BrowserTestBase { $tip_id = $tip['id']; unset($tip['id']); $tip['label'] = 'a' . $this->randomString(); $this->drupalPostForm('admin/config/user-interface/tour/manage/' . $edit['id'] . '/tip/edit/' . $tip_id, $tip, t('Save')); $this->drupalGet('admin/config/user-interface/tour/manage/' . $edit['id'] . '/tip/edit/' . $tip_id); $this->submitForm($tip, t('Save')); $elements = $this->xpath('//tr[@class=:class and ./td[contains(., :text)]]', [ ':class' => 'draggable odd', ':text' => $tip['label'], ]); $this->assertEquals(1, count($elements), 'Found tip "' . $tip['label'] . '".'); $this->drupalGet('admin/config/user-interface/tour/manage/' . $edit['id'] . '/tip/delete/' . $tip_id); // Delete the tip. $this->drupalPostForm('admin/config/user-interface/tour/manage/' . $edit['id'] . '/tip/delete/' . $tip_id, [], t('Delete')); $this->submitForm([], t('Delete')); $elements = $this->xpath('//tr[@class=:class and ./td[contains(., :text)]]', [ ':class' => 'draggable odd', ':text' => $tip['label'], ]); $this->assertNotEqual(count($elements), 1, 'Did not find tip "' . $tip['label'] . '".'); $this->assertNotEquals(count($elements), 1, 'Did not find tip "' . $tip['label'] . '".'); } } tour_ui.info.yml +1 −2 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ type: module description : 'Provides a UI to manage guided tours.' package: Development configure: entity.tour.collection core: 8.x core_version_requirement: ^8 || ^9 core_version_requirement: ^9.1 || ^10 dependencies: - drupal:tour Loading
tests/src/Functional/TourUITest.php +31 −25 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ class TourUITest extends BrowserTestBase { * * @var array */ public static $modules = ['tour_ui', 'tour_test']; protected static $modules = ['tour_ui', 'tour_test']; /** Loading Loading @@ -62,11 +62,11 @@ class TourUITest extends BrowserTestBase { // jQuery('table > tbody > tr:first').hasClass('tour-test') // jQuery('table > tbody > tr.tip-edit > td:first').text() $elements = $this->xpath('//table/tbody/tr[contains(@class, :class)]/td[1]', [':class' => 'tour-test']); $this->assertIdentical($elements[0]->getText(), 'tour-test'); $this->assertSame($elements[0]->getText(), 'tour-test'); // The second column contains the title. $elements = $this->xpath('//table/tbody/tr[contains(@class, :class)]/td[2]', [':class' => 'tour-test']); $this->assertIdentical($elements[0]->getText(), t('Tour test english')->render()); $this->assertSame($elements[0]->getText(), t('Tour test english')->render()); // The third column contains the routes. // Running "jQuery('table > tbody > tr.tour-test > td:nth(2)').html()" Loading @@ -78,8 +78,8 @@ class TourUITest extends BrowserTestBase { // The fourth column contains the number of tips. $elements = $this->xpath('//table/tbody/tr[contains(@class, :class)]/td[4]', [':class' => 'tour-test']); $this->assertIdentical($elements[0]->getText(), '1', 'Core tour_test/config/tour-test-2 has 1 tip'); $this->assertIdentical($elements[1]->getText(), '3', 'Core tour_test/config/tour-test-1 has 3 tips'); $this->assertSame($elements[0]->getText(), '1', 'Core tour_test/config/tour-test-2 has 1 tip'); $this->assertSame($elements[1]->getText(), '3', 'Core tour_test/config/tour-test-1 has 3 tips'); } /** Loading @@ -92,15 +92,16 @@ class TourUITest extends BrowserTestBase { 'id' => strtolower($this->randomMachineName()), 'module' => strtolower($this->randomMachineName()), ]; $this->drupalPostForm('admin/config/user-interface/tour/add', $edit, t('Save')); $this->assertRaw(t('The %tour tour has been created.', ['%tour' => $edit['label']])); $this->drupalGet('admin/config/user-interface/tour/add'); $this->submitForm($edit, t('Save')); $this->assertSession()->responseContains(t('The %tour tour has been created.', ['%tour' => $edit['label']])); $elements = $this->xpath('//table/tbody/tr'); $this->assertEquals(1, count($elements)); // Edit and re-save an existing tour. $this->assertTitle(t('Edit tour | @site-name', ['@site-name' => \Drupal::config('system.site')->get('name')])); $this->drupalPostForm(NULL, [], t('Save')); $this->assertRaw(t('Updated the %tour tour', ['%tour' => $edit['label']])); $this->assertSession()->titleEquals(t('Edit tour | @site-name', ['@site-name' => \Drupal::config('system.site')->get('name')])); $this->submitForm([], t('Save')); $this->assertSession()->responseContains(t('Updated the %tour tour', ['%tour' => $edit['label']])); // Reorder the tour tips. $this->drupalGet('admin/config/user-interface/tour/manage/tour-test'); Loading @@ -108,7 +109,7 @@ class TourUITest extends BrowserTestBase { 'tips[tour-test-1][weight]' => '2', 'tips[tour-test-3][weight]' => '1', ]; $this->drupalPostForm(NULL, $weights, t('Save')); $this->submitForm($weights, t('Save')); $this->drupalGet('admin/config/user-interface/tour/manage/tour-test'); $elements = $this->xpath('//tr[@class=:class and ./td[contains(., :text)]]', [ ':class' => 'draggable odd', Loading @@ -124,7 +125,7 @@ class TourUITest extends BrowserTestBase { 'tips[tour-test-1][weight]' => '1', 'tips[tour-test-3][weight]' => '2', ]; $this->drupalPostForm(NULL, $weights, t('Save')); $this->submitForm($weights, t('Save')); $this->drupalGet('admin/config/user-interface/tour/manage/tour-test'); $elements = $this->xpath('//tr[@class=:class and ./td[contains(., :text)]]', [ ':class' => 'draggable odd', Loading @@ -136,21 +137,22 @@ class TourUITest extends BrowserTestBase { ':text' => 'The awesome image', ]); $this->assertEquals(1, count($elements), 'Found even tip "The awesome image".'); $this->drupalGet('admin/config/user-interface/tour/add'); // Attempt to create a duplicate tour. $this->drupalPostForm('admin/config/user-interface/tour/add', $edit, t('Save')); $this->assertRaw(t('The machine-readable name is already in use. It must be unique.')); $this->submitForm($edit, t('Save')); $this->assertSession()->responseContains(t('The machine-readable name is already in use. It must be unique.')); // Delete a tour. $this->drupalGet('admin/config/user-interface/tour/manage/' . $edit['id']); $this->drupalPostForm(NULL, NULL, t('Delete')); $this->assertRaw(t('Are you sure you want to delete the %tour tour?', ['%tour' => $edit['label']])); $this->submitForm(NULL, t('Delete')); $this->assertSession()->responseContains(t('Are you sure you want to delete the %tour tour?', ['%tour' => $edit['label']])); $this->clickLink(t('Cancel')); $this->clickLink(t('Delete')); $this->drupalPostForm(NULL, NULL, t('Delete')); $this->submitForm(NULL, t('Delete')); $elements = $this->xpath('//table/tbody/tr'); $this->assertEquals(2, count($elements)); $this->assertRaw(t('Deleted the %tour tour.', ['%tour' => $edit['label']])); $this->assertSession()->responseContains(t('Deleted the %tour tour.', ['%tour' => $edit['label']])); } /** Loading @@ -164,21 +166,23 @@ class TourUITest extends BrowserTestBase { 'module' => $this->randomString(), 'paths' => '', ]; $this->drupalPostForm('admin/config/user-interface/tour/add', $edit, t('Save')); $this->assertRaw(t('The %tour tour has been created.', ['%tour' => $edit['label']])); $this->drupalGet('admin/config/user-interface/tour/add'); $this->submitForm($edit, t('Save')); $this->assertSession()->responseContains(t('The %tour tour has been created.', ['%tour' => $edit['label']])); // Add a new tip. $tip = [ 'new' => 'image', ]; $this->drupalPostForm('admin/config/user-interface/tour/manage/' . $edit['id'], $tip, t('Add')); $this->drupalGet('admin/config/user-interface/tour/manage/' . $edit['id']); $this->submitForm($tip, t('Add')); $tip = [ 'label' => 'a' . $this->randomString(), 'id' => 'tour-ui-test-image-tip', 'url' => 'http://testimage.png', 'alt' => 'Testing a new image tip through Tour UI.', ]; $this->drupalPostForm(NULL, $tip, t('Save')); $this->submitForm($tip, t('Save')); $elements = $this->xpath('//tr[@class=:class and ./td[contains(., :text)]]', [ ':class' => 'draggable odd', ':text' => $tip['label'], Loading @@ -189,20 +193,22 @@ class TourUITest extends BrowserTestBase { $tip_id = $tip['id']; unset($tip['id']); $tip['label'] = 'a' . $this->randomString(); $this->drupalPostForm('admin/config/user-interface/tour/manage/' . $edit['id'] . '/tip/edit/' . $tip_id, $tip, t('Save')); $this->drupalGet('admin/config/user-interface/tour/manage/' . $edit['id'] . '/tip/edit/' . $tip_id); $this->submitForm($tip, t('Save')); $elements = $this->xpath('//tr[@class=:class and ./td[contains(., :text)]]', [ ':class' => 'draggable odd', ':text' => $tip['label'], ]); $this->assertEquals(1, count($elements), 'Found tip "' . $tip['label'] . '".'); $this->drupalGet('admin/config/user-interface/tour/manage/' . $edit['id'] . '/tip/delete/' . $tip_id); // Delete the tip. $this->drupalPostForm('admin/config/user-interface/tour/manage/' . $edit['id'] . '/tip/delete/' . $tip_id, [], t('Delete')); $this->submitForm([], t('Delete')); $elements = $this->xpath('//tr[@class=:class and ./td[contains(., :text)]]', [ ':class' => 'draggable odd', ':text' => $tip['label'], ]); $this->assertNotEqual(count($elements), 1, 'Did not find tip "' . $tip['label'] . '".'); $this->assertNotEquals(count($elements), 1, 'Did not find tip "' . $tip['label'] . '".'); } }
tour_ui.info.yml +1 −2 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ type: module description : 'Provides a UI to manage guided tours.' package: Development configure: entity.tour.collection core: 8.x core_version_requirement: ^8 || ^9 core_version_requirement: ^9.1 || ^10 dependencies: - drupal:tour