diff --git a/core/modules/node/src/Tests/AssertButtonsTrait.php b/core/modules/node/src/Tests/AssertButtonsTrait.php index 58d484d9e4..97016dc2e4 100644 --- a/core/modules/node/src/Tests/AssertButtonsTrait.php +++ b/core/modules/node/src/Tests/AssertButtonsTrait.php @@ -2,8 +2,13 @@ namespace Drupal\node\Tests; +@trigger_error('\Drupal\Tests\node\Functional\AssertButtonsTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\node\Functional\AssertButtonsTrait', E_USER_DEPRECATED); + /** * Asserts that buttons are present on a page. + * + * @deprecated Scheduled for removal before Drupal 9.0.0. + * Use \Drupal\Tests\node\Functional\AssertButtonsTrait instead. */ trait AssertButtonsTrait { diff --git a/core/modules/node/src/Tests/Views/NodeTestBase.php b/core/modules/node/src/Tests/Views/NodeTestBase.php index 661ad91ba8..cb765d4c56 100644 --- a/core/modules/node/src/Tests/Views/NodeTestBase.php +++ b/core/modules/node/src/Tests/Views/NodeTestBase.php @@ -2,11 +2,16 @@ namespace Drupal\node\Tests\Views; +@trigger_error('\Drupal\node\Tests\Views\NodeTestBase is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\node\Functional\Views\NodeTestBase', E_USER_DEPRECATED); + use Drupal\views\Tests\ViewTestBase; use Drupal\views\Tests\ViewTestData; /** * Base class for all node tests. + * + * @deprecated Scheduled for removal before Drupal 9.0.0. + * Use \Drupal\Tests\node\Functional\Views\NodeTestBase instead. */ abstract class NodeTestBase extends ViewTestBase { diff --git a/core/modules/node/src/Tests/AssertButtonsTrait.php b/core/modules/node/tests/src/Functional/AssertButtonsTrait.php similarity index 84% copy from core/modules/node/src/Tests/AssertButtonsTrait.php copy to core/modules/node/tests/src/Functional/AssertButtonsTrait.php index 58d484d9e4..bc2ef9078b 100644 --- a/core/modules/node/src/Tests/AssertButtonsTrait.php +++ b/core/modules/node/tests/src/Functional/AssertButtonsTrait.php @@ -1,6 +1,6 @@ xpath('//input[@type="submit"][@value="Save"]'); @@ -30,10 +30,11 @@ public function assertButtons($buttons, $dropbutton = TRUE) { $this->assertTrue(empty($save_button)); // Dropbutton elements. + /** @var \Behat\Mink\Element\NodeElement[] $elements */ $elements = $this->xpath('//div[@class="dropbutton-wrapper"]//input[@type="submit"]'); $this->assertEqual($count, count($elements)); foreach ($elements as $element) { - $value = isset($element['value']) ? (string) $element['value'] : ''; + $value = $element->getValue() ?: ''; $this->assertEqual($buttons[$i], $value); $i++; } diff --git a/core/modules/node/src/Tests/NodeAccessAutoBubblingTest.php b/core/modules/node/tests/src/Functional/NodeAccessAutoBubblingTest.php similarity index 92% rename from core/modules/node/src/Tests/NodeAccessAutoBubblingTest.php rename to core/modules/node/tests/src/Functional/NodeAccessAutoBubblingTest.php index 789818b408..6af8d8de66 100644 --- a/core/modules/node/src/Tests/NodeAccessAutoBubblingTest.php +++ b/core/modules/node/tests/src/Functional/NodeAccessAutoBubblingTest.php @@ -1,8 +1,9 @@ nidsVisible = []; foreach ($this->xpath("//a[text()='Read more']") as $link) { // See also testTranslationRendering() in NodeTranslationUITest. - $this->assertTrue(preg_match('|node/(\d+)$|', (string) $link['href'], $matches), 'Read more points to a node'); + $this->assertTrue(preg_match('|node/(\d+)$|', $link->getAttribute('href'), $matches), 'Read more points to a node'); $this->nidsVisible[$matches[1]] = TRUE; } foreach ($this->nodesByUser as $uid => $data) { diff --git a/core/modules/node/src/Tests/NodeAccessPagerTest.php b/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php similarity index 95% rename from core/modules/node/src/Tests/NodeAccessPagerTest.php rename to core/modules/node/tests/src/Functional/NodeAccessPagerTest.php index b4fe8302e9..ad6cc54944 100644 --- a/core/modules/node/src/Tests/NodeAccessPagerTest.php +++ b/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php @@ -1,18 +1,18 @@ assertLinkByHref('node/' . $node->id() . '/edit'); $this->assertLinkByHref('node/' . $node->id() . '/delete'); // Verify that we can see the content type label. - $this->assertEqual(trim((string) $node_type_labels[$delta]), $node->type->entity->label()); + $this->assertEqual(trim($node_type_labels[$delta]->getText()), $node->type->entity->label()); $delta++; } diff --git a/core/modules/node/src/Tests/NodeBlockFunctionalTest.php b/core/modules/node/tests/src/Functional/NodeBlockFunctionalTest.php similarity index 99% rename from core/modules/node/src/Tests/NodeBlockFunctionalTest.php rename to core/modules/node/tests/src/Functional/NodeBlockFunctionalTest.php index 5a2e40a30d..ad3613d74f 100644 --- a/core/modules/node/src/Tests/NodeBlockFunctionalTest.php +++ b/core/modules/node/tests/src/Functional/NodeBlockFunctionalTest.php @@ -1,6 +1,6 @@ assertNoText('Data that should appear only in the body for the node.', 'Body text not present'); // Test that the correct build mode has been set. - $build = $this->drupalBuildEntityView($node); + $build = $this->buildEntityView($node); $this->assertEqual($build['#view_mode'], 'teaser', 'The view mode has correctly been set to teaser.'); } diff --git a/core/modules/node/src/Tests/NodeFieldMultilingualTest.php b/core/modules/node/tests/src/Functional/NodeFieldMultilingualTest.php similarity index 95% rename from core/modules/node/src/Tests/NodeFieldMultilingualTest.php rename to core/modules/node/tests/src/Functional/NodeFieldMultilingualTest.php index edd01b2d00..771426d025 100644 --- a/core/modules/node/src/Tests/NodeFieldMultilingualTest.php +++ b/core/modules/node/tests/src/Functional/NodeFieldMultilingualTest.php @@ -1,19 +1,19 @@ ' node ', ':content-class' => 'node__content', ]); - $this->assertEqual(current($body), $node->body->value, 'Node body found.'); + $this->assertEqual($body[0]->getText(), $node->body->value, 'Node body found.'); } } diff --git a/core/modules/node/src/Tests/NodeFormButtonsTest.php b/core/modules/node/tests/src/Functional/NodeFormButtonsTest.php similarity index 99% rename from core/modules/node/src/Tests/NodeFormButtonsTest.php rename to core/modules/node/tests/src/Functional/NodeFormButtonsTest.php index ed2bb8f7a4..546a6334ad 100644 --- a/core/modules/node/src/Tests/NodeFormButtonsTest.php +++ b/core/modules/node/tests/src/Functional/NodeFormButtonsTest.php @@ -1,6 +1,6 @@ $this->accounts, ]; - $permutations = $this->generatePermutations($parameters); + $permutations = TestBase::generatePermutations($parameters); $node_revision_access = \Drupal::service('access_check.node.revision'); foreach ($permutations as $case) { diff --git a/core/modules/node/src/Tests/NodeSyndicateBlockTest.php b/core/modules/node/tests/src/Functional/NodeSyndicateBlockTest.php similarity index 95% rename from core/modules/node/src/Tests/NodeSyndicateBlockTest.php rename to core/modules/node/tests/src/Functional/NodeSyndicateBlockTest.php index 23c3d881a7..c1daef94c9 100644 --- a/core/modules/node/src/Tests/NodeSyndicateBlockTest.php +++ b/core/modules/node/tests/src/Functional/NodeSyndicateBlockTest.php @@ -1,6 +1,6 @@ tag. $this->drupalGet('node/' . $node->id()); $xpath = '//title'; - $this->assertEqual(current($this->xpath($xpath)), $node->label() . ' | Drupal', 'Page title is equal to node title.', 'Node'); + $this->assertEqual($this->xpath($xpath)[0]->getText(), $node->label() . ' | Drupal', 'Page title is equal to node title.', 'Node'); // Test breadcrumb in comment preview. $this->drupalGet('comment/reply/node/' . $node->id() . '/comment'); $xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a'; - $this->assertEqual(current($this->xpath($xpath)), $node->label(), 'Node breadcrumb is equal to node title.', 'Node'); + $this->assertEqual($this->xpath($xpath)[0]->getText(), $node->label(), 'Node breadcrumb is equal to node title.', 'Node'); // Test node title in comment preview. - $this->assertEqual(current($this->xpath('//article[contains(concat(" ", normalize-space(@class), " "), :node-class)]/h2/a/span', [':node-class' => ' node--type-' . $node->bundle() . ' '])), $node->label(), 'Node preview title is equal to node title.', 'Node'); + $this->assertEqual($this->xpath('//article[contains(concat(" ", normalize-space(@class), " "), :node-class)]/h2/a/span', [':node-class' => ' node--type-' . $node->bundle() . ' '])[0]->getText(), $node->label(), 'Node preview title is equal to node title.', 'Node'); // Test node title is clickable on teaser list (/node). $this->drupalGet('node'); @@ -92,11 +92,11 @@ public function testNodeTitle() { // the page. $edge_case_title_escaped = Html::escape($edge_case_title); $this->drupalGet('node/' . $node->id()); - $this->assertTitle($edge_case_title_escaped . ' | Drupal', 'Page title is equal to article\'s "title".', 'Node'); + $this->assertRaw($edge_case_title_escaped . ' | Drupal', 'Page title is equal to article\'s "title".', 'Node'); // Test that the title appears as when reloading the node page. $this->drupalGet('node/' . $node->id()); - $this->assertTitle($edge_case_title_escaped . ' | Drupal', 'Page title is equal to article\'s "title".', 'Node'); + $this->assertRaw($edge_case_title_escaped . ' | Drupal', 'Page title is equal to article\'s "title".', 'Node'); } diff --git a/core/modules/node/src/Tests/NodeTitleXSSTest.php b/core/modules/node/tests/src/Functional/NodeTitleXSSTest.php similarity index 89% rename from core/modules/node/src/Tests/NodeTitleXSSTest.php rename to core/modules/node/tests/src/Functional/NodeTitleXSSTest.php index c5bbe95d62..cbc9162f35 100644 --- a/core/modules/node/src/Tests/NodeTitleXSSTest.php +++ b/core/modules/node/tests/src/Functional/NodeTitleXSSTest.php @@ -1,6 +1,6 @@ <?php -namespace Drupal\node\Tests; +namespace Drupal\Tests\node\Functional; use Drupal\Component\Utility\Html; @@ -32,7 +32,7 @@ public function testNodeTitleXSS() { $this->drupalGet('node/' . $node->id()); // Titles should be escaped. - $this->assertTitle(Html::escape($title) . ' | Drupal', 'Title is displayed when viewing a node.'); + $this->assertRaw(Html::escape($title) . ' | Drupal', 'Title is displayed when viewing a node.'); $this->assertNoRaw($xss, 'Harmful tags are escaped when viewing a node.'); $this->drupalGet('node/' . $node->id() . '/edit'); diff --git a/core/modules/node/src/Tests/NodeTranslationUITest.php b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php similarity index 98% rename from core/modules/node/src/Tests/NodeTranslationUITest.php rename to core/modules/node/tests/src/Functional/NodeTranslationUITest.php index a01c4d5c39..a8a74544ec 100644 --- a/core/modules/node/src/Tests/NodeTranslationUITest.php +++ b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php @@ -1,9 +1,9 @@ <?php -namespace Drupal\node\Tests; +namespace Drupal\Tests\node\Functional; use Drupal\Core\Entity\EntityInterface; -use Drupal\content_translation\Tests\ContentTranslationUITestBase; +use Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Url; use Drupal\node\Entity\Node; @@ -82,7 +82,7 @@ public function testPublishedStatusNoFields() { // Add a node. $default_langcode = $this->langcodes[0]; $values[$default_langcode] = ['title' => [['value' => $this->randomMachineName()]]]; - $entity_id = $this->createEntity($values[$default_langcode], $default_langcode); + $this->entityId = $this->createEntity($values[$default_langcode], $default_langcode); $storage = $this->container->get('entity_type.manager') ->getStorage($this->entityTypeId); $storage->resetCache([$this->entityId]); @@ -327,7 +327,7 @@ public function testTranslationRendering() { } $pattern = '|^' . $expected_href . '$|'; foreach ($this->xpath("//a[text()='Read more']") as $link) { - if (preg_match($pattern, (string) $link['href'], $matches) == TRUE) { + if (preg_match($pattern, $link->getAttribute('href'), $matches) == TRUE) { $num_match_found++; } } @@ -349,7 +349,7 @@ public function testTranslationRendering() { } $pattern = '|^' . $expected_href . '$|'; foreach ($this->xpath("//a[text()='Add new comment']") as $link) { - if (preg_match($pattern, (string) $link['href'], $matches) == TRUE) { + if (preg_match($pattern, $link->getAttribute('href'), $matches) == TRUE) { $num_match_found++; } } diff --git a/core/modules/node/src/Tests/NodeViewTest.php b/core/modules/node/tests/src/Functional/NodeViewTest.php similarity index 81% rename from core/modules/node/src/Tests/NodeViewTest.php rename to core/modules/node/tests/src/Functional/NodeViewTest.php index a01cb25a57..b0eaa47f66 100644 --- a/core/modules/node/src/Tests/NodeViewTest.php +++ b/core/modules/node/tests/src/Functional/NodeViewTest.php @@ -1,6 +1,6 @@ <?php -namespace Drupal\node\Tests; +namespace Drupal\Tests\node\Functional; use Drupal\Component\Utility\Html; @@ -21,7 +21,7 @@ public function testHtmlHeadLinks() { $this->drupalGet($node->urlInfo()); $result = $this->xpath('//link[@rel = "canonical"]'); - $this->assertEqual($result[0]['href'], $node->url()); + $this->assertEqual($result[0]->getAttribute('href'), $node->url()); // Link relations are checked for access for anonymous users. $result = $this->xpath('//link[@rel = "version-history"]'); @@ -34,14 +34,14 @@ public function testHtmlHeadLinks() { $this->drupalGet($node->urlInfo()); $result = $this->xpath('//link[@rel = "canonical"]'); - $this->assertEqual($result[0]['href'], $node->url()); + $this->assertEqual($result[0]->getAttribute('href'), $node->url()); // Link relations are present regardless of access for authenticated users. $result = $this->xpath('//link[@rel = "version-history"]'); - $this->assertEqual($result[0]['href'], $node->url('version-history')); + $this->assertEqual($result[0]->getAttribute('href'), $node->url('version-history')); $result = $this->xpath('//link[@rel = "edit-form"]'); - $this->assertEqual($result[0]['href'], $node->url('edit-form')); + $this->assertEqual($result[0]->getAttribute('href'), $node->url('edit-form')); // Give anonymous users access to edit the node. Do this through the UI to // ensure caches are handled properly. @@ -56,13 +56,13 @@ public function testHtmlHeadLinks() { // version-history link. $this->drupalGet($node->urlInfo()); $result = $this->xpath('//link[@rel = "canonical"]'); - $this->assertEqual($result[0]['href'], $node->url()); + $this->assertEqual($result[0]->getAttribute('href'), $node->url()); $result = $this->xpath('//link[@rel = "version-history"]'); $this->assertFalse($result, 'Version history not present for anonymous users without access.'); $result = $this->xpath('//link[@rel = "edit-form"]'); - $this->assertEqual($result[0]['href'], $node->url('edit-form')); + $this->assertEqual($result[0]->getAttribute('href'), $node->url('edit-form')); } /** @@ -79,7 +79,7 @@ public function testLinkHeader() { $this->drupalGet($node->urlInfo()); - $links = explode(',', $this->drupalGetHeader('Link')); + $links = $this->drupalGetHeaders()['Link']; $this->assertEqual($links, $expected); } @@ -92,7 +92,7 @@ public function testMultiByteUtf8() { $node = $this->drupalCreateNode(['title' => $title]); $this->drupalGet($node->urlInfo()); $result = $this->xpath('//span[contains(@class, "field--name-title")]'); - $this->assertEqual((string) $result[0], $title, 'The passed title was returned.'); + $this->assertEqual($result[0]->getText(), $title, 'The passed title was returned.'); } } diff --git a/core/modules/node/src/Tests/Views/BulkFormAccessTest.php b/core/modules/node/tests/src/Functional/Views/BulkFormAccessTest.php similarity index 97% rename from core/modules/node/src/Tests/Views/BulkFormAccessTest.php rename to core/modules/node/tests/src/Functional/Views/BulkFormAccessTest.php index 938e456ce5..04948c545a 100644 --- a/core/modules/node/src/Tests/Views/BulkFormAccessTest.php +++ b/core/modules/node/tests/src/Functional/Views/BulkFormAccessTest.php @@ -1,6 +1,6 @@ <?php -namespace Drupal\node\Tests\Views; +namespace Drupal\Tests\node\Functional\Views; use Drupal\Component\Utility\SafeMarkup; use Drupal\node\Entity\Node; @@ -41,8 +41,8 @@ class BulkFormAccessTest extends NodeTestBase { /** * {@inheritdoc} */ - protected function setUp() { - parent::setUp(); + protected function setUp($import_test_views = TRUE) { + parent::setUp($import_test_views); // Create Article node type. $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']); diff --git a/core/modules/node/src/Tests/Views/BulkFormTest.php b/core/modules/node/tests/src/Functional/Views/BulkFormTest.php similarity index 99% rename from core/modules/node/src/Tests/Views/BulkFormTest.php rename to core/modules/node/tests/src/Functional/Views/BulkFormTest.php index 2e7b6ff428..458933e04e 100644 --- a/core/modules/node/src/Tests/Views/BulkFormTest.php +++ b/core/modules/node/tests/src/Functional/Views/BulkFormTest.php @@ -1,6 +1,6 @@ <?php -namespace Drupal\node\Tests\Views; +namespace Drupal\Tests\node\Functional\Views; use Drupal\Component\Utility\SafeMarkup; use Drupal\language\Entity\ConfigurableLanguage; diff --git a/core/modules/node/src/Tests/Views/FilterNodeAccessTest.php b/core/modules/node/tests/src/Functional/Views/FilterNodeAccessTest.php similarity index 95% rename from core/modules/node/src/Tests/Views/FilterNodeAccessTest.php rename to core/modules/node/tests/src/Functional/Views/FilterNodeAccessTest.php index dba4419576..44f08a60d4 100644 --- a/core/modules/node/src/Tests/Views/FilterNodeAccessTest.php +++ b/core/modules/node/tests/src/Functional/Views/FilterNodeAccessTest.php @@ -1,6 +1,6 @@ <?php -namespace Drupal\node\Tests\Views; +namespace Drupal\Tests\node\Functional\Views; use Drupal\node\Entity\NodeType; @@ -31,8 +31,11 @@ class FilterNodeAccessTest extends NodeTestBase { */ public static $testViews = ['test_filter_node_access']; - protected function setUp() { - parent::setUp(); + /** + * {@inheritdoc} + */ + protected function setUp($import_test_views = TRUE) { + parent::setUp($import_test_views); $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']); diff --git a/core/modules/node/src/Tests/Views/FilterUidRevisionTest.php b/core/modules/node/tests/src/Functional/Views/FilterUidRevisionTest.php similarity index 97% rename from core/modules/node/src/Tests/Views/FilterUidRevisionTest.php rename to core/modules/node/tests/src/Functional/Views/FilterUidRevisionTest.php index 18273003ae..2b3f3b30e7 100644 --- a/core/modules/node/src/Tests/Views/FilterUidRevisionTest.php +++ b/core/modules/node/tests/src/Functional/Views/FilterUidRevisionTest.php @@ -1,6 +1,6 @@ <?php -namespace Drupal\node\Tests\Views; +namespace Drupal\Tests\node\Functional\Views; use Drupal\views\Views; diff --git a/core/modules/node/src/Tests/Views/FrontPageTest.php b/core/modules/node/tests/src/Functional/Views/FrontPageTest.php similarity index 98% rename from core/modules/node/src/Tests/Views/FrontPageTest.php rename to core/modules/node/tests/src/Functional/Views/FrontPageTest.php index 1c6003a740..37a6b91f3f 100644 --- a/core/modules/node/src/Tests/Views/FrontPageTest.php +++ b/core/modules/node/tests/src/Functional/Views/FrontPageTest.php @@ -1,13 +1,13 @@ <?php -namespace Drupal\node\Tests\Views; +namespace Drupal\Tests\node\Functional\Views; use Drupal\Core\Cache\Cache; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Url; use Drupal\node\Entity\Node; +use Drupal\Tests\views\Functional\ViewTestBase; use Drupal\views\Tests\AssertViewsCacheTagsTrait; -use Drupal\views\Tests\ViewTestBase; use Drupal\views\ViewExecutable; use Drupal\views\Views; @@ -39,8 +39,11 @@ class FrontPageTest extends ViewTestBase { */ public static $modules = ['node', 'contextual']; - protected function setUp() { - parent::setUp(); + /** + * {@inheritdoc} + */ + protected function setUp($import_test_views = TRUE) { + parent::setUp($import_test_views); $this->nodeStorage = $this->container->get('entity.manager') ->getStorage('node'); diff --git a/core/modules/node/src/Tests/Views/NodeFieldFilterTest.php b/core/modules/node/tests/src/Functional/Views/NodeFieldFilterTest.php similarity index 95% rename from core/modules/node/src/Tests/Views/NodeFieldFilterTest.php rename to core/modules/node/tests/src/Functional/Views/NodeFieldFilterTest.php index 86ff676c50..c2ee2f2763 100644 --- a/core/modules/node/src/Tests/Views/NodeFieldFilterTest.php +++ b/core/modules/node/tests/src/Functional/Views/NodeFieldFilterTest.php @@ -1,6 +1,6 @@ <?php -namespace Drupal\node\Tests\Views; +namespace Drupal\Tests\node\Functional\Views; use Drupal\language\Entity\ConfigurableLanguage; @@ -30,8 +30,11 @@ class NodeFieldFilterTest extends NodeTestBase { */ public $nodeTitles = []; - public function setUp() { - parent::setUp(); + /** + * {@inheritdoc} + */ + protected function setUp($import_test_views = TRUE) { + parent::setUp($import_test_views); // Create Page content type. if ($this->profile != 'standard') { diff --git a/core/modules/node/src/Tests/Views/NodeFieldTokensTest.php b/core/modules/node/tests/src/Functional/Views/NodeFieldTokensTest.php similarity index 97% rename from core/modules/node/src/Tests/Views/NodeFieldTokensTest.php rename to core/modules/node/tests/src/Functional/Views/NodeFieldTokensTest.php index a5b1910130..fc547ed370 100644 --- a/core/modules/node/src/Tests/Views/NodeFieldTokensTest.php +++ b/core/modules/node/tests/src/Functional/Views/NodeFieldTokensTest.php @@ -1,6 +1,7 @@ <?php -namespace Drupal\node\Tests\Views; +namespace Drupal\Tests\node\Functional\Views; + use Drupal\node\Entity\Node; use Drupal\node\Entity\NodeType; diff --git a/core/modules/node/src/Tests/Views/NodeIntegrationTest.php b/core/modules/node/tests/src/Functional/Views/NodeIntegrationTest.php similarity index 94% rename from core/modules/node/src/Tests/Views/NodeIntegrationTest.php rename to core/modules/node/tests/src/Functional/Views/NodeIntegrationTest.php index c679138199..0f855d728b 100644 --- a/core/modules/node/src/Tests/Views/NodeIntegrationTest.php +++ b/core/modules/node/tests/src/Functional/Views/NodeIntegrationTest.php @@ -1,6 +1,6 @@ <?php -namespace Drupal\node\Tests\Views; +namespace Drupal\Tests\node\Functional\Views; /** * Tests the node integration into views. @@ -59,7 +59,7 @@ protected function assertNids(array $expected_nids = []) { $result = $this->xpath('//span[@class="field-content"]'); $nids = []; foreach ($result as $element) { - $nids[] = (int) $element; + $nids[] = (int) $element->getText(); } $this->assertEqual($nids, $expected_nids); } diff --git a/core/modules/node/src/Tests/Views/NodeLanguageTest.php b/core/modules/node/tests/src/Functional/Views/NodeLanguageTest.php similarity index 99% rename from core/modules/node/src/Tests/Views/NodeLanguageTest.php rename to core/modules/node/tests/src/Functional/Views/NodeLanguageTest.php index bdd26c0caf..d2d1b479a4 100644 --- a/core/modules/node/src/Tests/Views/NodeLanguageTest.php +++ b/core/modules/node/tests/src/Functional/Views/NodeLanguageTest.php @@ -1,6 +1,6 @@ <?php -namespace Drupal\node\Tests\Views; +namespace Drupal\Tests\node\Functional\Views; use Drupal\Core\Language\LanguageInterface; use Drupal\field\Entity\FieldStorageConfig; @@ -38,7 +38,7 @@ class NodeLanguageTest extends NodeTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp($import_test_views = TRUE) { parent::setUp(FALSE); // Create Page content type. diff --git a/core/modules/node/src/Tests/Views/NodeRevisionWizardTest.php b/core/modules/node/tests/src/Functional/Views/NodeRevisionWizardTest.php similarity index 94% rename from core/modules/node/src/Tests/Views/NodeRevisionWizardTest.php rename to core/modules/node/tests/src/Functional/Views/NodeRevisionWizardTest.php index 6a774f33f7..db70b2c9da 100644 --- a/core/modules/node/src/Tests/Views/NodeRevisionWizardTest.php +++ b/core/modules/node/tests/src/Functional/Views/NodeRevisionWizardTest.php @@ -1,8 +1,8 @@ <?php -namespace Drupal\node\Tests\Views; +namespace Drupal\Tests\node\Functional\Views; -use Drupal\views\Tests\Wizard\WizardTestBase; +use Drupal\Tests\views\Functional\Wizard\WizardTestBase; use Drupal\views\Views; /** diff --git a/core/modules/node/src/Tests/Views/NodeTestBase.php b/core/modules/node/tests/src/Functional/Views/NodeTestBase.php similarity index 67% copy from core/modules/node/src/Tests/Views/NodeTestBase.php copy to core/modules/node/tests/src/Functional/Views/NodeTestBase.php index 661ad91ba8..b98778c503 100644 --- a/core/modules/node/src/Tests/Views/NodeTestBase.php +++ b/core/modules/node/tests/src/Functional/Views/NodeTestBase.php @@ -1,22 +1,23 @@ <?php -namespace Drupal\node\Tests\Views; +namespace Drupal\Tests\node\Functional\Views; -use Drupal\views\Tests\ViewTestBase; +use Drupal\Tests\views\Functional\ViewTestBase; use Drupal\views\Tests\ViewTestData; /** - * Base class for all node tests. + * Base class for all node Views tests. */ abstract class NodeTestBase extends ViewTestBase { /** - * Modules to enable. - * - * @var array + * {@inheritdoc} */ public static $modules = ['node_test_views']; + /** + * {@inheritdoc} + */ protected function setUp($import_test_views = TRUE) { parent::setUp($import_test_views); diff --git a/core/modules/node/src/Tests/Views/PathPluginTest.php b/core/modules/node/tests/src/Functional/Views/PathPluginTest.php similarity index 90% rename from core/modules/node/src/Tests/Views/PathPluginTest.php rename to core/modules/node/tests/src/Functional/Views/PathPluginTest.php index 6558f00da9..3cb4e372c9 100644 --- a/core/modules/node/src/Tests/Views/PathPluginTest.php +++ b/core/modules/node/tests/src/Functional/Views/PathPluginTest.php @@ -1,6 +1,6 @@ <?php -namespace Drupal\node\Tests\Views; +namespace Drupal\Tests\node\Functional\Views; use Drupal\views\Views; @@ -32,8 +32,11 @@ class PathPluginTest extends NodeTestBase { */ protected $nodes; - protected function setUp() { - parent::setUp(); + /** + * {@inheritdoc} + */ + protected function setUp($import_test_views = TRUE) { + parent::setUp($import_test_views); $this->drupalCreateContentType(['type' => 'article']); diff --git a/core/modules/node/src/Tests/Views/RevisionLinkTest.php b/core/modules/node/tests/src/Functional/Views/RevisionLinkTest.php similarity index 98% rename from core/modules/node/src/Tests/Views/RevisionLinkTest.php rename to core/modules/node/tests/src/Functional/Views/RevisionLinkTest.php index 0a508dc9cf..6dc20d64ec 100644 --- a/core/modules/node/src/Tests/Views/RevisionLinkTest.php +++ b/core/modules/node/tests/src/Functional/Views/RevisionLinkTest.php @@ -1,6 +1,6 @@ <?php -namespace Drupal\node\Tests\Views; +namespace Drupal\Tests\node\Functional\Views; /** * Tests the different revision link handlers. diff --git a/core/modules/node/src/Tests/Views/RowPluginTest.php b/core/modules/node/tests/src/Functional/Views/RowPluginTest.php similarity index 92% rename from core/modules/node/src/Tests/Views/RowPluginTest.php rename to core/modules/node/tests/src/Functional/Views/RowPluginTest.php index 160640fd23..fdd4d45ad2 100644 --- a/core/modules/node/src/Tests/Views/RowPluginTest.php +++ b/core/modules/node/tests/src/Functional/Views/RowPluginTest.php @@ -1,6 +1,6 @@ <?php -namespace Drupal\node\Tests\Views; +namespace Drupal\Tests\node\Functional\Views; use Drupal\views\Views; @@ -33,8 +33,11 @@ class RowPluginTest extends NodeTestBase { */ protected $nodes; - protected function setUp() { - parent::setUp(); + /** + * {@inheritdoc} + */ + protected function setUp($import_test_views = TRUE) { + parent::setUp($import_test_views); $this->drupalCreateContentType(['type' => 'article']); diff --git a/core/modules/node/src/Tests/Views/StatusExtraTest.php b/core/modules/node/tests/src/Functional/Views/StatusExtraTest.php similarity index 98% rename from core/modules/node/src/Tests/Views/StatusExtraTest.php rename to core/modules/node/tests/src/Functional/Views/StatusExtraTest.php index 9e41f5beca..7961088c48 100644 --- a/core/modules/node/src/Tests/Views/StatusExtraTest.php +++ b/core/modules/node/tests/src/Functional/Views/StatusExtraTest.php @@ -1,6 +1,6 @@ <?php -namespace Drupal\node\Tests\Views; +namespace Drupal\Tests\node\Functional\Views; use Drupal\node\NodeInterface; diff --git a/core/modules/node/src/Tests/SummaryLengthTest.php b/core/modules/node/tests/src/Kernel/SummaryLengthTest.php similarity index 61% rename from core/modules/node/src/Tests/SummaryLengthTest.php rename to core/modules/node/tests/src/Kernel/SummaryLengthTest.php index e953882e41..fa15c0e6ab 100644 --- a/core/modules/node/src/Tests/SummaryLengthTest.php +++ b/core/modules/node/tests/src/Kernel/SummaryLengthTest.php @@ -1,15 +1,82 @@ <?php -namespace Drupal\node\Tests; +namespace Drupal\Tests\node\Kernel; +use Drupal\Component\Utility\Unicode; +use Drupal\Core\Datetime\Entity\DateFormat; +use Drupal\KernelTests\KernelTestBase; use Drupal\node\Entity\Node; +use Drupal\simpletest\ContentTypeCreationTrait; +use Drupal\simpletest\NodeCreationTrait; +use Drupal\simpletest\UserCreationTrait; +use Drupal\Tests\EntityViewTrait; /** * Tests summary length. * * @group node */ -class SummaryLengthTest extends NodeTestBase { +class SummaryLengthTest extends KernelTestBase { + + use NodeCreationTrait { + getNodeByTitle as drupalGetNodeByTitle; + createNode as drupalCreateNode; + } + use UserCreationTrait { + createUser as drupalCreateUser; + createRole as drupalCreateRole; + createAdminRole as drupalCreateAdminRole; + } + use ContentTypeCreationTrait { + createContentType as drupalCreateContentType; + } + use EntityViewTrait { + buildEntityView as drupalBuildEntityView; + } + + /** + * {@inheritdoc} + */ + public static $modules = [ + 'node', + 'datetime', + 'user', + 'system', + 'filter', + 'field', + 'text', + ]; + + /** + * {@inheritdoc} + */ + protected function setUp() { + parent::setUp(); + $this->installSchema('system', 'sequences'); + $this->installSchema('node', 'node_access'); + $this->installEntitySchema('user'); + $this->installEntitySchema('node'); + $this->installEntitySchema('date_format'); + $this->installConfig('filter'); + $this->installConfig('node'); + + // Create a node type. + $this->drupalCreateContentType([ + 'type' => 'page', + 'name' => 'Basic page', + 'display_submitted' => FALSE, + ]); + + DateFormat::create([ + 'id' => 'fallback', + 'label' => 'Fallback', + 'pattern' => 'Y-m-d', + ])->save(); + + // Enable multibyte support. + Unicode::setStatus(Unicode::STATUS_MULTIBYTE); + } + /** * Tests the node summary length functionality. */ diff --git a/core/modules/node/src/Tests/Views/RevisionRelationshipsTest.php b/core/modules/node/tests/src/Kernel/Views/RevisionRelationshipsTest.php similarity index 70% rename from core/modules/node/src/Tests/Views/RevisionRelationshipsTest.php rename to core/modules/node/tests/src/Kernel/Views/RevisionRelationshipsTest.php index 51e200c020..e47bdd038b 100644 --- a/core/modules/node/src/Tests/Views/RevisionRelationshipsTest.php +++ b/core/modules/node/tests/src/Kernel/Views/RevisionRelationshipsTest.php @@ -1,9 +1,11 @@ <?php -namespace Drupal\node\Tests\Views; +namespace Drupal\Tests\node\Kernel\Views; +use Drupal\node\Entity\Node; +use Drupal\node\Entity\NodeType; +use Drupal\Tests\views\Kernel\ViewsKernelTestBase; use Drupal\views\Views; -use Drupal\views\Tests\ViewTestBase; use Drupal\views\Tests\ViewTestData; /** @@ -11,7 +13,7 @@ * * @group node */ -class RevisionRelationshipsTest extends ViewTestBase { +class RevisionRelationshipsTest extends ViewsKernelTestBase { /** * Modules to enable. @@ -20,8 +22,16 @@ class RevisionRelationshipsTest extends ViewTestBase { */ public static $modules = ['node' , 'node_test_views']; - protected function setUp() { - parent::setUp(); + /** + * {@inheritdoc} + */ + protected function setUp($import_test_views = TRUE) { + parent::setUp($import_test_views); + + $this->installSchema('node', 'node_access'); + + $this->installEntitySchema('user'); + $this->installEntitySchema('node'); ViewTestData::createTestViews(get_class($this), ['node_test_views']); } @@ -37,11 +47,13 @@ protected function setUp() { * Create a node with revision and rest result count for both views. */ public function testNodeRevisionRelationship() { - $node = $this->drupalCreateNode(); + $type = NodeType::create(['type' => 'page', 'name' => 'page']); + $type->save(); + $node = Node::create(['type' => 'page', 'title' => 'test', 'uid' => 1]); + $node->save(); // Create revision of the node. - $node_revision = clone $node; - $node_revision->setNewRevision(); - $node_revision->save(); + $node->setNewRevision(TRUE); + $node->save(); $column_map = [ 'vid' => 'vid', 'node_field_data_node_field_revision_nid' => 'node_node_revision_nid',