Compare commits

..

2 commits

Author SHA1 Message Date
rxu
28e39fb7b8
Merge f92fce1622 into 1b2ac50cfd 2025-05-04 18:15:09 +00:00
rxu
f92fce1622
[ticket/17491] Add test
PHPBB-17491
2025-05-05 01:14:46 +07:00

View file

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