Passed
Push — master ( 108d2e...42466b )
by Aimeos
24:07 queued 21:25
created

TestAbstract::context()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015-2021
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() : void
18
	{
19
		\Aimeos\MShop::cache( true );
20
21
		$context = \TestHelperCntl::context();
22
		$aimeos = \TestHelperCntl::getAimeos();
23
24
		$this->object = new TestAbstract( $context, $aimeos );
25
	}
26
27
28
	protected function tearDown() : void
29
	{
30
		\Aimeos\MShop::cache( false );
31
	}
32
33
34
	public function testGetCache()
35
	{
36
		$cache = $this->object->getCachePublic( 'attribute' );
37
38
		$this->assertInstanceOf( '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\Iface', $cache );
39
	}
40
41
42
	public function testGetCacheInvalidType()
43
	{
44
		$this->expectException( '\\Aimeos\\Controller\\Common\\Exception' );
45
		$this->object->getCachePublic( '$' );
46
	}
47
48
49
	public function testGetCacheInvalidClass()
50
	{
51
		$this->expectException( '\\Aimeos\\Controller\\Common\\Exception' );
52
		$this->object->getCachePublic( 'unknown' );
53
	}
54
55
56
	public function testGetCacheInvalidInterface()
57
	{
58
		$this->expectException( '\\Aimeos\\Controller\\Common\\Exception' );
59
		$this->object->getCachePublic( 'attribute', 'unknown' );
60
	}
61
62
63
	public function testGetProcessors()
64
	{
65
		$processor = $this->object->getProcessorsPublic( array( 'attribute' => [] ) );
66
67
		$this->assertInstanceOf( '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\Iface', $processor );
68
	}
69
70
71
	public function testGetProcessorsInvalidType()
72
	{
73
		$this->expectException( '\\Aimeos\\Controller\\Common\\Exception' );
74
		$this->object->getProcessorsPublic( array( '$' => [] ) );
75
	}
76
77
78
	public function testGetProcessorsInvalidClass()
79
	{
80
		$this->expectException( '\\Aimeos\\Controller\\Common\\Exception' );
81
		$this->object->getProcessorsPublic( array( 'unknown' => [] ) );
82
	}
83
84
85
	public function testGetProcessorsInvalidInterface()
86
	{
87
		$this->expectException( '\\Aimeos\\Controller\\Common\\Exception' );
88
		$this->object->getProcessorsPublic( array( 'unknown' => [] ) );
89
	}
90
}
91
92
93
class TestAbstract
94
	extends \Aimeos\Controller\Common\Product\Import\Csv\Base
95
{
96
	public function context() : \Aimeos\MShop\Context\Item\Iface
97
	{
98
		return \TestHelperCntl::context();
99
	}
100
101
	public function getCachePublic( $type, $name = null )
102
	{
103
		return $this->getCache( $type, $name );
104
	}
105
106
107
	public function getProcessorsPublic( array $mappings )
108
	{
109
		return $this->getProcessors( $mappings );
110
	}
111
}
112
113
114
class TestInvalid
115
{
116
}
117