mirror of
https://github.com/phpbb/phpbb.git
synced 2025-01-17 22:28:46 +01:00
[ticket/11174] Extract phpbb_search_test_case.
PHPBB3-11174
This commit is contained in:
parent
04480ec4ae
commit
a5900a6b11
@ -7,24 +7,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function phpbb_native_search_wrapper($class)
|
require_once dirname(__FILE__) . '/../test_framework/phpbb_search_test_case.php';
|
||||||
{
|
|
||||||
$wrapped = $class . '_wrapper';
|
|
||||||
if (!class_exists($wrapped))
|
|
||||||
{
|
|
||||||
$code = "
|
|
||||||
class $wrapped extends $class
|
|
||||||
{
|
|
||||||
public function get_must_contain_ids() { return \$this->must_contain_ids; }
|
|
||||||
public function get_must_not_contain_ids() { return \$this->must_not_contain_ids; }
|
|
||||||
}
|
|
||||||
";
|
|
||||||
eval($code);
|
|
||||||
}
|
|
||||||
return $wrapped;
|
|
||||||
}
|
|
||||||
|
|
||||||
class phpbb_search_native_test extends phpbb_database_test_case
|
class phpbb_search_native_test extends phpbb_search_test_case
|
||||||
{
|
{
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $search;
|
protected $search;
|
||||||
@ -45,7 +30,7 @@ class phpbb_search_native_test extends phpbb_database_test_case
|
|||||||
|
|
||||||
$this->db = $this->new_dbal();
|
$this->db = $this->new_dbal();
|
||||||
$error = null;
|
$error = null;
|
||||||
$class = phpbb_native_search_wrapper('phpbb_search_fulltext_native');
|
$class = self::get_search_wrapper('phpbb_search_fulltext_native');
|
||||||
$this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user);
|
$this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
28
tests/test_framework/phpbb_search_test_case.php
Normal file
28
tests/test_framework/phpbb_search_test_case.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package testing
|
||||||
|
* @copyright (c) 2012 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
abstract class phpbb_search_test_case extends phpbb_database_test_case
|
||||||
|
{
|
||||||
|
static protected function get_search_wrapper($class)
|
||||||
|
{
|
||||||
|
$wrapped = $class . '_wrapper';
|
||||||
|
if (!class_exists($wrapped))
|
||||||
|
{
|
||||||
|
$code = "
|
||||||
|
class $wrapped extends $class
|
||||||
|
{
|
||||||
|
public function get_must_contain_ids() { return \$this->must_contain_ids; }
|
||||||
|
public function get_must_not_contain_ids() { return \$this->must_not_contain_ids; }
|
||||||
|
}
|
||||||
|
";
|
||||||
|
eval($code);
|
||||||
|
}
|
||||||
|
return $wrapped;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user