Loading core/modules/block/tests/src/Kernel/BlockConfigSchemaTest.php +0 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ class BlockConfigSchemaTest extends KernelTestBase { 'comment', 'forum', 'node', 'statistics', // \Drupal\block\Entity\Block->preSave() calls system_region_list(). 'system', 'taxonomy', Loading core/modules/search/tests/src/Functional/SearchRankingTest.php +3 −17 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\comment\Tests\CommentTestTrait; use Drupal\Core\Database\Database; use Drupal\Core\Link; use Drupal\Core\Url; use Drupal\filter\Entity\FilterFormat; Loading Loading @@ -33,7 +32,7 @@ class SearchRankingTest extends BrowserTestBase { /** * {@inheritdoc} */ protected static $modules = ['node', 'search', 'statistics', 'comment']; protected static $modules = ['node', 'search', 'comment']; /** * {@inheritdoc} Loading Loading @@ -65,7 +64,7 @@ public function testRankings() { $this->addDefaultCommentField('node', 'page'); // Build a list of the rankings to test. $node_ranks = ['sticky', 'promote', 'relevance', 'recent', 'comments', 'views']; $node_ranks = ['sticky', 'promote', 'relevance', 'recent', 'comments']; // Create nodes for testing. $nodes = []; Loading Loading @@ -116,18 +115,7 @@ public function testRankings() { $this->submitForm($edit, 'Preview'); $this->submitForm($edit, 'Save'); // Enable counting of statistics. $this->config('statistics.settings')->set('count_content_views', 1)->save(); // Simulating content views is kind of difficult in the test. Leave that // to the Statistics module. So instead go ahead and manually update the // counter for this node. $nid = $nodes['views'][1]->id(); Database::getConnection()->insert('node_counter') ->fields(['totalcount' => 5, 'daycount' => 5, 'timestamp' => REQUEST_TIME, 'nid' => $nid]) ->execute(); // Run cron to update the search index and comment/statistics totals. // Run cron to update the search index totals. $this->cronRun(); // Test that the settings form displays the content ranking section. Loading Loading @@ -177,7 +165,6 @@ public function testRankings() { 'relevance' => 0, 'recent' => 0, 'comments' => 0, 'views' => 0, ]; $configuration = $this->nodeSearch->getPlugin()->getConfiguration(); foreach ($node_ranks as $var => $value) { Loading @@ -202,7 +189,6 @@ public function testRankings() { 'relevance' => 0, 'recent' => 10, 'comments' => 1, 'views' => 0, ]; $configuration = $this->nodeSearch->getPlugin()->getConfiguration(); foreach ($node_ranks as $var => $value) { Loading core/modules/statistics/tests/src/Functional/search/SearchRankingTest.php 0 → 100644 +116 −0 Original line number Diff line number Diff line <?php namespace Drupal\Tests\statistics\Functional\search; use Drupal\Core\Database\Database; use Drupal\search\Entity\SearchPage; use Drupal\Tests\BrowserTestBase; use Drupal\Tests\Traits\Core\CronRunTrait; /** * Indexes content and tests ranking factors. * * @group statistics */ class SearchRankingTest extends BrowserTestBase { use CronRunTrait; /** * The node search page. * * @var \Drupal\search\SearchPageInterface */ protected $nodeSearch; /** * {@inheritdoc} */ protected static $modules = ['node', 'search', 'statistics']; /** * {@inheritdoc} */ protected $defaultTheme = 'stark'; /** * {@inheritdoc} */ protected function setUp(): void { parent::setUp(); $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']); // Create a plugin instance. $this->nodeSearch = SearchPage::load('node_search'); // Log in with sufficient privileges. $this->drupalLogin($this->drupalCreateUser([ 'create page content', 'administer search', ])); } /** * Tests statistics ranking on search pages. */ public function testRankings() { // Create nodes for testing. $nodes = []; $settings = [ 'type' => 'page', 'title' => 'Drupal rocks', 'body' => [['value' => "Drupal's search rocks"]], // Node is one day old. 'created' => \Drupal::time()->getRequestTime() - 24 * 3600, 'sticky' => 0, 'promote' => 0, ]; foreach ([0, 1] as $num) { $nodes['views'][$num] = $this->drupalCreateNode($settings); } // Enable counting of statistics. $this->config('statistics.settings')->set('count_content_views', 1)->save(); // Simulating content views is kind of difficult in the test. So instead go // ahead and manually update the counter for this node. $nid = $nodes['views'][1]->id(); Database::getConnection()->insert('node_counter') ->fields([ 'totalcount' => 5, 'daycount' => 5, 'timestamp' => \Drupal::time()->getRequestTime(), 'nid' => $nid, ]) ->execute(); // Run cron to update the search index and statistics totals. $this->cronRun(); // Test that the settings form displays the content ranking section. $this->drupalGet('admin/config/search/pages/manage/node_search'); $this->assertSession()->pageTextContains('Content ranking'); // Check that views ranking is visible and set to 0. $this->assertSession()->optionExists('edit-rankings-views-value', '0'); // Test each of the possible rankings. $edit = []; // Enable views ranking. $edit['rankings[views][value]'] = 10; $this->drupalGet('admin/config/search/pages/manage/node_search'); $this->submitForm($edit, 'Save search page'); $this->drupalGet('admin/config/search/pages/manage/node_search'); $this->assertSession()->optionExists('edit-rankings-views-value', '10'); // Reload the plugin to get the up-to-date values. $this->nodeSearch = SearchPage::load('node_search'); // Do the search and assert the results. $this->nodeSearch->getPlugin()->setSearch('rocks', [], []); $set = $this->nodeSearch->getPlugin()->execute(); $this->assertEquals($nodes['views'][1]->id(), $set[0]['node']->id()); } } core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php +0 −1 Original line number Diff line number Diff line Loading @@ -375,7 +375,6 @@ public function testUpdatedSite() { 'search', 'serialization', 'shortcut', 'statistics', 'syslog', 'system', 'taxonomy', Loading core/modules/views/tests/src/Functional/Handler/HandlerAllTest.php +0 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,6 @@ class HandlerAllTest extends ViewTestBase { 'locale', 'node', 'search', 'statistics', 'taxonomy', 'user', ]; Loading Loading
core/modules/block/tests/src/Kernel/BlockConfigSchemaTest.php +0 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ class BlockConfigSchemaTest extends KernelTestBase { 'comment', 'forum', 'node', 'statistics', // \Drupal\block\Entity\Block->preSave() calls system_region_list(). 'system', 'taxonomy', Loading
core/modules/search/tests/src/Functional/SearchRankingTest.php +3 −17 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\comment\Tests\CommentTestTrait; use Drupal\Core\Database\Database; use Drupal\Core\Link; use Drupal\Core\Url; use Drupal\filter\Entity\FilterFormat; Loading Loading @@ -33,7 +32,7 @@ class SearchRankingTest extends BrowserTestBase { /** * {@inheritdoc} */ protected static $modules = ['node', 'search', 'statistics', 'comment']; protected static $modules = ['node', 'search', 'comment']; /** * {@inheritdoc} Loading Loading @@ -65,7 +64,7 @@ public function testRankings() { $this->addDefaultCommentField('node', 'page'); // Build a list of the rankings to test. $node_ranks = ['sticky', 'promote', 'relevance', 'recent', 'comments', 'views']; $node_ranks = ['sticky', 'promote', 'relevance', 'recent', 'comments']; // Create nodes for testing. $nodes = []; Loading Loading @@ -116,18 +115,7 @@ public function testRankings() { $this->submitForm($edit, 'Preview'); $this->submitForm($edit, 'Save'); // Enable counting of statistics. $this->config('statistics.settings')->set('count_content_views', 1)->save(); // Simulating content views is kind of difficult in the test. Leave that // to the Statistics module. So instead go ahead and manually update the // counter for this node. $nid = $nodes['views'][1]->id(); Database::getConnection()->insert('node_counter') ->fields(['totalcount' => 5, 'daycount' => 5, 'timestamp' => REQUEST_TIME, 'nid' => $nid]) ->execute(); // Run cron to update the search index and comment/statistics totals. // Run cron to update the search index totals. $this->cronRun(); // Test that the settings form displays the content ranking section. Loading Loading @@ -177,7 +165,6 @@ public function testRankings() { 'relevance' => 0, 'recent' => 0, 'comments' => 0, 'views' => 0, ]; $configuration = $this->nodeSearch->getPlugin()->getConfiguration(); foreach ($node_ranks as $var => $value) { Loading @@ -202,7 +189,6 @@ public function testRankings() { 'relevance' => 0, 'recent' => 10, 'comments' => 1, 'views' => 0, ]; $configuration = $this->nodeSearch->getPlugin()->getConfiguration(); foreach ($node_ranks as $var => $value) { Loading
core/modules/statistics/tests/src/Functional/search/SearchRankingTest.php 0 → 100644 +116 −0 Original line number Diff line number Diff line <?php namespace Drupal\Tests\statistics\Functional\search; use Drupal\Core\Database\Database; use Drupal\search\Entity\SearchPage; use Drupal\Tests\BrowserTestBase; use Drupal\Tests\Traits\Core\CronRunTrait; /** * Indexes content and tests ranking factors. * * @group statistics */ class SearchRankingTest extends BrowserTestBase { use CronRunTrait; /** * The node search page. * * @var \Drupal\search\SearchPageInterface */ protected $nodeSearch; /** * {@inheritdoc} */ protected static $modules = ['node', 'search', 'statistics']; /** * {@inheritdoc} */ protected $defaultTheme = 'stark'; /** * {@inheritdoc} */ protected function setUp(): void { parent::setUp(); $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']); // Create a plugin instance. $this->nodeSearch = SearchPage::load('node_search'); // Log in with sufficient privileges. $this->drupalLogin($this->drupalCreateUser([ 'create page content', 'administer search', ])); } /** * Tests statistics ranking on search pages. */ public function testRankings() { // Create nodes for testing. $nodes = []; $settings = [ 'type' => 'page', 'title' => 'Drupal rocks', 'body' => [['value' => "Drupal's search rocks"]], // Node is one day old. 'created' => \Drupal::time()->getRequestTime() - 24 * 3600, 'sticky' => 0, 'promote' => 0, ]; foreach ([0, 1] as $num) { $nodes['views'][$num] = $this->drupalCreateNode($settings); } // Enable counting of statistics. $this->config('statistics.settings')->set('count_content_views', 1)->save(); // Simulating content views is kind of difficult in the test. So instead go // ahead and manually update the counter for this node. $nid = $nodes['views'][1]->id(); Database::getConnection()->insert('node_counter') ->fields([ 'totalcount' => 5, 'daycount' => 5, 'timestamp' => \Drupal::time()->getRequestTime(), 'nid' => $nid, ]) ->execute(); // Run cron to update the search index and statistics totals. $this->cronRun(); // Test that the settings form displays the content ranking section. $this->drupalGet('admin/config/search/pages/manage/node_search'); $this->assertSession()->pageTextContains('Content ranking'); // Check that views ranking is visible and set to 0. $this->assertSession()->optionExists('edit-rankings-views-value', '0'); // Test each of the possible rankings. $edit = []; // Enable views ranking. $edit['rankings[views][value]'] = 10; $this->drupalGet('admin/config/search/pages/manage/node_search'); $this->submitForm($edit, 'Save search page'); $this->drupalGet('admin/config/search/pages/manage/node_search'); $this->assertSession()->optionExists('edit-rankings-views-value', '10'); // Reload the plugin to get the up-to-date values. $this->nodeSearch = SearchPage::load('node_search'); // Do the search and assert the results. $this->nodeSearch->getPlugin()->setSearch('rocks', [], []); $set = $this->nodeSearch->getPlugin()->execute(); $this->assertEquals($nodes['views'][1]->id(), $set[0]['node']->id()); } }
core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php +0 −1 Original line number Diff line number Diff line Loading @@ -375,7 +375,6 @@ public function testUpdatedSite() { 'search', 'serialization', 'shortcut', 'statistics', 'syslog', 'system', 'taxonomy', Loading
core/modules/views/tests/src/Functional/Handler/HandlerAllTest.php +0 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,6 @@ class HandlerAllTest extends ViewTestBase { 'locale', 'node', 'search', 'statistics', 'taxonomy', 'user', ]; Loading