Completed
Push — master ( b98343...f157ac )
by Aimeos
03:37
created

TestAbstract   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 19
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addDecoratorsPublic() 0 5 1
A addClientDecoratorsPublic() 0 5 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2016
6
 */
7
8
9
namespace Aimeos\Admin\JQAdm\Common\Factory;
10
11
12
class BaseTest extends \PHPUnit_Framework_TestCase
13
{
14
	private $context;
15
16
17
	protected function setUp()
18
	{
19
		$this->context = \TestHelperJqadm::getContext();
20
		$this->context->setView( \TestHelperJqadm::getView() );
21
22
		$config = $this->context->getConfig();
23
		$config->set( 'admin/jqadm/common/decorators/default', array() );
24
		$config->set( 'admin/jqadm/decorators/global', array() );
25
		$config->set( 'admin/jqadm/decorators/local', array() );
26
27
	}
28
29
30
	public function testInjectClient()
31
	{
32
		$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' );
33
		\Aimeos\Admin\JQAdm\Product\Factory::injectClient( '\\Aimeos\\Admin\\JQAdm\\Product\\Standard', $client );
34
35
		$iClient = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' );
36
37
		$this->assertSame( $client, $iClient );
38
	}
39
40
41
	public function testInjectClientReset()
42
	{
43
		$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' );
44
		\Aimeos\Admin\JQAdm\Product\Factory::injectClient( '\\Aimeos\\Admin\\JQAdm\\Product\\Standard', $client );
45
		\Aimeos\Admin\JQAdm\Product\Factory::injectClient( '\\Aimeos\\Admin\\JQAdm\\Product\\Standard', null );
46
47
		$new = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' );
48
49
		$this->assertNotSame( $client, $new );
50
	}
51
52
53
	public function testAddDecoratorsInvalidName()
54
	{
55
		$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' );
56
57
		$this->setExpectedException( '\\Aimeos\\Admin\\JQAdm\\Exception' );
1 ignored issue
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
58
		\Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $this->context, $client, array(),
59
			array( '$' ), 'Test' );
60
	}
61
62
63
	public function testAddDecoratorsInvalidClass()
64
	{
65
		$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' );
66
67
		$this->setExpectedException( '\\Aimeos\\Admin\\JQAdm\\Exception' );
1 ignored issue
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
68
		\Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $this->context, $client, array(),
69
			array( 'Test' ), 'TestDecorator' );
70
	}
71
72
73
	public function testAddDecoratorsInvalidInterface()
74
	{
75
		$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' );
76
77
		$this->setExpectedException( '\\Aimeos\\Admin\\JQAdm\\Exception' );
1 ignored issue
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
78
		\Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $this->context, $client, array(),
79
			array( 'Test' ), '\\Aimeos\\Admin\\JQAdm\\Common\\Decorator\\' );
80
	}
81
82
83
	public function testAddClientDecoratorsExcludes()
84
	{
85
		$this->context->getConfig()->set( 'admin/jqadm/decorators/excludes', array( 'TestDecorator' ) );
86
		$this->context->getConfig()->set( 'admin/jqadm/common/decorators/default', array( 'TestDecorator' ) );
87
88
		$this->setExpectedException( '\\Aimeos\\Admin\\JQAdm\\Exception' );
1 ignored issue
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
89
		\Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' );
90
	}
91
}
92
93
94
class TestAbstract
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
95
	extends \Aimeos\Admin\JQAdm\Common\Factory\Base
0 ignored issues
show
Coding Style introduced by
The extends keyword must be on the same line as the class name
Loading history...
96
{
97
	/**
98
	 * @param string $classprefix
99
	 * @param string $path
0 ignored issues
show
Bug introduced by
There is no parameter named $path. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
100
	 */
101
	public static function addDecoratorsPublic( \Aimeos\MShop\Context\Item\Iface $context,
102
		\Aimeos\Admin\JQAdm\Iface $client, $templatePaths, array $decorators, $classprefix )
103
	{
104
		self::addDecorators( $context, $client, $templatePaths, $decorators, $classprefix );
105
	}
106
107
	public static function addClientDecoratorsPublic( \Aimeos\MShop\Context\Item\Iface $context,
108
		\Aimeos\Admin\JQAdm\Iface $client, $templatePaths, $path )
109
	{
110
		self::addClientDecorators( $context, $client, $templatePaths, $path );
111
	}
112
}
113
114
115
class TestDecorator
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
116
{
117
}
118