Completed
Push — master ( f157ac...a775dd )
by Aimeos
03:15
created

BaseTest::testCreateClientBase()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
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 testAddDecorators()
54
	{
55
		$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' );
56
57
		$result = \Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $this->context, $client,
58
			array(), array( 'Cache' ), '\\Aimeos\\Admin\\JQAdm\\Common\\Decorator\\' );
59
60
		$this->assertInstanceOf( '\Aimeos\Admin\JQAdm\Iface', $result );
61
	}
62
63
64
	public function testAddDecoratorsInvalidName()
65
	{
66
		$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' );
67
68
		$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...
69
		\Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $this->context, $client, array(),
70
			array( '$' ), 'Test' );
71
	}
72
73
74
	public function testAddDecoratorsInvalidClass()
75
	{
76
		$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' );
77
78
		$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...
79
		\Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $this->context, $client, array(),
80
			array( 'Test' ), 'TestDecorator' );
81
	}
82
83
84
	public function testAddDecoratorsInvalidInterface()
85
	{
86
		$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' );
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\Common\Factory\TestAbstract::addDecoratorsPublic( $this->context, $client, array(),
90
			array( 'Test' ), '\\Aimeos\\Admin\\JQAdm\\Common\\Decorator\\' );
91
	}
92
93
94
	public function testAddClientDecoratorsExcludes()
95
	{
96
		$this->context->getConfig()->set( 'admin/jqadm/decorators/excludes', array( 'TestDecorator' ) );
97
		$this->context->getConfig()->set( 'admin/jqadm/common/decorators/default', array( 'TestDecorator' ) );
98
99
		$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...
100
		\Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' );
101
	}
102
103
104
	public function testAddClientDecoratorsEmptyPath()
105
	{
106
		$client = \Aimeos\Admin\JQAdm\Product\Factory::createClient( $this->context, array(), 'Standard' );
107
108
		$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...
109
		\Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::addClientDecoratorsPublic( $this->context, $client, array(), '' );
110
	}
111
112
113
	public function testCreateClientBase()
114
	{
115
		$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...
116
		\Aimeos\Admin\JQAdm\Common\Factory\TestAbstract::createClientBasePublic( $this->context, 'Test', 'Test', array() );
117
	}
118
}
119
120
121
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...
122
	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...
123
{
124
	/**
125
	 * @param string $classprefix
126
	 * @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...
127
	 */
128
	public static function addDecoratorsPublic( \Aimeos\MShop\Context\Item\Iface $context,
129
		\Aimeos\Admin\JQAdm\Iface $client, $templatePaths, array $decorators, $classprefix )
130
	{
131
		return self::addDecorators( $context, $client, $templatePaths, $decorators, $classprefix );
132
	}
133
134
	public static function addClientDecoratorsPublic( \Aimeos\MShop\Context\Item\Iface $context,
135
		\Aimeos\Admin\JQAdm\Iface $client, $templatePaths, $path )
136
	{
137
		return self::addClientDecorators( $context, $client, $templatePaths, $path );
138
	}
139
140
	public static function createClientBasePublic( \Aimeos\MShop\Context\Item\Iface $context,
141
		$classname, $interface, $templatePath )
142
	{
143
		return self::createClientBase( $context, $classname, $interface, $templatePath );
144
	}
145
}
146
147
148
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...
149
{
150
}
151