Passed
Push — master ( 9305da...612cc2 )
by Aimeos
24:47 queued 09:42
created

StandardTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015-2023
6
 */
7
8
9
namespace Aimeos\Controller\Jobs\Group\Import\Xml;
10
11
12
class StandardTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $object;
15
	private $context;
16
	private $aimeos;
17
18
19
	public static function setUpBeforeClass() : void
20
	{
21
		$context = \TestHelper::context();
22
23
		$fs = $context->fs( 'fs-import' );
24
		$fs->has( 'group' ) ?: $fs->mkdir( 'group' );
25
		$fs->writef( 'group/group_1.xml', __DIR__ . '/_testfiles/group_1.xml' );
26
		$fs->writef( 'group/group_2.xml', __DIR__ . '/_testfiles/group_2.xml' );
27
	}
28
29
30
	protected function setUp() : void
31
	{
32
		\Aimeos\MShop::cache( true );
33
34
		$this->context = \TestHelper::context();
35
		$this->aimeos = \TestHelper::getAimeos();
36
37
		$this->object = new \Aimeos\Controller\Jobs\Group\Import\Xml\Standard( $this->context, $this->aimeos );
38
	}
39
40
41
	protected function tearDown() : void
42
	{
43
		\Aimeos\MShop::cache( false );
44
		unset( $this->object, $this->context, $this->aimeos );
45
	}
46
47
48
	public function testGetName()
49
	{
50
		$this->assertEquals( 'Groups import XML', $this->object->getName() );
51
	}
52
53
54
	public function testGetDescription()
55
	{
56
		$text = 'Imports new and updates existing groups from XML files';
57
		$this->assertEquals( $text, $this->object->getDescription() );
58
	}
59
60
61
	public function testRun()
62
	{
63
		$this->object->run();
64
65
		$manager = \Aimeos\MShop::create( $this->context, 'group' );
66
		$item = $manager->find( 'test' );
67
		$manager->delete( $item );
68
69
		$this->assertEquals( 'Test group', $item->getLabel() );
70
		$this->assertEquals( 'test', $item->getCode() );
71
	}
72
}
73