forked from aimeos/aimeos-core
/
FactoryTest.php
executable file
·115 lines (79 loc) · 3.66 KB
/
FactoryTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
/**
* @copyright Metaways Infosystems GmbH, 2013
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
* @copyright Aimeos (aimeos.org), 2015
*/
namespace Aimeos\Controller\ExtJS;
/**
* Test class for \Aimeos\Controller\ExtJS\Factory.
*/
class FactoryTest extends \PHPUnit_Framework_TestCase
{
public function testCreateController()
{
$controller = \Aimeos\Controller\ExtJS\Factory::createController( \TestHelperExtjs::getContext(), 'attribute' );
$this->assertInstanceOf( '\\Aimeos\\Controller\\ExtJS\\Common\\Iface', $controller );
}
public function testCreateSubController()
{
$controller = \Aimeos\Controller\ExtJS\Factory::createController( \TestHelperExtjs::getContext(), 'attribute/lists/type' );
$this->assertInstanceOf( '\\Aimeos\\Controller\\ExtJS\\Common\\Iface', $controller );
}
public function testCreateControllerEmpty()
{
$this->setExpectedException( '\\Aimeos\\Controller\\ExtJS\\Exception' );
\Aimeos\Controller\ExtJS\Factory::createController( \TestHelperExtjs::getContext(), "\t\n" );
}
public function testCreateControllerInvalidName()
{
$this->setExpectedException( '\\Aimeos\\Controller\\ExtJS\\Exception' );
\Aimeos\Controller\ExtJS\Factory::createController( \TestHelperExtjs::getContext(), '%^' );
}
public function testCreateControllerNotExisting()
{
$this->setExpectedException( '\\Aimeos\\Controller\\ExtJS\\Exception' );
\Aimeos\Controller\ExtJS\Factory::createController( \TestHelperExtjs::getContext(), 'notexist' );
}
public function testCreateSubControllerNotExisting()
{
$this->setExpectedException( '\\Aimeos\\Controller\\ExtJS\\Exception' );
\Aimeos\Controller\ExtJS\Factory::createController( \TestHelperExtjs::getContext(), 'attribute/notexist' );
}
public function testClear()
{
$cache = \Aimeos\Controller\ExtJS\Factory::setCache( true );
$context = \TestHelperExtjs::getContext();
$controller1 = \Aimeos\Controller\ExtJS\Factory::createController( $context, 'attribute' );
\Aimeos\Controller\ExtJS\Factory::clear();
$controller2 = \Aimeos\Controller\ExtJS\Factory::createController( $context, 'attribute' );
\Aimeos\Controller\ExtJS\Factory::setCache( $cache );
$this->assertNotSame( $controller1, $controller2 );
}
public function testClearSite()
{
$cache = \Aimeos\Controller\ExtJS\Factory::setCache( true );
$context = \TestHelperExtjs::getContext();
$cntlA1 = \Aimeos\Controller\ExtJS\Factory::createController( $context, 'attribute' );
$cntlB1 = \Aimeos\Controller\ExtJS\Factory::createController( $context, 'attribute/lists/type' );
\Aimeos\Controller\ExtJS\Factory::clear( (string) $context );
$cntlA2 = \Aimeos\Controller\ExtJS\Factory::createController( $context, 'attribute' );
$cntlB2 = \Aimeos\Controller\ExtJS\Factory::createController( $context, 'attribute/lists/type' );
\Aimeos\Controller\ExtJS\Factory::setCache( $cache );
$this->assertNotSame( $cntlA1, $cntlA2 );
$this->assertNotSame( $cntlB1, $cntlB2 );
}
public function testClearSpecific()
{
$cache = \Aimeos\Controller\ExtJS\Factory::setCache( true );
$context = \TestHelperExtjs::getContext();
$cntlA1 = \Aimeos\Controller\ExtJS\Factory::createController( $context, 'attribute' );
$cntlB1 = \Aimeos\Controller\ExtJS\Factory::createController( $context, 'attribute/lists/type' );
\Aimeos\Controller\ExtJS\Factory::clear( (string) $context, 'attribute' );
$cntlA2 = \Aimeos\Controller\ExtJS\Factory::createController( $context, 'attribute' );
$cntlB2 = \Aimeos\Controller\ExtJS\Factory::createController( $context, 'attribute/lists/type' );
\Aimeos\Controller\ExtJS\Factory::setCache( $cache );
$this->assertNotSame( $cntlA1, $cntlA2 );
$this->assertSame( $cntlB1, $cntlB2 );
}
}