Completed
Push — master ( 6a7433...48eba7 )
by Aimeos
02:24
created

TraitsTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
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), 2015-2017
6
 */
7
8
9
namespace Aimeos\Controller\Common\Product\Import\Csv;
10
11
12
class TraitsTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $object;
15
16
17
	protected function setUp()
18
	{
19
		\Aimeos\MShop\Factory::setCache( true );
20
21
		$context = \TestHelperCntl::getContext();
22
		$aimeos = \TestHelperCntl::getAimeos();
23
24
		$this->object = new TestAbstract( $context, $aimeos );
0 ignored issues
show
Unused Code introduced by
The call to TestAbstract::__construct() has too many arguments starting with $context.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
25
	}
26
27
28
	protected function tearDown()
29
	{
30
		\Aimeos\MShop\Factory::setCache( false );
31
		\Aimeos\MShop\Factory::clear();
32
	}
33
34
35
	public function testGetCache()
36
	{
37
		$cache = $this->object->getCachePublic( 'attribute' );
38
39
		$this->assertInstanceOf( '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\Iface', $cache );
40
	}
41
42
43
	public function testGetCacheInvalidType()
44
	{
45
		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
46
		$this->object->getCachePublic( '$' );
47
	}
48
49
50
	public function testGetCacheInvalidClass()
51
	{
52
		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
53
		$this->object->getCachePublic( 'unknown' );
54
	}
55
56
57
	public function testGetCacheInvalidInterface()
58
	{
59
		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
60
		$this->object->getCachePublic( 'attribute', 'unknown' );
61
	}
62
63
64
	public function testGetProcessors()
65
	{
66
		$processor = $this->object->getProcessorsPublic( array( 'attribute' => [] ) );
67
68
		$this->assertInstanceOf( '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\Iface', $processor );
69
	}
70
71
72
	public function testGetProcessorsInvalidType()
73
	{
74
		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
75
		$this->object->getProcessorsPublic( array( '$' => [] ) );
76
	}
77
78
79
	public function testGetProcessorsInvalidClass()
80
	{
81
		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
82
		$this->object->getProcessorsPublic( array( 'unknown' => [] ) );
83
	}
84
85
86
	public function testGetProcessorsInvalidInterface()
87
	{
88
		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
89
		$this->object->getProcessorsPublic( array( 'unknown' => [] ) );
90
	}
91
92
93
	public function testGetTypeId()
94
	{
95
		$typeid = $this->object->getTypeIdPublic( 'attribute/type', 'product', 'color' );
96
97
		$this->assertNotEquals( null, $typeid );
98
	}
99
100
101
	public function testGetTypeIdUnknown()
102
	{
103
		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
104
		$this->object->getTypeIdPublic( 'attribute/type', 'product', 'unknown' );
105
	}
106
}
107
108
109
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...
110
{
111
	use \Aimeos\Controller\Common\Product\Import\Csv\Traits;
112
113
	public function getContext()
114
	{
115
		return \TestHelperCntl::getContext();
116
	}
117
118
	public function getCachePublic( $type, $name = null )
119
	{
120
		return $this->getCache( $type, $name );
121
	}
122
123
124
	public function getProcessorsPublic( array $mappings )
125
	{
126
		return $this->getProcessors( $mappings );
127
	}
128
129
130
	public function getTypeIdPublic( $path, $domain, $code )
131
	{
132
		return $this->getTypeId( $path, $domain, $code );
133
	}
134
}
135
136
137
class TestInvalid
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...
138
{
139
}
140