This repository has been archived by the owner on Oct 17, 2022. It is now read-only.
forked from aimeos/aimeos-core
/
FactoryTest.php
executable file
·104 lines (72 loc) · 3.1 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
<?php
/**
* @copyright Copyright (c) Metaways Infosystems GmbH, 2013
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
*/
/**
* Test class for Controller_Frontend_Factory.
*/
class Controller_Frontend_FactoryTest extends PHPUnit_Framework_TestCase
{
public function testCreateController()
{
$controller = Controller_Frontend_Factory::createController( TestHelper::getContext(), 'basket' );
$this->assertInstanceOf( 'Controller_Frontend_Common_Interface', $controller );
}
public function testCreateControllerEmpty()
{
$this->setExpectedException( 'Controller_Frontend_Exception' );
Controller_Frontend_Factory::createController( TestHelper::getContext(), "\t\n" );
}
public function testCreateControllerInvalidName()
{
$this->setExpectedException( 'Controller_Frontend_Exception' );
Controller_Frontend_Factory::createController( TestHelper::getContext(), '%^' );
}
public function testCreateControllerNotExisting()
{
$this->setExpectedException( 'Controller_Frontend_Exception' );
Controller_Frontend_Factory::createController( TestHelper::getContext(), 'notexist' );
}
public function testCreateSubControllerNotExisting()
{
$this->setExpectedException( 'Controller_Frontend_Exception' );
Controller_Frontend_Factory::createController( TestHelper::getContext(), 'basket/notexist' );
}
public function testClear()
{
$cache = Controller_Frontend_Factory::setCache( true );
$context = TestHelper::getContext();
$controller1 = Controller_Frontend_Factory::createController( $context, 'basket' );
Controller_Frontend_Factory::clear();
$controller2 = Controller_Frontend_Factory::createController( $context, 'basket' );
Controller_Frontend_Factory::setCache( $cache );
$this->assertNotSame( $controller1, $controller2 );
}
public function testClearSite()
{
$cache = Controller_Frontend_Factory::setCache( true );
$context = TestHelper::getContext();
$basket1 = Controller_Frontend_Factory::createController( $context, 'basket' );
$catalog1 = Controller_Frontend_Factory::createController( $context, 'catalog' );
Controller_Frontend_Factory::clear( (string) $context );
$basket2 = Controller_Frontend_Factory::createController( $context, 'basket' );
$catalog2 = Controller_Frontend_Factory::createController( $context, 'catalog' );
Controller_Frontend_Factory::setCache( $cache );
$this->assertNotSame( $basket1, $basket2 );
$this->assertNotSame( $catalog1, $catalog2 );
}
public function testClearSpecific()
{
$cache = Controller_Frontend_Factory::setCache( true );
$context = TestHelper::getContext();
$basket1 = Controller_Frontend_Factory::createController( $context, 'basket' );
$catalog1 = Controller_Frontend_Factory::createController( $context, 'catalog' );
Controller_Frontend_Factory::clear( (string) $context, 'basket' );
$basket2 = Controller_Frontend_Factory::createController( $context, 'basket' );
$catalog2 = Controller_Frontend_Factory::createController( $context, 'catalog' );
Controller_Frontend_Factory::setCache( $cache );
$this->assertNotSame( $basket1, $basket2 );
$this->assertSame( $catalog1, $catalog2 );
}
}