Passed
Push — master ( 365418...ec127b )
by Aimeos
02:19
created

FactoryTest::testCreateController()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 9
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2021
6
 */
7
8
9
namespace Aimeos\Controller\Frontend\Site;
10
11
12
class FactoryTest extends \PHPUnit\Framework\TestCase
13
{
14
	public function testCreateController()
15
	{
16
		$target = '\\Aimeos\\Controller\\Frontend\\Site\\Iface';
17
18
		$controller = \Aimeos\Controller\Frontend\Site\Factory::create( \TestHelperFrontend::getContext() );
19
		$this->assertInstanceOf( $target, $controller );
20
21
		$controller = \Aimeos\Controller\Frontend\Site\Factory::create( \TestHelperFrontend::getContext(), 'Standard' );
22
		$this->assertInstanceOf( $target, $controller );
23
	}
24
25
26
	public function testCreateControllerInvalidImplementation()
27
	{
28
		$this->expectException( '\\Aimeos\\MW\\Common\\Exception' );
29
		\Aimeos\Controller\Frontend\Site\Factory::create( \TestHelperFrontend::getContext(), 'Invalid' );
30
	}
31
32
33
	public function testCreateControllerInvalidName()
34
	{
35
		$this->expectException( '\\Aimeos\\Controller\\Frontend\\Exception' );
36
		\Aimeos\Controller\Frontend\Site\Factory::create( \TestHelperFrontend::getContext(), '%^' );
37
	}
38
39
40
	public function testCreateControllerNotExisting()
41
	{
42
		$this->expectException( '\\Aimeos\\Controller\\Frontend\\Exception' );
43
		\Aimeos\Controller\Frontend\Site\Factory::create( \TestHelperFrontend::getContext(), 'notexist' );
44
	}
45
}
46