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 testAddDecoratorsInvalidName() |
54
|
|
|
{ |
55
|
|
|
$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' ); |
56
|
|
|
|
57
|
|
|
$this->setExpectedException( '\\Aimeos\\Admin\\JQAdm\\Exception' ); |
|
|
|
|
58
|
|
|
\Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $this->context, $client, array(), |
59
|
|
|
array( '$' ), 'Test' ); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
|
63
|
|
|
public function testAddDecoratorsInvalidClass() |
64
|
|
|
{ |
65
|
|
|
$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' ); |
66
|
|
|
|
67
|
|
|
$this->setExpectedException( '\\Aimeos\\Admin\\JQAdm\\Exception' ); |
|
|
|
|
68
|
|
|
\Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $this->context, $client, array(), |
69
|
|
|
array( 'Test' ), 'TestDecorator' ); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
public function testAddDecoratorsInvalidInterface() |
74
|
|
|
{ |
75
|
|
|
$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' ); |
76
|
|
|
|
77
|
|
|
$this->setExpectedException( '\\Aimeos\\Admin\\JQAdm\\Exception' ); |
|
|
|
|
78
|
|
|
\Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $this->context, $client, array(), |
79
|
|
|
array( 'Test' ), '\\Aimeos\\Admin\\JQAdm\\Common\\Decorator\\' ); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
|
83
|
|
|
public function testAddClientDecoratorsExcludes() |
84
|
|
|
{ |
85
|
|
|
$this->context->getConfig()->set( 'admin/jqadm/decorators/excludes', array( 'TestDecorator' ) ); |
86
|
|
|
$this->context->getConfig()->set( 'admin/jqadm/common/decorators/default', array( 'TestDecorator' ) ); |
87
|
|
|
|
88
|
|
|
$this->setExpectedException( '\\Aimeos\\Admin\\JQAdm\\Exception' ); |
|
|
|
|
89
|
|
|
\Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' ); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
|
94
|
|
|
class TestAbstract |
|
|
|
|
95
|
|
|
extends \Aimeos\Admin\JQAdm\Common\Factory\Base |
|
|
|
|
96
|
|
|
{ |
97
|
|
|
/** |
98
|
|
|
* @param string $classprefix |
99
|
|
|
* @param string $path |
|
|
|
|
100
|
|
|
*/ |
101
|
|
|
public static function addDecoratorsPublic( \Aimeos\MShop\Context\Item\Iface $context, |
102
|
|
|
\Aimeos\Admin\JQAdm\Iface $client, $templatePaths, array $decorators, $classprefix ) |
103
|
|
|
{ |
104
|
|
|
self::addDecorators( $context, $client, $templatePaths, $decorators, $classprefix ); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public static function addClientDecoratorsPublic( \Aimeos\MShop\Context\Item\Iface $context, |
108
|
|
|
\Aimeos\Admin\JQAdm\Iface $client, $templatePaths, $path ) |
109
|
|
|
{ |
110
|
|
|
self::addClientDecorators( $context, $client, $templatePaths, $path ); |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
|
115
|
|
|
class TestDecorator |
|
|
|
|
116
|
|
|
{ |
117
|
|
|
} |
118
|
|
|
|
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.