Completed
Push — master ( f9d464...00af66 )
by Aimeos
02:40
created

FactoryTest::testClearSpecific()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 12

Duplication

Lines 20
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 20
loc 20
rs 9.4285
cc 1
eloc 12
nc 1
nop 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015
6
 */
7
8
9
namespace Aimeos\Admin\JsonAdm;
10
11
12
class FactoryTest extends \PHPUnit_Framework_TestCase
13
{
14 View Code Duplication
	public function testCreateClient()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
15
	{
16
		$context = \TestHelperJadm::getContext();
17
		$templatePaths = \TestHelperJadm::getJsonadmPaths();
18
19
		$client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' );
20
		$this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client );
21
	}
22
23
24 View Code Duplication
	public function testCreateSubClient()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
	{
26
		$context = \TestHelperJadm::getContext();
27
		$templatePaths = \TestHelperJadm::getJsonadmPaths();
28
29
		$client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' );
30
		$this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client );
31
	}
32
33
34 View Code Duplication
	public function testCreateClientEmpty()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
35
	{
36
		$context = \TestHelperJadm::getContext();
37
		$templatePaths = \TestHelperJadm::getJsonadmPaths();
38
39
		$client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '' );
40
		$this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client );
41
	}
42
43
44 View Code Duplication
	public function testCreateClientInvalidPath()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
	{
46
		$context = \TestHelperJadm::getContext();
47
		$templatePaths = \TestHelperJadm::getJsonadmPaths();
48
49
		$this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' );
50
		\Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '%^' );
51
	}
52
53
54
	public function testCreateClientInvalidName()
55
	{
56
		$context = \TestHelperJadm::getContext();
57
		$templatePaths = \TestHelperJadm::getJsonadmPaths();
58
59
		$this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' );
60
		\Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '', '%^' );
61
	}
62
63
64
	public function testClear()
65
	{
66
		$cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true );
67
68
		$context = \TestHelperJadm::getContext();
69
		$templatePaths = \TestHelperJadm::getJsonadmPaths();
70
71
		$client1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' );
72
		\Aimeos\Admin\JsonAdm\Factory::clear();
73
		$client2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' );
74
75
		\Aimeos\Admin\JsonAdm\Factory::setCache( $cache );
76
77
		$this->assertNotSame( $client1, $client2 );
78
	}
79
80
81 View Code Duplication
	public function testClearSite()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
82
	{
83
		$cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true );
84
85
		$context = \TestHelperJadm::getContext();
86
		$templatePaths = \TestHelperJadm::getJsonadmPaths();
87
88
		$cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' );
89
		$cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' );
90
		\Aimeos\Admin\JsonAdm\Factory::clear( (string) $context );
91
92
		$cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' );
93
		$cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' );
94
95
		\Aimeos\Admin\JsonAdm\Factory::setCache( $cache );
96
97
		$this->assertNotSame( $cntlA1, $cntlA2 );
98
		$this->assertNotSame( $cntlB1, $cntlB2 );
99
	}
100
101
102 View Code Duplication
	public function testClearSpecific()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
103
	{
104
		$cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true );
105
106
		$context = \TestHelperJadm::getContext();
107
		$templatePaths = \TestHelperJadm::getJsonadmPaths();
108
109
		$cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' );
110
		$cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' );
111
112
		\Aimeos\Admin\JsonAdm\Factory::clear( (string) $context, 'order' );
113
114
		$cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' );
115
		$cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' );
116
117
		\Aimeos\Admin\JsonAdm\Factory::setCache( $cache );
118
119
		$this->assertNotSame( $cntlA1, $cntlA2 );
120
		$this->assertSame( $cntlB1, $cntlB2 );
121
	}
122
123
}