|
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\Catalog\Import\Csv; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class BaseTest 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 testGetCacheInvalidType() |
|
36
|
|
|
{ |
|
37
|
|
|
$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
38
|
|
|
$this->object->getCachePublic( '$' ); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
public function testGetCacheInvalidClass() |
|
43
|
|
|
{ |
|
44
|
|
|
$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
45
|
|
|
$this->object->getCachePublic( 'unknown' ); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
|
|
49
|
|
|
public function testGetProcessors() |
|
50
|
|
|
{ |
|
51
|
|
|
$processor = $this->object->getProcessorsPublic( array( 'media' => [] ) ); |
|
52
|
|
|
|
|
53
|
|
|
$this->assertInstanceOf( '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\Iface', $processor ); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
public function testGetProcessorsInvalidType() |
|
58
|
|
|
{ |
|
59
|
|
|
$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
60
|
|
|
$this->object->getProcessorsPublic( array( '$' => [] ) ); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
public function testGetProcessorsInvalidClass() |
|
65
|
|
|
{ |
|
66
|
|
|
$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
67
|
|
|
$this->object->getProcessorsPublic( array( 'unknown' => [] ) ); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
|
|
71
|
|
|
public function testGetProcessorsInvalidInterface() |
|
72
|
|
|
{ |
|
73
|
|
|
$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
74
|
|
|
$this->object->getProcessorsPublic( array( 'unknown' => [] ) ); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
|
|
78
|
|
|
public function testGetTypeId() |
|
79
|
|
|
{ |
|
80
|
|
|
$typeid = $this->object->getTypeIdPublic( 'text/type', 'catalog', 'name' ); |
|
81
|
|
|
|
|
82
|
|
|
$this->assertNotEquals( null, $typeid ); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
|
|
86
|
|
|
public function testGetTypeIdUnknown() |
|
87
|
|
|
{ |
|
88
|
|
|
$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
89
|
|
|
$this->object->getTypeIdPublic( 'text/type', 'catalog', 'unknown' ); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
|
|
94
|
|
|
class TestAbstract |
|
|
|
|
|
|
95
|
|
|
extends \Aimeos\Controller\Common\Catalog\Import\Csv\Base |
|
|
|
|
|
|
96
|
|
|
{ |
|
97
|
|
|
public function getCachePublic( $type, $name = null ) |
|
98
|
|
|
{ |
|
99
|
|
|
return $this->getCache( $type, $name ); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
|
|
103
|
|
|
public function getProcessorsPublic( array $mappings ) |
|
104
|
|
|
{ |
|
105
|
|
|
return $this->getProcessors( $mappings ); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
|
|
109
|
|
|
public function getTypeIdPublic( $path, $domain, $code ) |
|
110
|
|
|
{ |
|
111
|
|
|
return $this->getTypeId( $path, $domain, $code ); |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
|
|
116
|
|
|
class TestInvalid |
|
|
|
|
|
|
117
|
|
|
{ |
|
118
|
|
|
} |
|
119
|
|
|
|
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.