1
|
|
|
<?php namespace DocLister\Tests;
|
2
|
|
|
|
3
|
|
|
abstract class ModxAbstract extends TestAbstract
|
4
|
|
|
{
|
5
|
|
|
protected $modx = null;
|
6
|
|
|
|
7
|
|
|
public function setUp()
|
8
|
|
|
{
|
9
|
|
|
$this->modx = $this->mockMODX();
|
10
|
|
|
$this->assertTrue($this->modx instanceof \DocumentParser);
|
11
|
|
|
$this->assertTrue($this->modx->db instanceof \DBAPI);
|
|
|
|
|
12
|
|
|
}
|
13
|
|
|
|
14
|
|
|
protected function mockDBAPI()
|
15
|
|
|
{
|
16
|
|
|
$DBAPI = $this->getMockBuilder('DBAPI')
|
17
|
|
|
->setMethods(array('query', 'makeArray', 'escape', 'getValue'))
|
18
|
|
|
->getMock();
|
19
|
|
|
|
20
|
|
|
$DBAPI->expects($this->any())
|
21
|
|
|
->method('makeArray')
|
22
|
|
|
->will($this->returnValue(array()));
|
23
|
|
|
|
24
|
|
|
$DBAPI->expects($this->any())
|
25
|
|
|
->method('escape')
|
26
|
|
|
->will($this->returnArgument(0));
|
27
|
|
|
|
28
|
|
|
$DBAPI->expects($this->any())
|
29
|
|
|
->method('getValue')
|
30
|
|
|
->will($this->returnValue('db_value'));
|
31
|
|
|
|
32
|
|
|
return $DBAPI;
|
33
|
|
|
}
|
34
|
|
|
|
35
|
|
|
protected function mockMODX(array $config = array())
|
36
|
|
|
{
|
37
|
|
|
$modx = $this->getMockBuilder('DocumentParser')
|
38
|
|
|
->setMethods(array('getFullTableName'))
|
39
|
|
|
->getMock();
|
40
|
|
|
|
41
|
|
|
$modx->expects($this->any())
|
42
|
|
|
->method('getFullTableName')
|
43
|
|
|
->will($this->returnArgument(0));
|
44
|
|
|
|
45
|
|
|
$modx->db = $this->mockDBAPI();
|
|
|
|
|
46
|
|
|
|
47
|
|
|
$modx->documentObject = array(
|
|
|
|
|
48
|
|
|
'id' => 1,
|
49
|
|
|
'type' => 'document',
|
50
|
|
|
'contentType' => 'text/html',
|
51
|
|
|
'pagetitle' => 'New document',
|
52
|
|
|
'longtitle' => '',
|
53
|
|
|
'description' => '',
|
54
|
|
|
'alias' => '',
|
55
|
|
|
'link_attributes' => '',
|
56
|
|
|
'published' => 1,
|
57
|
|
|
'pub_date' => 0,
|
58
|
|
|
'unpub_date' => 0,
|
59
|
|
|
'parent' => 0,
|
60
|
|
|
'isfolder' => 0,
|
61
|
|
|
'introtext' => '',
|
62
|
|
|
'content' => '',
|
63
|
|
|
'richtext' => 1,
|
64
|
|
|
'template' => 0,
|
65
|
|
|
'menuindex' => 0,
|
66
|
|
|
'searchable' => 1,
|
67
|
|
|
'cacheable' => 1,
|
68
|
|
|
'createdon' => 0,
|
69
|
|
|
'createdby' => 0,
|
70
|
|
|
'editedon' => 0,
|
71
|
|
|
'editedby' => 0,
|
72
|
|
|
'deleted' => 0,
|
73
|
|
|
'deletedon' => 0,
|
74
|
|
|
'deletedby' => 0,
|
75
|
|
|
'publishedon' => 0,
|
76
|
|
|
'publishedby' => 0,
|
77
|
|
|
'menutitle' => '',
|
78
|
|
|
'donthit' => 0,
|
79
|
|
|
'haskeywords' => 0,
|
80
|
|
|
'hasmetatags' => 0,
|
81
|
|
|
'privateweb' => 0,
|
82
|
|
|
'privatemgr' => 0,
|
83
|
|
|
'content_dispo' => 0,
|
84
|
|
|
'hidemenu' => 0,
|
85
|
|
|
'alias_visible' => 1
|
86
|
|
|
);
|
87
|
|
|
$modx->documentIdentifier = 1;
|
|
|
|
|
88
|
|
|
$modx->config = array_merge(array(
|
|
|
|
|
89
|
|
|
'manager_language' => 'russian-UTF8',
|
90
|
|
|
'site_start' => 1,
|
91
|
|
|
'site_url' => 'http://example.com/',
|
92
|
|
|
), $config);
|
93
|
|
|
|
94
|
|
|
return $modx;
|
95
|
|
|
|
96
|
|
|
}
|
97
|
|
|
} |