diff --git a/modules/search_api_db/search_api_db_defaults/tests/src/Functional/IntegrationTest.php b/modules/search_api_db/search_api_db_defaults/tests/src/Functional/IntegrationTest.php index 0e6e22c..ef6ca58 100644 --- a/modules/search_api_db/search_api_db_defaults/tests/src/Functional/IntegrationTest.php +++ b/modules/search_api_db/search_api_db_defaults/tests/src/Functional/IntegrationTest.php @@ -54,7 +54,7 @@ public function setUp() { /** * Tests whether the default search was correctly installed. */ - protected function testInstallAndDefaultSetupWorking() { + public function testInstallAndDefaultSetupWorking() { $this->drupalLogin($this->adminUser); // Install the search_api_db_defaults module. diff --git a/modules/search_api_db/tests/src/FunctionalJavascript/IntegrationTest.php b/modules/search_api_db/tests/src/FunctionalJavascript/IntegrationTest.php index bd486a2..9f0a0a8 100644 --- a/modules/search_api_db/tests/src/FunctionalJavascript/IntegrationTest.php +++ b/modules/search_api_db/tests/src/FunctionalJavascript/IntegrationTest.php @@ -4,8 +4,6 @@ use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\FunctionalJavascriptTests\JavascriptTestBase; -use Drupal\Tests\search_api\Functional\SearchApiBrowserTestBase; -use Drupal\Tests\simpletest\FunctionalJavascript\BrowserWithJavascriptTest; /** * Tests that using the DB backend via the UI works as expected. diff --git a/tests/src/Functional/ExampleContentTrait.php b/tests/src/Functional/ExampleContentTrait.php index 84798df..c24f751 100644 --- a/tests/src/Functional/ExampleContentTrait.php +++ b/tests/src/Functional/ExampleContentTrait.php @@ -67,7 +67,7 @@ protected function insertExampleContent() { 'width' => '2.0', ]); $count = \Drupal::entityQuery('entity_test_mulrev_changed')->count()->execute(); - $this->assertEquals($count, 5, "$count items inserted."); + $this->assertEquals(5, $count, "$count items inserted."); } /** diff --git a/tests/src/Functional/HooksTest.php b/tests/src/Functional/HooksTest.php index b8e1b2e..fed83a9 100644 --- a/tests/src/Functional/HooksTest.php +++ b/tests/src/Functional/HooksTest.php @@ -152,7 +152,7 @@ public function testHooks() { ->getInstances(); // hook_search_api_displays_alter was invoked. $display_label = $displays['views_page:search_api_test_view__page_1']->label(); - $this->assertEqual($display_label, 'Some funny label for testing'); + $this->assertEquals('Some funny label for testing', $display_label); } } diff --git a/tests/src/Functional/IntegrationTest.php b/tests/src/Functional/IntegrationTest.php index 8f30096..58fd0bf 100644 --- a/tests/src/Functional/IntegrationTest.php +++ b/tests/src/Functional/IntegrationTest.php @@ -9,7 +9,6 @@ use Drupal\field\Entity\FieldStorageConfig; use Drupal\node\Entity\Node; use Drupal\search_api\Entity\Server; -use Drupal\search_api\IndexInterface; use Drupal\search_api\Plugin\search_api\tracker\Basic; use Drupal\search_api\SearchApiException; use Drupal\search_api\Utility\Utility; @@ -297,12 +296,12 @@ protected function createIndex() { $index = $this->getIndex(TRUE); $this->assertTrue($index, 'Index was correctly created.'); - $this->assertEquals($index->label(), $edit['name'], 'Name correctly inserted.'); - $this->assertEquals($index->id(), $edit['id'], 'Index ID correctly inserted.'); + $this->assertEquals($edit['name'], $index->label(), 'Name correctly inserted.'); + $this->assertEquals($edit['id'], $index->id(), 'Index ID correctly inserted.'); $this->assertTrue($index->status(), 'Index status correctly inserted.'); - $this->assertEquals($index->getDescription(), $edit['description'], 'Index ID correctly inserted.'); - $this->assertEquals($index->getServerId(), $edit['server'], 'Index server ID correctly inserted.'); - $this->assertEquals($index->getDatasourceIds()[0], $index_datasource, 'Index datasource id correctly inserted.'); + $this->assertEquals($edit['description'], $index->getDescription(), 'Index ID correctly inserted.'); + $this->assertEquals($edit['server'], $index->getServerId(), 'Index server ID correctly inserted.'); + $this->assertEquals($index_datasource, $index->getDatasourceIds()[0], 'Index datasource id correctly inserted.'); // Test the "Save and add fields" button. $index2_id = 'test_index2'; @@ -363,7 +362,7 @@ protected function editServer() { // Check if it's possible to change the machine name. $elements = $this->xpath('//form[@id="search-api-server-edit-form"]/div[contains(@class, "form-item-id")]/input[@disabled]'); - $this->assertEquals(count($elements), 1, 'Machine name cannot be changed.'); + $this->assertEquals(1, count($elements), 'Machine name cannot be changed.'); $tracked_items_before = $this->countTrackedItems(); @@ -397,7 +396,7 @@ protected function editIndex() { // Check if it's possible to change the machine name. $elements = $this->xpath('//form[@id="search-api-index-edit-form"]/div[contains(@class, "form-item-id")]/input[@disabled]'); - $this->assertEquals(count($elements), 1, 'Machine name cannot be changed.'); + $this->assertEquals(1, count($elements), 'Machine name cannot be changed.'); // Test the AJAX functionality for configuring the tracker. $edit = ['tracker' => 'search_api_test']; @@ -417,8 +416,8 @@ protected function editIndex() { 'foo' => 'foobar', 'dependencies' => [], ]; - $this->assertEquals($tracker->getConfiguration(), $configuration, 'Tracker config was successfully saved.'); - $this->assertEquals($this->countTrackedItems(), $tracked_items, 'Items are still correctly tracked.'); + $this->assertEquals($configuration, $tracker->getConfiguration(), 'Tracker config was successfully saved.'); + $this->assertEquals($tracked_items, $this->countTrackedItems(), 'Items are still correctly tracked.'); // Revert back to the default tracker for the rest of the test. $edit = ['tracker' => 'default']; @@ -479,7 +478,7 @@ protected function checkServerAvailability() { protected function checkContentEntityTracking() { // Initially there should be no tracked items, because there are no nodes. $tracked_items = $this->countTrackedItems(); - $this->assertEquals($tracked_items, 0, 'No items are tracked yet.'); + $this->assertEquals(0, $tracked_items, 'No items are tracked yet.'); // Add two articles and two pages (one of them "invisible" to Search API). $article1 = $this->drupalCreateNode(['type' => 'article']); @@ -502,12 +501,12 @@ protected function checkContentEntityTracking() { // The 3 new nodes without "search_api_skip_tracking" property set should // have been added to the tracking table immediately. $tracked_items = $this->countTrackedItems(); - $this->assertEquals($tracked_items, 3, 'Three items are tracked.'); + $this->assertEquals(3, $tracked_items, 'Three items are tracked.'); $this->getCalledMethods('backend'); $page2->delete(); $methods = $this->getCalledMethods('backend'); - $this->assertEquals($methods, [], 'Tracking of a delete operation could successfully be prevented.'); + $this->assertEquals([], $methods, 'Tracking of a delete operation could successfully be prevented.'); // Test disabling the index. $settings_path = $this->getIndexPath('edit'); @@ -522,7 +521,7 @@ protected function checkContentEntityTracking() { $this->assertSession()->pageTextContains($this->t('The index was successfully saved.')); $tracked_items = $this->countTrackedItems(); - $this->assertEquals($tracked_items, 0, 'No items are tracked.'); + $this->assertEquals(0, $tracked_items, 'No items are tracked.'); // Test re-enabling the index. $this->drupalGet($settings_path); @@ -538,7 +537,7 @@ protected function checkContentEntityTracking() { $this->assertSession()->pageTextContains($this->t('The index was successfully saved.')); $tracked_items = $this->countTrackedItems(); - $this->assertEquals($tracked_items, 3, 'Three items are tracked.'); + $this->assertEquals(3, $tracked_items, 'Three items are tracked.'); // Uncheck "default" and don't select any bundles. This should remove all // items from the tracking table. @@ -554,7 +553,7 @@ protected function checkContentEntityTracking() { $this->assertSession()->pageTextContains($this->t('The index was successfully saved.')); $tracked_items = $this->countTrackedItems(); - $this->assertEquals($tracked_items, 0, 'No items are tracked.'); + $this->assertEquals(0, $tracked_items, 'No items are tracked.'); // Leave "default" unchecked and select the "article" bundle. This should // re-add the two articles to the tracking table. @@ -570,7 +569,7 @@ protected function checkContentEntityTracking() { $this->assertSession()->pageTextContains($this->t('The index was successfully saved.')); $tracked_items = $this->countTrackedItems(); - $this->assertEquals($tracked_items, 2, 'Two items are tracked.'); + $this->assertEquals(2, $tracked_items, 'Two items are tracked.'); // Leave "default" unchecked and select only the "page" bundle. This should // result in only the page being present in the tracking table. @@ -586,7 +585,7 @@ protected function checkContentEntityTracking() { $this->assertSession()->pageTextContains($this->t('The index was successfully saved.')); $tracked_items = $this->countTrackedItems(); - $this->assertEquals($tracked_items, 1, 'One item is tracked.'); + $this->assertEquals(1, $tracked_items, 'One item is tracked.'); // Check "default" again and select the "article" bundle. This shouldn't // change the tracking table, which should still only contain the page. @@ -602,7 +601,7 @@ protected function checkContentEntityTracking() { $this->assertSession()->pageTextContains($this->t('The index was successfully saved.')); $tracked_items = $this->countTrackedItems(); - $this->assertEquals($tracked_items, 1, 'One item is tracked.'); + $this->assertEquals(1, $tracked_items, 'One item is tracked.'); // Leave "default" checked but now select only the "page" bundle. This // should result in only the articles being tracked. @@ -618,25 +617,25 @@ protected function checkContentEntityTracking() { $this->assertSession()->pageTextContains($this->t('The index was successfully saved.')); $tracked_items = $this->countTrackedItems(); - $this->assertEquals($tracked_items, 2, 'Two items are tracked.'); + $this->assertEquals(2, $tracked_items, 'Two items are tracked.'); // Index items, then check whether updating an article is handled correctly. $this->getCalledMethods('backend'); $article1->save(); $methods = $this->getCalledMethods('backend'); - $this->assertEquals($methods, ['indexItems'], 'Update successfully tracked.'); + $this->assertEquals(['indexItems'], $methods, 'Update successfully tracked.'); $article1->search_api_skip_tracking = TRUE; $article1->save(); $methods = $this->getCalledMethods('backend'); - $this->assertEquals($methods, [], 'Tracking of entity update successfully prevented.'); + $this->assertEquals([], $methods, 'Tracking of entity update successfully prevented.'); unset($article1->search_api_skip_tracking); // Delete an article. That should remove it from the item table. $article1->delete(); $tracked_items = $this->countTrackedItems(); - $this->assertEquals($tracked_items, 1, 'One item is tracked.'); + $this->assertEquals(1, $tracked_items, 'One item is tracked.'); } /** @@ -760,7 +759,7 @@ protected function addFieldsToIndex() { $index = $this->getIndex(TRUE); $fields = $index->getFields(); - $this->assertTrue(!empty($fields['nid']), 'nid field is indexed.'); + $this->assertArrayHasKey('nid', $fields, 'nid field is indexed.'); // Ensure that we aren't offered to index properties of the "Content type" // property. @@ -770,28 +769,19 @@ protected function addFieldsToIndex() { $this->assertSession()->responseNotContains('property_path=type'); // The "Content access" processor correctly marked fields as locked. - $this->assertTrue(!empty($fields['uid']), 'uid field is indexed.'); - // @todo Do we need this if? - if (!empty($fields['uid'])) { - $this->assertTrue($fields['uid']->isIndexedLocked(), 'uid field is locked.'); - $this->assertTrue($fields['uid']->isTypeLocked(), 'uid field is type-locked.'); - $this->assertEquals($fields['uid']->getType(), 'integer', 'uid field has type integer.'); - } - $this->assertTrue(!empty($fields['status']), 'status field is indexed.'); - // @todo Do we need this if? - if (!empty($fields['status'])) { - $this->assertTrue($fields['status']->isIndexedLocked(), 'status field is locked.'); - $this->assertTrue($fields['status']->isTypeLocked(), 'status field is type-locked.'); - $this->assertEquals($fields['status']->getType(), 'boolean', 'status field has type boolean.'); - } + $this->assertArrayHasKey('uid', $fields, 'uid field is indexed.'); + $this->assertTrue($fields['uid']->isIndexedLocked(), 'uid field is locked.'); + $this->assertTrue($fields['uid']->isTypeLocked(), 'uid field is type-locked.'); + $this->assertEquals('integer', $fields['uid']->getType(), 'uid field has type integer.'); + $this->assertArrayHasKey('status', $fields, 'status field is indexed.'); + $this->assertTrue($fields['status']->isIndexedLocked(), 'status field is locked.'); + $this->assertTrue($fields['status']->isTypeLocked(), 'status field is type-locked.'); + $this->assertEquals('boolean', $fields['status']->getType(), 'status field has type boolean.'); // Check that a 'parent_data_type.data_type' Search API field type => data // type mapping relationship works. - $this->assertTrue(!empty($fields['body']), 'body field is indexed.'); - // @todo Do we need this if? - if (!empty($fields['body'])) { - $this->assertEquals($fields['body']->getType(), 'text', 'Complex field mapping relationship works.'); - } + $this->assertArrayHasKey('body', $fields, 'body field is indexed.'); + $this->assertEquals('text', $fields['body']->getType(), 'Complex field mapping relationship works.'); $edit = [ 'fields[title][title]' => 'new_title', @@ -807,17 +797,17 @@ protected function addFieldsToIndex() { $index = $this->getIndex(TRUE); $fields = $index->getFields(); - $this->assertTrue(!empty($fields['new_id']), 'title field is indexed.'); + $this->assertArrayHasKey('new_id', $fields, 'title field is indexed.'); if (!empty($fields['new_id'])) { - $this->assertEquals($fields['new_id']->getLabel(), $edit['fields[title][title]'], 'title field title is saved.'); - $this->assertEquals($fields['new_id']->getFieldIdentifier(), $edit['fields[title][id]'], 'title field id value is saved.'); - $this->assertEquals($fields['new_id']->getType(), $edit['fields[title][type]'], 'title field type is text.'); - $this->assertEquals($fields['new_id']->getBoost(), $edit['fields[title][boost]'], 'title field boost value is 21.'); + $this->assertEquals($edit['fields[title][title]'], $fields['new_id']->getLabel(), 'title field title is saved.'); + $this->assertEquals($edit['fields[title][id]'], $fields['new_id']->getFieldIdentifier(), 'title field id value is saved.'); + $this->assertEquals($edit['fields[title][type]'], $fields['new_id']->getType(), 'title field type is text.'); + $this->assertEquals($edit['fields[title][boost]'], $fields['new_id']->getBoost(), 'title field boost value is 21.'); } - $this->assertTrue(!empty($fields['revision_log']), 'revision_log field is indexed.'); + $this->assertArrayHasKey('revision_log', $fields, 'revision_log field is indexed.'); if (!empty($fields['revision_log'])) { - $this->assertEquals($fields['revision_log']->getType(), $edit['fields[revision_log][type]'], 'revision_log field type is search_api_test.'); + $this->assertEquals($edit['fields[revision_log][type]'], $fields['revision_log']->getType(), 'revision_log field type is search_api_test.'); } // Reset field values to original. @@ -847,12 +837,12 @@ protected function checkDataTypesTable() { // Make sure we display the right icon and fallback column. if (strpos($label, 'Unsupported') === 0) { - $this->assertEquals($icon, 'error.svg', 'An error icon is shown for unsupported data types.'); + $this->assertEquals('error.svg', $icon, 'An error icon is shown for unsupported data types.'); $this->assertNotEquals($fallback, '', 'The fallback data type label is not empty for unsupported data types.'); } else { - $this->assertEquals($icon, 'check.svg', 'A check icon is shown for supported data types.'); - $this->assertEquals($fallback, '', 'The fallback data type label is empty for supported data types.'); + $this->assertEquals('check.svg', $icon, 'A check icon is shown for supported data types.'); + $this->assertEquals('', $fallback, 'The fallback data type label is empty for supported data types.'); } } } @@ -957,10 +947,6 @@ protected function removeFieldsDependencies() { $this->submitForm([], t('Delete')); $this->assertNotNull($this->getIndex(), 'Index was not deleted.'); - // @todo Do we need this if? - if (!$this->getIndex()) { - throw new \Exception('Index deleted, test aborted.'); - } $this->drupalGet($this->getIndexPath('fields')); $this->assertSession()->statusCodeEquals(200); @@ -981,11 +967,9 @@ protected function removeFieldsFromIndex() { // Find the "Remove" link for the "body" field. $links = $this->xpath('//a[@data-drupal-selector=:id]', [':id' => 'edit-fields-body-remove']); $this->assertNotEmpty($links, 'Found "Remove" link for body field'); - // @todo do we need this if? - if (is_array($links) && !empty($links)) { - $url_target = $this->getAbsoluteUrl($links[0]->getAttribute('href')); - $this->drupalGet($url_target); - } + $this->assertInternalType('array', $links); + $url_target = $this->getAbsoluteUrl($links[0]->getAttribute('href')); + $this->drupalGet($url_target); $this->drupalGet($this->getIndexPath('fields')); $this->submitForm([], $this->t('Save changes')); @@ -1033,10 +1017,7 @@ protected function checkUnsavedChanges() { $this->assertFalse($this->xpath('//input[not(@disabled)]')); $match_result = preg_match('#fields/break-lock">([^<>]*?)#', $message, $m); $this->assertTrue($match_result); - // @todo Do we need this if? - if ($match_result) { - $this->clickLink($m[1]); - } + $this->clickLink($m[1]); $this->assertSession()->responseContains($this->t('By breaking this lock, any unsaved changes made by @user will be lost.', $args)); $this->submitForm([], $this->t('Break lock')); @@ -1049,16 +1030,14 @@ protected function checkUnsavedChanges() { // Find the "Remove" link for the "title" field. $links = $this->xpath('//a[@data-drupal-selector=:id]', array(':id' => 'edit-fields-title-remove')); $this->assertNotEmpty($links, 'Found "Remove" link for title field'); - // @todo do we need this if? - if (is_array($links) && !empty($links)) { - $url_target = $this->getAbsoluteUrl($links[0]->getAttribute('href')); - $this->drupalGet($url_target); - } + $this->assertInternalType('array', $links); + $url_target = $this->getAbsoluteUrl($links[0]->getAttribute('href')); + $this->drupalGet($url_target); $this->assertSession()->pageTextContains($this->t('You have unsaved changes.')); $this->submitForm([], $this->t('Cancel')); - $this->assertTrue(!empty($fields['title']), 'The title field has not been removed from the index.'); + $this->assertArrayHasKey('title', $fields, 'The title field has not been removed from the index.'); } /** @@ -1319,7 +1298,7 @@ protected function changeIndexDatasource() { $this->assertSession()->pageTextContains($this->t('The index was successfully saved.')); $tracked_items = $this->countTrackedItems(); - $this->assertEquals($tracked_items, $user_count + $node_count, 'Correct number of items tracked after enabling the "User" datasource.'); + $this->assertEquals($user_count + $node_count, $tracked_items, 'Correct number of items tracked after enabling the "User" datasource.'); // Disable indexing of users again. $edit = [ @@ -1333,7 +1312,7 @@ protected function changeIndexDatasource() { $this->executeTasks(); $tracked_items = $this->countTrackedItems(); - $this->assertEquals($tracked_items, $node_count, 'Correct number of items tracked after disabling the "User" datasource.'); + $this->assertEquals($node_count, $tracked_items, 'Correct number of items tracked after disabling the "User" datasource.'); } /** @@ -1353,7 +1332,7 @@ protected function changeIndexServer() { $index->indexItems(); $remaining_items = $this->countRemainingItems(); - $this->assertEquals($remaining_items, 0, 'All items have been successfully indexed.'); + $this->assertEquals(0, $remaining_items, 'All items have been successfully indexed.'); // Create a second search server. $this->createServer('test_server_2'); @@ -1369,7 +1348,7 @@ protected function changeIndexServer() { // After saving the new index, we should have called reindex. $remaining_items = $this->countRemainingItems(); - $this->assertEquals($remaining_items, $node_count, 'All items still need to be indexed.'); + $this->assertEquals($node_count, $remaining_items, 'All items still need to be indexed.'); } /** @@ -1395,11 +1374,8 @@ protected function deleteServer() { /** @var $index \Drupal\search_api\IndexInterface */ $index = $this->indexStorage->load($this->indexId); $this->assertTrue($index, 'The index associated with the server was not deleted.'); - // @todo do we need this if? - if ($index instanceof IndexInterface) { - $this->assertFalse($index->status(), 'The index associated with the server was disabled.'); - $this->assertNull($index->getServerId(), 'The index was removed from the server.'); - } + $this->assertFalse($index->status(), 'The index associated with the server was disabled.'); + $this->assertNull($index->getServerId(), 'The index was removed from the server.'); } /** diff --git a/tests/src/Functional/LanguageIntegrationTest.php b/tests/src/Functional/LanguageIntegrationTest.php index 1d675ed..ab1a0d4 100644 --- a/tests/src/Functional/LanguageIntegrationTest.php +++ b/tests/src/Functional/LanguageIntegrationTest.php @@ -50,7 +50,7 @@ public function testIndexSettings() { // Those 2 new nodes should be added to the tracking table immediately. $tracked_items = $this->countTrackedItems(); - $this->assertEquals($tracked_items, 2, 'Two items are tracked.'); + $this->assertEquals(2, $tracked_items, 'Two items are tracked.'); // Add translations. $translation = ['title' => 'test NL', 'body' => 'NL body']; @@ -63,7 +63,7 @@ public function testIndexSettings() { // The translations should be tracked as well, so we have a total of 5 // indexed items. $tracked_items = $this->countTrackedItems(); - $this->assertEquals($tracked_items, 5, 'Five items are tracked.'); + $this->assertEquals(5, $tracked_items, 'Five items are tracked.'); // Clear index. $this->drupalGet($this->getIndexPath()); diff --git a/tests/src/Functional/OverviewPageTest.php b/tests/src/Functional/OverviewPageTest.php index cec7323..a903ab5 100644 --- a/tests/src/Functional/OverviewPageTest.php +++ b/tests/src/Functional/OverviewPageTest.php @@ -261,8 +261,7 @@ protected function assertLocalAction(array $actions) { // This behaviour is a bug in libxml, see // https://bugs.php.net/bug.php?id=49437. $this->assertSession()->responseMatches('@]*class="[^"]*button-action[^"]*"[^>]*>' . preg_quote($title, '@') . 'assertEquals($elements[$index]->getAttribute('href'), $url->toString()); - $index++; + $this->assertEquals($url->toString(), $elements[$index++]->getAttribute('href')); } } diff --git a/tests/src/Functional/SearchApiBrowserTestBase.php b/tests/src/Functional/SearchApiBrowserTestBase.php index 4b39bcf..ec4da8b 100644 --- a/tests/src/Functional/SearchApiBrowserTestBase.php +++ b/tests/src/Functional/SearchApiBrowserTestBase.php @@ -3,9 +3,8 @@ namespace Drupal\Tests\search_api\Functional; use Drupal\Component\Utility\Html; -use Drupal\Core\EventSubscriber\AjaxResponseSubscriber; -use Drupal\Core\EventSubscriber\MainContentViewSubscriber; use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\node\Entity\NodeType; use Drupal\search_api\Entity\Index; use Drupal\search_api\Entity\Server; use Drupal\Tests\BrowserTestBase; @@ -35,9 +34,10 @@ */ protected $adminUser; - /* The number of meta refresh redirects to follow, or NULL if unlimited. + /** + * The number of meta refresh redirects to follow, or NULL if unlimited. * - * @var null|int + * @var int|null */ protected $maximumMetaRefreshCount = NULL; @@ -100,17 +100,21 @@ public function setUp() { // Get the URL generator. $this->urlGenerator = $this->container->get('url_generator'); - // Create a node article type. - $this->drupalCreateContentType([ - 'type' => 'article', - 'name' => 'Article', - ]); + // Create an article node type, if not already present. + if (!NodeType::load('article')) { + $this->drupalCreateContentType([ + 'type' => 'article', + 'name' => 'Article', + ]); + } - // Create a node page type. - $this->drupalCreateContentType([ - 'type' => 'page', - 'name' => 'Page', - ]); + // Create a page node type, if not already present. + if (!NodeType::load('page')) { + $this->drupalCreateContentType([ + 'type' => 'page', + 'name' => 'Page', + ]); + } // Do not use a batch for tracking the initial items after creating an // index when running the tests via the GUI. Otherwise, it seems Drupal's @@ -197,15 +201,12 @@ protected function executeTasks() { } /** - * Checks for meta refresh tag and if found call drupalGet() recursively. - * - * This function looks for the http-equiv attribute to be set to "Refresh" and - * is case-sensitive. + * Checks for meta refresh tag and, if found, calls drupalGet() recursively. * - * @see https://www.drupal.org/node/2757023#comment-11445519 + * This function looks for the "http-equiv" attribute to be set to "Refresh" + * and is case-sensitive. * - * @return string|false - * Either the new page content or FALSE. + * @todo Remove once #2757023 gets committed (and we can depend on it). */ protected function checkForMetaRefresh() { $refresh = $this->cssSelect('meta[http-equiv="Refresh"]'); @@ -213,14 +214,13 @@ protected function checkForMetaRefresh() { // Parse the content attribute of the meta tag for the format: // "[delay]: URL=[page_to_redirect_to]". if (preg_match('/\d+;\s*URL=(?.*)/i', $refresh[0]->getAttribute('content'), $match)) { - $this->metaRefreshCount++; + ++$this->metaRefreshCount; $this->drupalGet($this->getAbsoluteUrl(Html::decodeEntities($match['url']))); $this->checkForMetaRefresh(); } } - // Flusch number of RefreshCount. + // Reset refresh count. $this->metaRefreshCount = 0; - return FALSE; } } diff --git a/tests/src/Functional/ViewsTest.php b/tests/src/Functional/ViewsTest.php index 8d804c9..25276db 100644 --- a/tests/src/Functional/ViewsTest.php +++ b/tests/src/Functional/ViewsTest.php @@ -670,8 +670,8 @@ protected function submitPluginForm(array $edit) { /** * Installs Drupal into the Simpletest site. * - * We need copy \Drupal\Tests\BrowserTestBase::installDrupal() because before - * modules install we need add test entity bundles for this test. + * We need to override \Drupal\Tests\BrowserTestBase::installDrupal() because + * before modules install we need to add test entity bundles for this test. */ public function installDrupal() { // Define information about the user 1 account.