diff --git a/core/modules/language/src/Tests/LanguageTourTest.php b/core/modules/language/src/Tests/LanguageTourTest.php index 7778367..06e449f 100644 --- a/core/modules/language/src/Tests/LanguageTourTest.php +++ b/core/modules/language/src/Tests/LanguageTourTest.php @@ -2,7 +2,7 @@ namespace Drupal\language\Tests; -use Drupal\tour\Tests\TourTestBase; +use Drupal\Tests\tour\Functional\TourTestBase; /** * Tests tour functionality. diff --git a/core/modules/locale/src/Tests/LocaleTranslateStringTourTest.php b/core/modules/locale/src/Tests/LocaleTranslateStringTourTest.php index 5c642f2..1c16ca4 100644 --- a/core/modules/locale/src/Tests/LocaleTranslateStringTourTest.php +++ b/core/modules/locale/src/Tests/LocaleTranslateStringTourTest.php @@ -2,7 +2,7 @@ namespace Drupal\locale\Tests; -use Drupal\tour\Tests\TourTestBase; +use Drupal\Tests\tour\Functional\TourTestBase; /** * Tests the Translate Interface tour. diff --git a/core/modules/tour/tests/src/Functional/TourCacheTagsTest.php b/core/modules/tour/tests/src/Functional/TourCacheTagsTest.php index c7048fb..087cf6f 100644 --- a/core/modules/tour/tests/src/Functional/TourCacheTagsTest.php +++ b/core/modules/tour/tests/src/Functional/TourCacheTagsTest.php @@ -3,7 +3,7 @@ namespace Drupal\Tests\tour\Functional; use Drupal\Core\Url; -use Drupal\system\Tests\Cache\PageCacheTagsTestBase; +use Drupal\Tests\system\Functional\Cache\PageCacheTagsTestBase; use Drupal\tour\Entity\Tour; use Drupal\user\Entity\Role; use Drupal\user\RoleInterface; diff --git a/core/modules/tour/src/Tests/TourHelpPageTest.php b/core/modules/tour/tests/src/Functional/TourHelpPageTest.php similarity index 90% rename from core/modules/tour/src/Tests/TourHelpPageTest.php rename to core/modules/tour/tests/src/Functional/TourHelpPageTest.php index 8a41eb9..78b35d0 100644 --- a/core/modules/tour/src/Tests/TourHelpPageTest.php +++ b/core/modules/tour/tests/src/Functional/TourHelpPageTest.php @@ -1,15 +1,15 @@ assertText('Tours guide you through workflows'); } else { - $this->assertNoText('Tours guide you through workflows'); + $this->assertSession()->pageTextNotContains('Tours guide you through workflows'); } $titles = $this->getTourList(); @@ -87,7 +87,7 @@ protected function verifyHelp($tours_ok = TRUE) { $this->assertLink($title); } else { - $this->assertNoLink($title); + $this->assertSession()->linkNotExists($title); // Just test the first item in the list of links that should not // be there, because the second matches the name of a module that is // in the Module overviews section, so the link will be there and @@ -101,10 +101,10 @@ protected function verifyHelp($tours_ok = TRUE) { foreach ($titles[1] as $title) { if ($tours_ok) { $this->assertText($title); - $this->assertNoLink($title); + $this->assertSession()->linkNotExists($title); } else { - $this->assertNoText($title); + $this->assertSession()->pageTextNotContains($title); // Just test the first item in the list of text that should not // be there, because the second matches part of the name of a module // that is in the Module overviews section, so the text will be there @@ -135,7 +135,7 @@ protected function getModuleList() { * not 'translate interface'. */ protected function getTourList() { - return [['Adding languages', 'Language'], ['Editing languages', 'Translation']]; + return [['Adding languages', 'Language'], ['Editing languages']]; } } diff --git a/core/modules/tour/src/Tests/TourTest.php b/core/modules/tour/tests/src/Functional/TourTest.php similarity index 76% rename from core/modules/tour/src/Tests/TourTest.php rename to core/modules/tour/tests/src/Functional/TourTest.php index 78304c6..933055b 100644 --- a/core/modules/tour/src/Tests/TourTest.php +++ b/core/modules/tour/tests/src/Functional/TourTest.php @@ -1,7 +1,8 @@ assertTourTips($tips); $this->assertTourTips(); - $elements = $this->xpath('//li[@data-id=:data_id and @class=:classes and ./p//a[@href=:href and contains(., :text)]]', array( + $elements = $this->xpath('//li[@data-id=:data_id and @class=:classes and ./p//a[@href=:href and contains(., :text)]]', [ ':classes' => 'tip-module-tour-test tip-type-text tip-tour-test-1', ':data_id' => 'tour-test-1', - ':href' => \Drupal::url('', [], ['absolute' => TRUE]), + ':href' => Url::fromRoute('', array(), array('absolute' => TRUE))->toString(), ':text' => 'Drupal', - )); - $this->assertEqual(count($elements), 1, 'Found Token replacement.'); + ]); + $this->assertEquals(count($elements), 1, 'Found Token replacement.'); $elements = $this->cssSelect("li[data-id=tour-test-1] h2:contains('The first tip')"); - $this->assertEqual(count($elements), 1, 'Found English variant of tip 1.'); + $this->assertEquals(count($elements), 1, 'Found English variant of tip 1.'); $elements = $this->cssSelect("li[data-id=tour-test-2] h2:contains('The quick brown fox')"); - $this->assertNotEqual(count($elements), 1, 'Did not find English variant of tip 2.'); + $this->assertNotEquals(count($elements), 1, 'Did not find English variant of tip 2.'); $elements = $this->cssSelect("li[data-id=tour-test-1] h2:contains('La pioggia cade in spagna')"); - $this->assertNotEqual(count($elements), 1, 'Did not find Italian variant of tip 1.'); + $this->assertNotEquals(count($elements), 1, 'Did not find Italian variant of tip 1.'); // Ensure that plugins work. $elements = $this->xpath('//img[@src="http://local/image.png"]'); - $this->assertEqual(count($elements), 1, 'Image plugin tip found.'); + $this->assertEquals(count($elements), 1, 'Image plugin tip found.'); // Navigate to tour-test-2/subpath and verify the tour_test_2 tip is found. $this->drupalGet('tour-test-2/subpath'); $elements = $this->cssSelect("li[data-id=tour-test-2] h2:contains('The quick brown fox')"); - $this->assertEqual(count($elements), 1, 'Found English variant of tip 2.'); + $this->assertEquals(count($elements), 1, 'Found English variant of tip 2.'); $elements = $this->cssSelect("li[data-id=tour-test-1] h2:contains('The first tip')"); - $this->assertNotEqual(count($elements), 1, 'Did not find English variant of tip 1.'); + $this->assertNotEquals(count($elements), 1, 'Did not find English variant of tip 1.'); // Enable Italian language and navigate to it/tour-test1 and verify italian // version of tip is found. @@ -98,10 +99,10 @@ public function testTourFunctionality() { $this->drupalGet('it/tour-test-1'); $elements = $this->cssSelect("li[data-id=tour-test-1] h2:contains('La pioggia cade in spagna')"); - $this->assertEqual(count($elements), 1, 'Found Italian variant of tip 1.'); + $this->assertEquals(count($elements), 1, 'Found Italian variant of tip 1.'); $elements = $this->cssSelect("li[data-id=tour-test-2] h2:contains('The quick brown fox')"); - $this->assertNotEqual(count($elements), 1, 'Did not find English variant of tip 1.'); + $this->assertNotEquals(count($elements), 1, 'Did not find English variant of tip 1.'); // Programmatically create a tour for use through the remainder of the test. $tour = Tour::create(array( @@ -140,26 +141,26 @@ public function testTourFunctionality() { // Ensure that a tour entity has the expected dependencies based on plugin // providers and the module named in the configuration entity. $dependencies = $tour->calculateDependencies()->getDependencies(); - $this->assertEqual($dependencies['module'], array('system', 'tour_test')); + $this->assertEquals($dependencies['module'], array('system', 'tour_test')); $this->drupalGet('tour-test-1'); // Load it back from the database and verify storage worked. $entity_save_tip = Tour::load('tour-entity-create-test-en'); // Verify that hook_ENTITY_TYPE_load() integration worked. - $this->assertEqual($entity_save_tip->loaded, 'Load hooks work'); + $this->assertEquals($entity_save_tip->loaded, 'Load hooks work'); // Verify that hook_ENTITY_TYPE_presave() integration worked. - $this->assertEqual($entity_save_tip->label(), 'Tour test english alter'); + $this->assertEquals($entity_save_tip->label(), 'Tour test english alter'); // Navigate to tour-test-1 and verify the new tip is found. $this->drupalGet('tour-test-1'); $elements = $this->cssSelect("li[data-id=tour-code-test-1] h2:contains('The rain in spain')"); - $this->assertEqual(count($elements), 1, 'Found the required tip markup for tip 4'); + $this->assertEquals(count($elements), 1, 'Found the required tip markup for tip 4'); // Verify that the weight sorting works by ensuring the lower weight item // (tip 4) has the 'End tour' button. $elements = $this->cssSelect("li[data-id=tour-code-test-1][data-text='End tour']"); - $this->assertEqual(count($elements), 1, 'Found code tip was weighted last and had "End tour".'); + $this->assertEquals(count($elements), 1, 'Found code tip was weighted last and had "End tour".'); // Test hook_tour_alter(). $this->assertText('Altered by hook_tour_tips_alter'); @@ -167,22 +168,22 @@ public function testTourFunctionality() { // Navigate to tour-test-3 and verify the tour_test_1 tip is found with // appropriate classes. $this->drupalGet('tour-test-3/foo'); - $elements = $this->xpath('//li[@data-id=:data_id and @class=:classes and ./h2[contains(., :text)]]', array( + $elements = $this->xpath('//li[@data-id=:data_id and @class=:classes and ./h2[contains(., :text)]]', [ ':classes' => 'tip-module-tour-test tip-type-text tip-tour-test-1', ':data_id' => 'tour-test-1', ':text' => 'The first tip', - )); - $this->assertEqual(count($elements), 1, 'Found English variant of tip 1.'); + ]); + $this->assertEquals(count($elements), 1, 'Found English variant of tip 1.'); // Navigate to tour-test-3 and verify the tour_test_1 tip is not found with // appropriate classes. $this->drupalGet('tour-test-3/bar'); - $elements = $this->xpath('//li[@data-id=:data_id and @class=:classes and ./h2[contains(., :text)]]', array( + $elements = $this->xpath('//li[@data-id=:data_id and @class=:classes and ./h2[contains(., :text)]]', [ ':classes' => 'tip-module-tour-test tip-type-text tip-tour-test-1', ':data_id' => 'tour-test-1', ':text' => 'The first tip', - )); - $this->assertEqual(count($elements), 0, 'Did not find English variant of tip 1.'); + ]); + $this->assertEquals(count($elements), 0, 'Did not find English variant of tip 1.'); } } diff --git a/core/modules/tour/src/Tests/TourTestBase.php b/core/modules/tour/tests/src/Functional/TourTestBase.php similarity index 68% rename from core/modules/tour/src/Tests/TourTestBase.php rename to core/modules/tour/tests/src/Functional/TourTestBase.php index 8383c99..7011ae1 100644 --- a/core/modules/tour/src/Tests/TourTestBase.php +++ b/core/modules/tour/tests/src/Functional/TourTestBase.php @@ -1,17 +1,17 @@ elements inside
    . $rendered_tips = $this->xpath('//ol[@id = "tour"]//li[starts-with(@class, "tip")]'); foreach ($rendered_tips as $rendered_tip) { - $attributes = (array) $rendered_tip->attributes(); - $tips[] = $attributes['@attributes']; + $tips[] = [ + 'data-id' => $rendered_tip->getAttribute('data-id'), + 'data-class' => $rendered_tip->getAttribute('data-class'), + ]; } } @@ -48,14 +50,15 @@ public function assertTourTips($tips = array()) { // Check for corresponding page elements. $total = 0; $modals = 0; + $raw_content = $this->getSession()->getPage()->getContent(); foreach ($tips as $tip) { if (!empty($tip['data-id'])) { - $elements = \PHPUnit_Util_XML::cssSelect('#' . $tip['data-id'], TRUE, $this->content, TRUE); - $this->assertTrue(!empty($elements) && count($elements) === 1, format_string('Found corresponding page element for tour tip with id #%data-id', array('%data-id' => $tip['data-id']))); + $elements = \PHPUnit_Util_XML::cssSelect('#' . $tip['data-id'], TRUE, $raw_content, TRUE); + $this->assertCount(1, $elements); } elseif (!empty($tip['data-class'])) { - $elements = \PHPUnit_Util_XML::cssSelect('.' . $tip['data-class'], TRUE, $this->content, TRUE); - $this->assertFalse(empty($elements), format_string('Found corresponding page element for tour tip with class .%data-class', array('%data-class' => $tip['data-class']))); + $elements = \PHPUnit_Util_XML::cssSelect('.' . $tip['data-class'], TRUE, $raw_content, TRUE); + $this->assertNotEmpty($elements); } else { // It's a modal. diff --git a/core/modules/tour/src/Tests/TourTestBasic.php b/core/modules/tour/tests/src/Functional/TourTestBasic.php similarity index 97% rename from core/modules/tour/src/Tests/TourTestBasic.php rename to core/modules/tour/tests/src/Functional/TourTestBasic.php index e79eb2b..ec92987 100644 --- a/core/modules/tour/src/Tests/TourTestBasic.php +++ b/core/modules/tour/tests/src/Functional/TourTestBasic.php @@ -1,6 +1,6 @@ assertIdentical(count($this->pluginManager->getDefinitions()), 1, 'Only tour plugins for the enabled modules were returned.'); + $this->assertSame(count($this->pluginManager->getDefinitions()), 1, 'Only tour plugins for the enabled modules were returned.'); } } diff --git a/core/modules/views_ui/src/Tests/ViewsUITourTest.php b/core/modules/views_ui/src/Tests/ViewsUITourTest.php index ccc0f29..6655b87 100644 --- a/core/modules/views_ui/src/Tests/ViewsUITourTest.php +++ b/core/modules/views_ui/src/Tests/ViewsUITourTest.php @@ -2,8 +2,8 @@ namespace Drupal\views_ui\Tests; -use Drupal\tour\Tests\TourTestBase; use Drupal\language\Entity\ConfigurableLanguage; +use Drupal\Tests\tour\Functional\TourTestBase; /** * Tests the Views UI tour.