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
|
|
|
|