Passed
Push — master ( 29f10b...e68c42 )
by Aimeos
05:07
created

StandardTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 54
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 11 1
A tearDown() 0 4 1
A testGetName() 0 3 1
A testRun() 0 13 1
A testGetDescription() 0 4 1
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\Jobs\Attribute\Import\Xml;
10
11
12
class StandardTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $object;
15
	private $context;
16
	private $aimeos;
17
18
19
	protected function setUp()
20
	{
21
		\Aimeos\MShop::cache( true );
22
23
		$this->context = \TestHelperJobs::getContext();
24
		$this->aimeos = \TestHelperJobs::getAimeos();
25
26
		$config = $this->context->getConfig();
27
		$config->set( 'controller/jobs/attribute/import/xml/location', __DIR__ . '/_testfiles' );
28
29
		$this->object = new \Aimeos\Controller\Jobs\Attribute\Import\Xml\Standard( $this->context, $this->aimeos );
30
	}
31
32
33
	protected function tearDown()
34
	{
35
		\Aimeos\MShop::cache( false );
36
		unset( $this->object, $this->context, $this->aimeos );
37
	}
38
39
40
	public function testGetName()
41
	{
42
		$this->assertEquals( 'Attribute import XML', $this->object->getName() );
43
	}
44
45
46
	public function testGetDescription()
47
	{
48
		$text = 'Imports new and updates existing attributes from XML files';
49
		$this->assertEquals( $text, $this->object->getDescription() );
50
	}
51
52
53
	public function testRun()
54
	{
55
		$this->object->run();
56
57
		$manager = \Aimeos\MShop::create( $this->context, 'attribute' );
58
		$item = $manager->findItem( 'unittest-xml', ['attribute/property', 'media', 'price', 'text'], 'product', 'color' );
59
		$manager->deleteItem( $item->getId() );
60
61
		$this->assertEquals( 'Test attribute 2', $item->getLabel() );
62
		$this->assertEquals( 1, count( $item->getRefItems( 'media' ) ) );
63
		$this->assertEquals( 1, count( $item->getRefItems( 'price' ) ) );
64
		$this->assertEquals( 1, count( $item->getRefItems( 'text' ) ) );
65
		$this->assertEquals( 1, count( $item->getPropertyItems() ) );
66
	}
67
}
68