|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* @package sitemaker |
|
5
|
|
|
* @copyright (c) 2015 Daniel A. (blitze) |
|
6
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
|
7
|
|
|
* |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace blitze\sitemaker\tests\model\mapper; |
|
11
|
|
|
|
|
12
|
|
|
class base_mapper extends \phpbb_database_test_case |
|
13
|
|
|
{ |
|
14
|
|
|
protected $config; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Define the extension to be tested. |
|
18
|
|
|
* |
|
19
|
|
|
* @return string[] |
|
20
|
|
|
*/ |
|
21
|
|
|
protected static function setup_extensions() |
|
22
|
|
|
{ |
|
23
|
|
|
return array('blitze/sitemaker'); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Load required fixtures. |
|
28
|
|
|
* |
|
29
|
|
|
* @return mixed |
|
30
|
|
|
*/ |
|
31
|
|
|
public function getDataSet() |
|
32
|
|
|
{ |
|
33
|
|
|
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/menu.xml'); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function setUp() |
|
37
|
|
|
{ |
|
38
|
|
|
parent::setUp(); |
|
39
|
|
|
|
|
40
|
|
|
global $config; |
|
41
|
|
|
|
|
42
|
|
|
$config = $this->config = new \phpbb\config\config(array( |
|
43
|
|
|
'force_server_vars' => false, |
|
44
|
|
|
'sitemaker.table_lock.menu_items_table' => 0 |
|
45
|
|
|
)); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Create the blocks mapper |
|
50
|
|
|
* @param string $type |
|
51
|
|
|
* @return mixed |
|
52
|
|
|
*/ |
|
53
|
|
|
protected function get_mapper($type) |
|
54
|
|
|
{ |
|
55
|
|
|
global $db, $request, $user; |
|
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
$table_prefix = 'phpbb_'; |
|
58
|
|
|
$collection_class = '\\blitze\\sitemaker\\model\\menus\\collections\\' . $type; |
|
59
|
|
|
$mapper_class = '\\blitze\\sitemaker\\model\\menus\\mapper\\' . $type; |
|
60
|
|
|
$tables = array( |
|
61
|
|
|
'mapper_tables' => array( |
|
62
|
|
|
'menus' => $table_prefix . 'sm_menus', |
|
63
|
|
|
'items' => $table_prefix . 'sm_menu_items' |
|
64
|
|
|
) |
|
65
|
|
|
); |
|
66
|
|
|
|
|
67
|
|
|
$db = $this->new_dbal(); |
|
68
|
|
|
|
|
69
|
|
|
$request = $this->getMock('\phpbb\request\request_interface'); |
|
70
|
|
|
|
|
71
|
|
|
$user = $this->getMockBuilder('\phpbb\user') |
|
72
|
|
|
->disableOriginalConstructor() |
|
73
|
|
|
->getMock(); |
|
74
|
|
|
$user->host = 'www.example.com'; |
|
75
|
|
|
$user->page['root_script_path'] = '/phpBB/'; |
|
76
|
|
|
|
|
77
|
|
|
$mapper_factory = new \blitze\sitemaker\model\mapper_factory($this->config, $db, $tables); |
|
78
|
|
|
$collection = new $collection_class; |
|
79
|
|
|
|
|
80
|
|
|
return new $mapper_class($db, $collection, $mapper_factory, $tables['mapper_tables'][$type], $this->config); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
Instead of relying on
globalstate, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state