Completed
Push — master ( 2e10c1...bb3077 )
by Aimeos
02:17
created

BaseTest::testGetCacheInvalidClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
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), 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
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\Controller\Common\Catalog\Import\Csv\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
	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
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...
117
{
118
}
119