1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2019-2021 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\Controller\Common\Common\Import\Xml\Processor\Lists\Catalog; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
13
|
|
|
{ |
14
|
|
|
private $context; |
15
|
|
|
private $object; |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
protected function setUp() : void |
19
|
|
|
{ |
20
|
|
|
$this->context = \TestHelperCntl::context(); |
21
|
|
|
$this->object = new \Aimeos\Controller\Common\Common\Import\Xml\Processor\Lists\Catalog\Standard( $this->context ); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
protected function tearDown() : void |
26
|
|
|
{ |
27
|
|
|
unset( $this->object, $this->context ); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
|
31
|
|
|
public function testProcess() |
32
|
|
|
{ |
33
|
|
|
$dom = new \DOMDocument(); |
34
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'product' ); |
35
|
|
|
$catManager = \Aimeos\MShop::create( $this->context, 'catalog' ); |
36
|
|
|
|
37
|
|
|
$refId1 = $catManager->find( 'cafe' )->getId(); |
38
|
|
|
$refId2 = $catManager->find( 'tea' )->getId(); |
39
|
|
|
|
40
|
|
|
$dom->loadXML( '<?xml version="1.0" encoding="UTF-8" standalone="no" ?> |
41
|
|
|
<catalog> |
42
|
|
|
<catalogitem ref="cafe" lists.type="default" /> |
43
|
|
|
<catalogitem ref="tea" lists.type="test" /> |
44
|
|
|
</catalog>' ); |
45
|
|
|
|
46
|
|
|
$product = $this->object->process( $manager->create(), $dom->firstChild ); |
47
|
|
|
|
48
|
|
|
$this->assertEquals( 2, count( $product->getListItems() ) ); |
49
|
|
|
$this->assertNotNull( $product->getListItem( 'catalog', 'default', $refId1 ) ); |
50
|
|
|
$this->assertNotNull( $product->getListItem( 'catalog', 'test', $refId2 ) ); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
|
54
|
|
|
public function testProcessUpdate() |
55
|
|
|
{ |
56
|
|
|
$dom = new \DOMDocument(); |
57
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'product' ); |
58
|
|
|
$catManager = \Aimeos\MShop::create( $this->context, 'catalog' ); |
59
|
|
|
|
60
|
|
|
$product = $manager->create(); |
61
|
|
|
$refId1 = $catManager->find( 'cafe' )->getId(); |
62
|
|
|
$refId2 = $catManager->find( 'tea' )->getId(); |
63
|
|
|
|
64
|
|
|
$product->addListItem( 'catalog', |
65
|
|
|
$manager->createListItem()->setType( 'default' )->setId( 1 )->setRefId( $refId1 ) |
|
|
|
|
66
|
|
|
); |
67
|
|
|
$product->addListItem( 'catalog', |
68
|
|
|
$manager->createListItem()->setType( 'test' )->setId( 2 )->setRefId( $refId2 ) |
69
|
|
|
); |
70
|
|
|
|
71
|
|
|
$dom->loadXML( '<?xml version="1.0" encoding="UTF-8" standalone="no" ?> |
72
|
|
|
<catalog> |
73
|
|
|
<catalogitem ref="tea" lists.type="test" /> |
74
|
|
|
<catalogitem ref="cafe" lists.type="default" /> |
75
|
|
|
</catalog>' ); |
76
|
|
|
|
77
|
|
|
$product = $this->object->process( $product, $dom->firstChild ); |
78
|
|
|
|
79
|
|
|
$this->assertEquals( 2, count( $product->getListItems() ) ); |
80
|
|
|
$this->assertNotNull( $product->getListItem( 'catalog', 'test', $refId2 ) ); |
81
|
|
|
$this->assertNotNull( $product->getListItem( 'catalog', 'default', $refId1 ) ); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
|
85
|
|
|
public function testProcessDelete() |
86
|
|
|
{ |
87
|
|
|
$dom = new \DOMDocument(); |
88
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'product' ); |
89
|
|
|
$catManager = \Aimeos\MShop::create( $this->context, 'catalog' ); |
90
|
|
|
|
91
|
|
|
$product = $manager->create(); |
92
|
|
|
$refId1 = $catManager->find( 'cafe' )->getId(); |
93
|
|
|
$refId2 = $catManager->find( 'tea' )->getId(); |
94
|
|
|
|
95
|
|
|
$product->addListItem( 'catalog', |
96
|
|
|
$manager->createListItem()->setType( 'default' )->setId( 1 )->setRefId( $refId1 ) |
97
|
|
|
); |
98
|
|
|
$product->addListItem( 'catalog', |
99
|
|
|
$manager->createListItem()->setType( 'test' )->setId( 2 )->setRefId( $refId2 ) |
100
|
|
|
); |
101
|
|
|
|
102
|
|
|
$dom->loadXML( '<?xml version="1.0" encoding="UTF-8" standalone="no" ?> |
103
|
|
|
<catalog> |
104
|
|
|
<catalogitem ref="tea" lists.type="default" /> |
105
|
|
|
</catalog>' ); |
106
|
|
|
|
107
|
|
|
$product = $this->object->process( $product, $dom->firstChild ); |
108
|
|
|
|
109
|
|
|
$this->assertEquals( 1, count( $product->getListItems() ) ); |
110
|
|
|
$this->assertNotNull( $product->getListItem( 'catalog', 'default', $refId2 ) ); |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.