|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2019 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
namespace Aimeos\Controller\Common\Common\Import\Xml\Processor\Property; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
|
|
|
|
|
|
13
|
|
|
{ |
|
14
|
|
|
private $context; |
|
15
|
|
|
private $object; |
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
protected function setUp() |
|
19
|
|
|
{ |
|
20
|
|
|
$this->context = \TestHelperCntl::getContext(); |
|
21
|
|
|
$this->object = new \Aimeos\Controller\Common\Common\Import\Xml\Processor\Property\Standard( $this->context ); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
protected function tearDown() |
|
26
|
|
|
{ |
|
27
|
|
|
unset( $this->object, $this->context ); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
public function testProcess() |
|
32
|
|
|
{ |
|
33
|
|
|
$dom = new \DOMDocument(); |
|
34
|
|
|
$product = \Aimeos\MShop::create( $this->context, 'product' )->createItem(); |
|
35
|
|
|
|
|
36
|
|
|
$dom->loadXML( '<?xml version="1.0" encoding="UTF-8" standalone="no" ?> |
|
37
|
|
|
<property> |
|
38
|
|
|
<propertyitem> |
|
39
|
|
|
<product.property.type><![CDATA[package-weight]]></product.property.type> |
|
40
|
|
|
<product.property.languageid><![CDATA[de]]></product.property.languageid> |
|
41
|
|
|
<product.property.value><![CDATA[3.00 kg]]></product.property.value> |
|
42
|
|
|
</propertyitem> |
|
43
|
|
|
<propertyitem> |
|
44
|
|
|
<product.property.type><![CDATA[package-width]]></product.property.type> |
|
45
|
|
|
<product.property.languageid><![CDATA[]]></product.property.languageid> |
|
46
|
|
|
<product.property.value><![CDATA[50]]></product.property.value> |
|
47
|
|
|
</propertyitem> |
|
48
|
|
|
</property>' ); |
|
49
|
|
|
|
|
50
|
|
|
$product = $this->object->process( $product, $dom->firstChild ); |
|
51
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
$pos = 0; |
|
54
|
|
|
$expected = [['package-weight', '3.00 kg', 'de'], ['package-width', '50', null]]; |
|
55
|
|
|
|
|
56
|
|
|
$items = $product->getPropertyItems(); |
|
57
|
|
|
$this->assertEquals( 2, count( $items ) ); |
|
58
|
|
|
|
|
59
|
|
|
foreach( $items as $item ) |
|
60
|
|
|
{ |
|
61
|
|
|
$this->assertEquals( $expected[$pos][0], $item->getType() ); |
|
62
|
|
|
$this->assertEquals( $expected[$pos][1], $item->getValue() ); |
|
63
|
|
|
$this->assertEquals( $expected[$pos][2], $item->getLanguageId() ); |
|
64
|
|
|
$pos++; |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
|
|
69
|
|
|
public function testProcessUpdate() |
|
70
|
|
|
{ |
|
71
|
|
|
$dom = new \DOMDocument(); |
|
72
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'product/property' ); |
|
73
|
|
|
$product = \Aimeos\MShop::create( $this->context, 'product' )->createItem(); |
|
74
|
|
|
|
|
75
|
|
|
$product->addPropertyItem( $manager->createItem()->setType( 'package-weight' ) |
|
76
|
|
|
->setLanguageId( 'de' )->setValue( '3.00 kg' )->setId( 1 ) ); |
|
77
|
|
|
$product->addPropertyItem( $manager->createItem()->setType( 'package-width' ) |
|
78
|
|
|
->setLanguageId( '' )->setValue( '50' )->setId( 2 ) ); |
|
79
|
|
|
|
|
80
|
|
|
$dom->loadXML( '<?xml version="1.0" encoding="UTF-8" standalone="no" ?> |
|
81
|
|
|
<property> |
|
82
|
|
|
<propertyitem> |
|
83
|
|
|
<product.property.type><![CDATA[package-width]]></product.property.type> |
|
84
|
|
|
<product.property.languageid><![CDATA[]]></product.property.languageid> |
|
85
|
|
|
<product.property.value><![CDATA[50]]></product.property.value> |
|
86
|
|
|
</propertyitem> |
|
87
|
|
|
<propertyitem> |
|
88
|
|
|
<product.property.type><![CDATA[package-weight]]></product.property.type> |
|
89
|
|
|
<product.property.languageid><![CDATA[de]]></product.property.languageid> |
|
90
|
|
|
<product.property.value><![CDATA[3.00 kg]]></product.property.value> |
|
91
|
|
|
</propertyitem> |
|
92
|
|
|
</property>' ); |
|
93
|
|
|
|
|
94
|
|
|
$product = $this->object->process( $product, $dom->firstChild ); |
|
95
|
|
|
|
|
96
|
|
|
|
|
97
|
|
|
$pos = 0; |
|
98
|
|
|
$expected = [['package-weight', '3.00 kg', 'de'], ['package-width', '50', null]]; |
|
99
|
|
|
|
|
100
|
|
|
$items = $product->getPropertyItems(); |
|
101
|
|
|
$this->assertEquals( 2, count( $items ) ); |
|
102
|
|
|
|
|
103
|
|
|
foreach( $items as $item ) |
|
104
|
|
|
{ |
|
105
|
|
|
$this->assertEquals( $expected[$pos][0], $item->getType() ); |
|
106
|
|
|
$this->assertEquals( $expected[$pos][1], $item->getValue() ); |
|
107
|
|
|
$this->assertEquals( $expected[$pos][2], $item->getLanguageId() ); |
|
108
|
|
|
$pos++; |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
|
|
113
|
|
|
public function testProcessDelete() |
|
114
|
|
|
{ |
|
115
|
|
|
$dom = new \DOMDocument(); |
|
116
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'product/property' ); |
|
117
|
|
|
$product = \Aimeos\MShop::create( $this->context, 'product' )->createItem(); |
|
118
|
|
|
|
|
119
|
|
|
$product->addPropertyItem( $manager->createItem()->setType( 'package-weight' ) |
|
120
|
|
|
->setLanguageId( 'de' )->setValue( '3.00 kg' )->setId( 1 ) ); |
|
121
|
|
|
$product->addPropertyItem( $manager->createItem()->setType( 'package-width' ) |
|
122
|
|
|
->setLanguageId( '' )->setValue( '50' )->setId( 2 ) ); |
|
123
|
|
|
|
|
124
|
|
|
$dom->loadXML( '<?xml version="1.0" encoding="UTF-8" standalone="no" ?> |
|
125
|
|
|
<property> |
|
126
|
|
|
<propertyitem> |
|
127
|
|
|
<product.property.type><![CDATA[package-width]]></product.property.type> |
|
128
|
|
|
<product.property.languageid><![CDATA[]]></product.property.languageid> |
|
129
|
|
|
<product.property.value><![CDATA[50]]></product.property.value> |
|
130
|
|
|
</propertyitem> |
|
131
|
|
|
</property>' ); |
|
132
|
|
|
|
|
133
|
|
|
$product = $this->object->process( $product, $dom->firstChild ); |
|
134
|
|
|
|
|
135
|
|
|
|
|
136
|
|
|
$pos = 0; |
|
137
|
|
|
$expected = [['package-width', '50', null]]; |
|
138
|
|
|
|
|
139
|
|
|
$items = $product->getPropertyItems(); |
|
140
|
|
|
$this->assertEquals( 1, count( $items ) ); |
|
141
|
|
|
|
|
142
|
|
|
foreach( $items as $item ) |
|
143
|
|
|
{ |
|
144
|
|
|
$this->assertEquals( $expected[$pos][0], $item->getType() ); |
|
145
|
|
|
$this->assertEquals( $expected[$pos][1], $item->getValue() ); |
|
146
|
|
|
$this->assertEquals( $expected[$pos][2], $item->getLanguageId() ); |
|
147
|
|
|
$pos++; |
|
148
|
|
|
} |
|
149
|
|
|
} |
|
150
|
|
|
} |
|
151
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths