diff --git a/core/modules/taxonomy/tests/src/Functional/RssTest.php b/core/modules/taxonomy/src/Tests/RssTest.php similarity index 92% rename from core/modules/taxonomy/tests/src/Functional/RssTest.php rename to core/modules/taxonomy/src/Tests/RssTest.php index 2f22196469154f9dc3ff69bbaf7be7507ac909de..c4f48846b436e6f2911f25f988cef7fa67143d7d 100644 --- a/core/modules/taxonomy/tests/src/Functional/RssTest.php +++ b/core/modules/taxonomy/src/Tests/RssTest.php @@ -1,6 +1,6 @@ drupalGet("taxonomy/term/{$term1->id()}/feed"); - $assert = $this->assertSession(); - $assert->responseHeaderContains('Content-Type', 'application/rss+xml'); - // Ensure the RSS version is 2.0. - $rss_array = $this->getSession()->getDriver()->find('rss'); - $this->assertEquals('2.0', reset($rss_array)->getAttribute('version')); + $this->assertTrue(!empty($this->cssSelect('rss[version="2.0"]')), "Feed page is RSS."); // Check that the "Exception value" is disabled by default. $this->drupalGet('taxonomy/term/all/feed'); diff --git a/core/modules/taxonomy/tests/src/Functional/TaxonomyTermIndentationTest.php b/core/modules/taxonomy/src/Tests/TaxonomyTermIndentationTest.php similarity index 71% rename from core/modules/taxonomy/tests/src/Functional/TaxonomyTermIndentationTest.php rename to core/modules/taxonomy/src/Tests/TaxonomyTermIndentationTest.php index 13dcb7e1cba2a666a02cceda57d13e56c8ee7548..599b6fb2c7a790244aa18e90ba71017c0a23337e 100644 --- a/core/modules/taxonomy/tests/src/Functional/TaxonomyTermIndentationTest.php +++ b/core/modules/taxonomy/src/Tests/TaxonomyTermIndentationTest.php @@ -1,6 +1,6 @@ assertSession(); // Create three taxonomy terms. $term1 = $this->createTerm($this->vocabulary); $term2 = $this->createTerm($this->vocabulary); @@ -43,23 +42,15 @@ public function testTermIndentation() { $taxonomy_storage = $this->container->get('entity.manager')->getStorage('taxonomy_term'); // Indent the second term under the first one. - $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->get('vid') . '/overview'); - $hidden_edit = [ + $edit = [ 'terms[tid:' . $term2->id() . ':0][term][tid]' => 2, 'terms[tid:' . $term2->id() . ':0][term][parent]' => 1, 'terms[tid:' . $term2->id() . ':0][term][depth]' => 1, - ]; - // Because we can't post hidden form elements, we have to change them in - // code here, and then submit. - foreach ($hidden_edit as $field => $value) { - $node = $assert->hiddenFieldExists($field); - $node->setValue($value); - } - $edit = [ 'terms[tid:' . $term2->id() . ':0][weight]' => 1, ]; + // Submit the edited form and check for HTML indentation element presence. - $this->drupalPostForm(NULL, $edit, t('Save')); + $this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->get('vid') . '/overview', $edit, t('Save')); $this->assertPattern('|
 
|'); // Check explicitly that term 2's parent is term 1. @@ -67,22 +58,14 @@ public function testTermIndentation() { $this->assertEqual(key($parents), 1, 'Term 1 is the term 2\'s parent'); // Move the second term back out to the root level. - $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->get('vid') . '/overview'); - $hidden_edit = [ + $edit = [ 'terms[tid:' . $term2->id() . ':0][term][tid]' => 2, 'terms[tid:' . $term2->id() . ':0][term][parent]' => 0, 'terms[tid:' . $term2->id() . ':0][term][depth]' => 0, - ]; - // Because we can't post hidden form elements, we have to change them in - // code here, and then submit. - foreach ($hidden_edit as $field => $value) { - $node = $assert->hiddenFieldExists($field); - $node->setValue($value); - } - $edit = [ 'terms[tid:' . $term2->id() . ':0][weight]' => 1, ]; - $this->drupalPostForm(NULL, $edit, t('Save')); + + $this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->get('vid') . '/overview', $edit, t('Save')); // All terms back at the root level, no indentation should be present. $this->assertNoPattern('|
 
|'); diff --git a/core/modules/taxonomy/tests/src/Functional/TermAutocompleteTest.php b/core/modules/taxonomy/src/Tests/TermAutocompleteTest.php similarity index 82% rename from core/modules/taxonomy/tests/src/Functional/TermAutocompleteTest.php rename to core/modules/taxonomy/src/Tests/TermAutocompleteTest.php index 6304976176a7cf935a6d8395115c753104688523..ce28b1285d76055eabb959f07ae8596ef3d899cb 100644 --- a/core/modules/taxonomy/tests/src/Functional/TermAutocompleteTest.php +++ b/core/modules/taxonomy/src/Tests/TermAutocompleteTest.php @@ -1,8 +1,7 @@ drupalGet('node/add/article'); $result = $this->xpath('//input[@name="' . $this->fieldName . '[0][target_id]"]'); - $this->autocompleteUrl = $this->getAbsoluteUrl($result[0]->getAttribute('data-autocomplete-path')); - } - - /** - * Helper function for JSON formatted requests. - * - * @param string|\Drupal\Core\Url $path - * Drupal path or URL to load into Mink controlled browser. - * @param array $options - * (optional) Options to be forwarded to the url generator. - * @param string[] $headers - * (optional) An array containing additional HTTP request headers. - * - * @return string[] - * Array representing decoded JSON response. - */ - protected function drupalGetJson($path, array $options = [], array $headers = []) { - $options = array_merge_recursive(['query' => ['_format' => 'json']], $options); - return Json::decode($this->drupalGet($path, $options, $headers)); + $this->autocompleteUrl = $this->getAbsoluteUrl($result[0]['data-autocomplete-path']); } /** @@ -163,21 +137,21 @@ protected function drupalGetJson($path, array $options = [], array $headers = [] */ public function testAutocompleteCountResults() { // Test that no matching term found. - $data = $this->drupalGetJson( + $data = $this->drupalGetJSON( $this->autocompleteUrl, ['query' => ['q' => 'zzz']] ); $this->assertTrue(empty($data), 'Autocomplete returned no results'); // Test that only one matching term found, when only one matches. - $data = $this->drupalGetJson( + $data = $this->drupalGetJSON( $this->autocompleteUrl, ['query' => ['q' => 'aaa 10']] ); $this->assertEqual(1, count($data), 'Autocomplete returned 1 result'); // Test the correct number of matches when multiple are partial matches. - $data = $this->drupalGetJson( + $data = $this->drupalGetJSON( $this->autocompleteUrl, ['query' => ['q' => 'aaa 1']] ); @@ -185,7 +159,7 @@ public function testAutocompleteCountResults() { // Tests that only 10 results are returned, even if there are more than 10 // matches. - $data = $this->drupalGetJson( + $data = $this->drupalGetJSON( $this->autocompleteUrl, ['query' => ['q' => 'aaa']] ); @@ -218,7 +192,7 @@ public function testAutocompleteOrderedResults() { ]; } - $data = $this->drupalGetJson( + $data = $this->drupalGetJSON( $this->autocompleteUrl, ['query' => ['q' => 'bbb']] ); diff --git a/core/modules/taxonomy/tests/src/Functional/TermTest.php b/core/modules/taxonomy/src/Tests/TermTest.php similarity index 95% rename from core/modules/taxonomy/tests/src/Functional/TermTest.php rename to core/modules/taxonomy/src/Tests/TermTest.php index cce58da942ba60ea483ace7408bcb89caaa4f209..54309c4237e2a8f5089c93fc2c1aea53880a7eaf 100644 --- a/core/modules/taxonomy/tests/src/Functional/TermTest.php +++ b/core/modules/taxonomy/src/Tests/TermTest.php @@ -1,6 +1,6 @@ assertSession(); $this->createTerm($this->vocabulary); $this->createTerm($this->vocabulary); $this->createTerm($this->vocabulary); @@ -407,30 +406,21 @@ public function testTermReorder() { // "tid:1:0[depth]", and "tid:1:0[weight]". Change the order to term2, // term3, term1 by setting weight property, make term3 a child of term2 by // setting the parent and depth properties, and update all hidden fields. - $hidden_edit = [ + $edit = [ 'terms[tid:' . $term2->id() . ':0][term][tid]' => $term2->id(), 'terms[tid:' . $term2->id() . ':0][term][parent]' => 0, 'terms[tid:' . $term2->id() . ':0][term][depth]' => 0, + 'terms[tid:' . $term2->id() . ':0][weight]' => 0, 'terms[tid:' . $term3->id() . ':0][term][tid]' => $term3->id(), 'terms[tid:' . $term3->id() . ':0][term][parent]' => $term2->id(), 'terms[tid:' . $term3->id() . ':0][term][depth]' => 1, + 'terms[tid:' . $term3->id() . ':0][weight]' => 1, 'terms[tid:' . $term1->id() . ':0][term][tid]' => $term1->id(), 'terms[tid:' . $term1->id() . ':0][term][parent]' => 0, 'terms[tid:' . $term1->id() . ':0][term][depth]' => 0, - ]; - // Because we can't post hidden form elements, we have to change them in - // code here, and then submit. - foreach ($hidden_edit as $field => $value) { - $node = $assert->hiddenFieldExists($field); - $node->setValue($value); - } - // Edit non-hidden elements within drupalPostForm(). - $edit = [ - 'terms[tid:' . $term2->id() . ':0][weight]' => 0, - 'terms[tid:' . $term3->id() . ':0][weight]' => 1, 'terms[tid:' . $term1->id() . ':0][weight]' => 2, ]; - $this->drupalPostForm(NULL, $edit, 'Save'); + $this->drupalPostForm(NULL, $edit, t('Save')); $taxonomy_storage->resetCache(); $terms = $taxonomy_storage->loadTree($this->vocabulary->id()); @@ -580,7 +570,7 @@ public function testTermBreadcrumbs() { ]; // Create the term. - $this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add', $edit, 'Save'); + $this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add', $edit, t('Save')); $terms = taxonomy_term_load_multiple_by_name($edit['name[0][value]']); $term = reset($terms); @@ -588,19 +578,19 @@ public function testTermBreadcrumbs() { // Check the breadcrumb on the term edit page. $this->drupalGet('taxonomy/term/' . $term->id() . '/edit'); - $breadcrumbs = $this->getSession()->getPage()->findAll('css', 'nav.breadcrumb ol li a'); + $breadcrumbs = $this->cssSelect('nav.breadcrumb ol li a'); $this->assertIdentical(count($breadcrumbs), 2, 'The breadcrumbs are present on the page.'); - $this->assertIdentical($breadcrumbs[0]->getText(), 'Home', 'First breadcrumb text is Home'); - $this->assertIdentical($breadcrumbs[1]->getText(), $term->label(), 'Second breadcrumb text is term name on term edit page.'); - $this->assertEscaped($breadcrumbs[1]->getText(), 'breadcrumbs displayed and escaped.'); + $this->assertIdentical((string) $breadcrumbs[0], 'Home', 'First breadcrumb text is Home'); + $this->assertIdentical((string) $breadcrumbs[1], $term->label(), 'Second breadcrumb text is term name on term edit page.'); + $this->assertEscaped((string) $breadcrumbs[1], 'breadcrumbs displayed and escaped.'); // Check the breadcrumb on the term delete page. $this->drupalGet('taxonomy/term/' . $term->id() . '/delete'); - $breadcrumbs = $this->getSession()->getPage()->findAll('css', 'nav.breadcrumb ol li a'); + $breadcrumbs = $this->cssSelect('nav.breadcrumb ol li a'); $this->assertIdentical(count($breadcrumbs), 2, 'The breadcrumbs are present on the page.'); - $this->assertIdentical($breadcrumbs[0]->getText(), 'Home', 'First breadcrumb text is Home'); - $this->assertIdentical($breadcrumbs[1]->getText(), $term->label(), 'Second breadcrumb text is term name on term delete page.'); - $this->assertEscaped($breadcrumbs[1]->getText(), 'breadcrumbs displayed and escaped.'); + $this->assertIdentical((string) $breadcrumbs[0], 'Home', 'First breadcrumb text is Home'); + $this->assertIdentical((string) $breadcrumbs[1], $term->label(), 'Second breadcrumb text is term name on term delete page.'); + $this->assertEscaped((string) $breadcrumbs[1], 'breadcrumbs displayed and escaped.'); } } diff --git a/core/modules/taxonomy/tests/src/Functional/TermTranslationTest.php b/core/modules/taxonomy/src/Tests/TermTranslationTest.php similarity index 97% rename from core/modules/taxonomy/tests/src/Functional/TermTranslationTest.php rename to core/modules/taxonomy/src/Tests/TermTranslationTest.php index bd9085017b64c6da7fef6e745c909a8ee9d5b9d2..ccb16f611db5b7471a9252b4d8ca1ab58c16cf3a 100644 --- a/core/modules/taxonomy/tests/src/Functional/TermTranslationTest.php +++ b/core/modules/taxonomy/src/Tests/TermTranslationTest.php @@ -1,9 +1,9 @@