|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2025 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
namespace Aimeos\Controller; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class FrontendTest extends \PHPUnit\Framework\TestCase |
|
13
|
|
|
{ |
|
14
|
|
|
public function testCreateController() |
|
15
|
|
|
{ |
|
16
|
|
|
$controller = \Aimeos\Controller\Frontend::create( \TestHelper::context(), 'basket' ); |
|
17
|
|
|
$this->assertInstanceOf( '\\Aimeos\\Controller\\Frontend\\Iface', $controller ); |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
|
|
21
|
|
|
public function testCreateControllerEmpty() |
|
22
|
|
|
{ |
|
23
|
|
|
$this->expectException( '\\Aimeos\\Controller\\Frontend\\Exception' ); |
|
24
|
|
|
\Aimeos\Controller\Frontend::create( \TestHelper::context(), '' ); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
public function testCreateControllerInvalidName() |
|
29
|
|
|
{ |
|
30
|
|
|
$this->expectException( \LogicException::class ); |
|
31
|
|
|
\Aimeos\Controller\Frontend::create( \TestHelper::context(), '%^unknown' ); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
public function testCreateControllerNotExisting() |
|
36
|
|
|
{ |
|
37
|
|
|
$this->expectException( \LogicException::class ); |
|
38
|
|
|
\Aimeos\Controller\Frontend::create( \TestHelper::context(), 'unknown' ); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
public function testCreateSubControllerNotExisting() |
|
43
|
|
|
{ |
|
44
|
|
|
$this->expectException( \LogicException::class ); |
|
45
|
|
|
\Aimeos\Controller\Frontend::create( \TestHelper::context(), 'basket/unknown' ); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
|
|
49
|
|
|
public function testCache() |
|
50
|
|
|
{ |
|
51
|
|
|
$context = \TestHelper::context(); |
|
52
|
|
|
\Aimeos\Controller\Frontend::cache( true ); |
|
53
|
|
|
|
|
54
|
|
|
$controller1 = \Aimeos\Controller\Frontend::create( $context, 'basket' ); |
|
55
|
|
|
$controller2 = \Aimeos\Controller\Frontend::create( $context, 'basket' ); |
|
56
|
|
|
|
|
57
|
|
|
\Aimeos\Controller\Frontend::cache( false ); |
|
58
|
|
|
$this->assertNotSame( $controller1, $controller2 ); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|