|
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 ); |
|
|
|
|
|
|
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 |
|
|
|
|
|
|
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 |
|
|
|
|
|
|
138
|
|
|
{ |
|
139
|
|
|
} |
|
140
|
|
|
|
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
@ignorePhpDoc annotation to the duplicate definition and it will be ignored.