Completed
Push — master ( 984043...a9b00f )
by Aimeos
02:00
created

BaseTest::testGetCacheInvalidInterface()   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-2018
6
 */
7
8
9
namespace Aimeos\Controller\Common\Product\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 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
94
class TestAbstract
95
	extends \Aimeos\Controller\Common\Product\Import\Csv\Base
96
{
97
	public function getContext()
98
	{
99
		return \TestHelperCntl::getContext();
100
	}
101
102
	public function getCachePublic( $type, $name = null )
103
	{
104
		return $this->getCache( $type, $name );
105
	}
106
107
108
	public function getProcessorsPublic( array $mappings )
109
	{
110
		return $this->getProcessors( $mappings );
111
	}
112
}
113
114
115
class TestInvalid
116
{
117
}
118