Compare commits

..

2 commits

Author SHA1 Message Date
rxu
2968c2859a
Merge 70160d646c into 1b2ac50cfd 2025-05-05 03:14:18 +00:00
rxu
70160d646c
[ticket/17491] Add test
PHPBB-17491
2025-05-05 10:13:45 +07:00

View file

@ -223,6 +223,12 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case
public function test_caching_search_results()
{
// Sphinx search doesn't use phpBB search results caching
if (strpos($this->search_backend, 'fulltext_sphinx'))
{
$this->markTestSkipped("Sphinx search doesn't use phpBB search results caching");
}
$this->purge_cache();
$this->login();
$this->admin_login();
@ -235,7 +241,7 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case
$posts_count = (int) $matches[1];
$this->assertStringContainsString("Search found $posts_count matches", $posts_found_text, $this->search_backend);
// Set this value to cache less results than total count
$sql = 'UPDATE ' . CONFIG_TABLE . '
SET config_value = ' . floor($posts_count / 3) . "
@ -250,7 +256,7 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case
$values['config[posts_per_page]'] = floor($posts_count / 10);
$form->setValues($values);
$crawler = self::submit($form);
$this->assertEquals(1, $crawler->filter('.successbox')->count());
$this->assertEquals(1, $crawler->filter('.successbox')->count(), $this->search_backend);
// Now actually test caching search results
$this->purge_cache();
@ -333,10 +339,10 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case
$post_ids_cached_backup = $post_ids_cached;
// Cached data still should have initial 'd' sort direction
$this->assertTrue($post_ids_cached[-2] === 'd');
$this->assertTrue($post_ids_cached[-2] === 'd', $this->search_backend);
// Cached search results count should be more than or equal to displayed one
$this->assertGreaterThanOrEqual($posts_count, $post_ids_cached[-1]);
$this->assertGreaterThanOrEqual($posts_count, $post_ids_cached[-1], $this->search_backend);
/* Check post ids cached data. Array shouldn't change after removing duplicates and re-sorting.
* That means it shouldn't have any duplicates and it should be properly ordered already
@ -345,7 +351,7 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case
unset($post_ids_cached_backup[-2], $post_ids_cached_backup[-1]);
$post_ids_cached = array_unique($post_ids_cached);
rsort($post_ids_cached);
$this->assertEquals($post_ids_cached_backup, $post_ids_cached);
$this->assertEquals($post_ids_cached_backup, $post_ids_cached, $this->search_backend);
// Restore this value to default
$sql = 'UPDATE ' . CONFIG_TABLE . '
@ -353,7 +359,7 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case
WHERE config_name = '" . $this->db->sql_escape('search_block_size') . "'";
$this->db->sql_query($sql);
$crawler = self::submit($form);
$this->assertEquals(1, $crawler->filter('.successbox')->count());
$this->assertEquals(1, $crawler->filter('.successbox')->count(), $this->search_backend);
// Restore posts_per_page value
$crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=post');
@ -362,7 +368,7 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case
$values['config[posts_per_page]'] = $current_posts_per_page;
$form->setValues($values);
$crawler = self::submit($form);
$this->assertEquals(1, $crawler->filter('.successbox')->count());
$this->assertEquals(1, $crawler->filter('.successbox')->count(), $this->search_backend);
}
protected function create_search_index($backend = null)