1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2016 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\Admin\JQAdm\Common\Factory; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class BaseTest extends \PHPUnit_Framework_TestCase |
13
|
|
|
{ |
14
|
|
|
private $context; |
15
|
|
|
|
16
|
|
|
|
17
|
|
|
protected function setUp() |
18
|
|
|
{ |
19
|
|
|
$this->context = \TestHelperJqadm::getContext(); |
20
|
|
|
$this->context->setView( \TestHelperJqadm::getView() ); |
21
|
|
|
|
22
|
|
|
$config = $this->context->getConfig(); |
23
|
|
|
$config->set( 'admin/jqadm/common/decorators/default', array() ); |
24
|
|
|
$config->set( 'admin/jqadm/decorators/global', array() ); |
25
|
|
|
$config->set( 'admin/jqadm/decorators/local', array() ); |
26
|
|
|
|
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
public function testInjectClient() |
31
|
|
|
{ |
32
|
|
|
$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' ); |
33
|
|
|
\Aimeos\Admin\JQAdm\Product\Factory::injectClient( '\\Aimeos\\Admin\\JQAdm\\Product\\Standard', $client ); |
34
|
|
|
|
35
|
|
|
$iClient = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' ); |
36
|
|
|
|
37
|
|
|
$this->assertSame( $client, $iClient ); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
|
41
|
|
|
public function testInjectClientReset() |
42
|
|
|
{ |
43
|
|
|
$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' ); |
44
|
|
|
\Aimeos\Admin\JQAdm\Product\Factory::injectClient( '\\Aimeos\\Admin\\JQAdm\\Product\\Standard', $client ); |
45
|
|
|
\Aimeos\Admin\JQAdm\Product\Factory::injectClient( '\\Aimeos\\Admin\\JQAdm\\Product\\Standard', null ); |
46
|
|
|
|
47
|
|
|
$new = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' ); |
48
|
|
|
|
49
|
|
|
$this->assertNotSame( $client, $new ); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
public function testAddDecorators() |
54
|
|
|
{ |
55
|
|
|
$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' ); |
56
|
|
|
|
57
|
|
|
$result = \Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $this->context, $client, |
58
|
|
|
array(), array( 'Cache' ), '\\Aimeos\\Admin\\JQAdm\\Common\\Decorator\\' ); |
59
|
|
|
|
60
|
|
|
$this->assertInstanceOf( '\Aimeos\Admin\JQAdm\Iface', $result ); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
|
64
|
|
|
public function testAddDecoratorsInvalidName() |
65
|
|
|
{ |
66
|
|
|
$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' ); |
67
|
|
|
|
68
|
|
|
$this->setExpectedException( '\\Aimeos\\Admin\\JQAdm\\Exception' ); |
|
|
|
|
69
|
|
|
\Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $this->context, $client, array(), |
70
|
|
|
array( '$' ), 'Test' ); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
|
74
|
|
|
public function testAddDecoratorsInvalidClass() |
75
|
|
|
{ |
76
|
|
|
$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' ); |
77
|
|
|
|
78
|
|
|
$this->setExpectedException( '\\Aimeos\\Admin\\JQAdm\\Exception' ); |
|
|
|
|
79
|
|
|
\Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $this->context, $client, array(), |
80
|
|
|
array( 'Test' ), 'TestDecorator' ); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
|
84
|
|
|
public function testAddDecoratorsInvalidInterface() |
85
|
|
|
{ |
86
|
|
|
$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' ); |
87
|
|
|
|
88
|
|
|
$this->setExpectedException( '\\Aimeos\\Admin\\JQAdm\\Exception' ); |
|
|
|
|
89
|
|
|
\Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $this->context, $client, array(), |
90
|
|
|
array( 'Test' ), '\\Aimeos\\Admin\\JQAdm\\Common\\Decorator\\' ); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
|
94
|
|
|
public function testAddClientDecoratorsExcludes() |
95
|
|
|
{ |
96
|
|
|
$this->context->getConfig()->set( 'admin/jqadm/decorators/excludes', array( 'TestDecorator' ) ); |
97
|
|
|
$this->context->getConfig()->set( 'admin/jqadm/common/decorators/default', array( 'TestDecorator' ) ); |
98
|
|
|
|
99
|
|
|
$this->setExpectedException( '\\Aimeos\\Admin\\JQAdm\\Exception' ); |
|
|
|
|
100
|
|
|
\Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' ); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
|
104
|
|
|
public function testAddClientDecoratorsEmptyPath() |
105
|
|
|
{ |
106
|
|
|
$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' ); |
107
|
|
|
|
108
|
|
|
$this->setExpectedException( '\\Aimeos\\Admin\\JQAdm\\Exception' ); |
|
|
|
|
109
|
|
|
\Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::addClientDecoratorsPublic( $this->context, $client, array(), '' ); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
|
113
|
|
|
public function testCreateClientBase() |
114
|
|
|
{ |
115
|
|
|
$this->setExpectedException( '\\Aimeos\\Admin\\JQAdm\\Exception' ); |
|
|
|
|
116
|
|
|
\Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::createClientBasePublic( $this->context, 'Test', 'Test', array() ); |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
|
121
|
|
|
class TestAbstract |
|
|
|
|
122
|
|
|
extends \Aimeos\Admin\JQAdm\Common\Factory\Base |
|
|
|
|
123
|
|
|
{ |
124
|
|
|
/** |
125
|
|
|
* @param string $classprefix |
126
|
|
|
* @param string $path |
|
|
|
|
127
|
|
|
*/ |
128
|
|
|
public static function addDecoratorsPublic( \Aimeos\MShop\Context\Item\Iface $context, |
129
|
|
|
\Aimeos\Admin\JQAdm\Iface $client, $templatePaths, array $decorators, $classprefix ) |
130
|
|
|
{ |
131
|
|
|
return self::addDecorators( $context, $client, $templatePaths, $decorators, $classprefix ); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
public static function addClientDecoratorsPublic( \Aimeos\MShop\Context\Item\Iface $context, |
135
|
|
|
\Aimeos\Admin\JQAdm\Iface $client, $templatePaths, $path ) |
136
|
|
|
{ |
137
|
|
|
return self::addClientDecorators( $context, $client, $templatePaths, $path ); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
public static function createClientBasePublic( \Aimeos\MShop\Context\Item\Iface $context, |
141
|
|
|
$classname, $interface, $templatePath ) |
142
|
|
|
{ |
143
|
|
|
return self::createClientBase( $context, $classname, $interface, $templatePath ); |
144
|
|
|
} |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
|
148
|
|
|
class TestDecorator |
|
|
|
|
149
|
|
|
{ |
150
|
|
|
} |
151
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.