Passed
Push — master ( 94c6b8...b4b452 )
by Aimeos
05:00
created

OrderAddTestData   B

Complexity

Total Complexity 52

Size/Duplication

Total Lines 516
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 240
dl 0
loc 516
rs 7.44
c 0
b 0
f 0
wmc 52

12 Methods

Rating   Name   Duplication   Size   Complexity  
A getPreDependencies() 0 3 1
A addOrderBaseServiceData() 0 52 5
A getCustomerIds() 0 17 3
A addOrderBaseAddressData() 0 37 5
A getProductItems() 0 21 4
B addOrderBaseProductData() 0 65 7
B addOrderBaseProductAttributeData() 0 41 8
A addOrderBaseData() 0 32 2
A addOrderBaseServiceAttributeData() 0 24 4
A migrate() 0 38 4
A getServiceIds() 0 21 4
A addOrderData() 0 44 5

How to fix   Complexity   

Complex Class

Complex classes like OrderAddTestData often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use OrderAddTestData, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2012
6
 * @copyright Aimeos (aimeos.org), 2015-2018
7
 */
8
9
10
namespace Aimeos\MW\Setup\Task;
11
12
13
/**
14
 * Adds order test data.
15
 */
16
class OrderAddTestData extends \Aimeos\MW\Setup\Task\Base
17
{
18
	/**
19
	 * Returns the list of task names which this task depends on.
20
	 *
21
	 * @return string[] List of task names
22
	 */
23
	public function getPreDependencies()
24
	{
25
		return ['CustomerAddTestData', 'ProductAddTestData', 'PluginAddTestData', 'ServiceAddTestData'];
26
	}
27
28
29
	/**
30
	 * Adds order test data.
31
	 */
32
	public function migrate()
33
	{
34
		\Aimeos\MW\Common\Base::checkClass( \Aimeos\MShop\Context\Item\Iface::class, $this->additional );
35
36
		$this->msg( 'Adding order test data', 0 );
37
		$this->additional->setEditor( 'core:unittest' );
38
39
		$localeManager = \Aimeos\MShop\Locale\Manager\Factory::create( $this->additional, 'Standard' );
40
		$orderManager = \Aimeos\MShop\Order\Manager\Factory::create( $this->additional, 'Standard' );
41
		$orderBaseManager = $orderManager->getSubManager( 'base' );
42
43
		$search = $orderBaseManager->createSearch();
44
		$search->setConditions( $search->compare( '==', 'order.base.sitecode', array( 'unittest', 'unit' ) ) );
45
46
		foreach( $orderBaseManager->searchItems( $search ) as $order ) {
47
			$orderBaseManager->deleteItem( $order->getId() );
48
		}
49
50
51
		$ds = DIRECTORY_SEPARATOR;
52
		$path = __DIR__ . $ds . 'data' . $ds . 'order.php';
53
54
		if( ( $testdata = include( $path ) ) == false ) {
55
			throw new \Aimeos\MShop\Exception( sprintf( 'No file "%1$s" found for order domain', $path ) );
56
		}
57
58
		$bases = $this->addOrderBaseData( $localeManager, $orderBaseManager, $testdata );
59
		$bases['items'] = $this->addOrderBaseProductData( $orderBaseManager, $bases, $testdata );
60
		$bases['items'] = $this->addOrderBaseServiceData( $orderBaseManager, $bases, $testdata );
61
62
		//update order bases (getPrice)
63
		foreach( $bases['items'] as $baseItem ) {
64
			$orderBaseManager->saveItem( $baseItem, false );
65
		}
66
67
		$this->addOrderData( $orderManager, $bases['ids'], $testdata );
68
69
		$this->status( 'done' );
70
	}
71
72
73
	/**
74
	 * Adds the required order base data.
75
	 *
76
	 * @param \Aimeos\MShop\Common\Manager\Iface $localeManager Locale manager
77
	 * @param \Aimeos\MShop\Common\Manager\Iface $orderBaseManager Order base manager
78
	 * @param array $testdata Associative list of key/list pairs
79
	 * @throws \Aimeos\MW\Setup\Exception If no type ID is found
80
	 */
81
	protected function addOrderBaseData( \Aimeos\MShop\Common\Manager\Iface $localeManager,
82
		\Aimeos\MShop\Common\Manager\Iface $orderBaseManager, array $testdata )
83
	{
84
		$bases = [];
85
		$locale = $localeManager->createItem();
86
		$customerIds = $this->getCustomerIds( $testdata );
87
		$orderBaseAddressManager = $orderBaseManager->getSubManager( 'address', 'Standard' );
88
89
		$orderBaseManager->begin();
90
91
		foreach( $testdata['order/base'] as $key => $dataset )
92
		{
93
			$bases['items'][$key] = $orderBaseManager->createItem();
94
			$bases['items'][$key]->setId( null );
95
			$bases['items'][$key]->setComment( $dataset['comment'] );
96
			$bases['items'][$key]->setCustomerId( $customerIds[$dataset['customerid']] );
97
98
			$locale->setId( null );
99
			$locale->setSiteId( $this->additional->getLocale()->getSiteId() );
0 ignored issues
show
Bug introduced by
The method setSiteId() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

99
			$locale->/** @scrutinizer ignore-call */ 
100
            setSiteId( $this->additional->getLocale()->getSiteId() );

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.

Loading history...
100
			$locale->setLanguageId( $dataset['langid'] );
0 ignored issues
show
Bug introduced by
The method setLanguageId() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

100
			$locale->/** @scrutinizer ignore-call */ 
101
            setLanguageId( $dataset['langid'] );

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.

Loading history...
101
			$locale->setCurrencyId( $dataset['currencyid'] );
0 ignored issues
show
Bug introduced by
The method setCurrencyId() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

101
			$locale->/** @scrutinizer ignore-call */ 
102
            setCurrencyId( $dataset['currencyid'] );

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.

Loading history...
102
			$bases['items'][$key]->setLocale( $locale );
103
104
			$orderBaseManager->saveItem( $bases['items'][$key] );
105
			$bases['ids'][$key] = $bases['items'][$key]->getId();
106
		}
107
108
		$this->addOrderBaseAddressData( $orderBaseAddressManager, $bases, $testdata );
109
110
		$orderBaseManager->commit();
111
112
		return $bases;
113
	}
114
115
116
	/**
117
	 * Adds the order address data.
118
	 *
119
	 * @param \Aimeos\MShop\Common\Manager\Iface $manager
120
	 * @param array $testdata
121
	 */
122
	protected function addOrderBaseAddressData( \Aimeos\MShop\Common\Manager\Iface $manager,
123
		array $bases, array $testdata )
124
	{
125
		$orderAddr = $manager->createItem();
126
127
		foreach( $testdata['order/base/address'] as $dataset )
128
		{
129
			if( !isset( $bases['ids'][$dataset['baseid']] ) ) {
130
				throw new \Aimeos\MW\Setup\Exception( sprintf( 'No base ID found for "%1$s"', $dataset['baseid'] ) );
131
			}
132
133
			$orderAddr->setId( null );
134
			$orderAddr->setBaseId( $bases['ids'][$dataset['baseid']] );
0 ignored issues
show
Bug introduced by
The method setBaseId() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

134
			$orderAddr->/** @scrutinizer ignore-call */ 
135
               setBaseId( $bases['ids'][$dataset['baseid']] );

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.

Loading history...
135
			$orderAddr->setAddressId( ( isset( $dataset['addrid'] ) ? $dataset['addrid'] : '' ) );
0 ignored issues
show
Bug introduced by
The method setAddressId() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

135
			$orderAddr->/** @scrutinizer ignore-call */ 
136
               setAddressId( ( isset( $dataset['addrid'] ) ? $dataset['addrid'] : '' ) );

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.

Loading history...
136
			$orderAddr->setType( $dataset['type'] );
137
			$orderAddr->setCompany( $dataset['company'] );
0 ignored issues
show
Bug introduced by
The method setCompany() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

137
			$orderAddr->/** @scrutinizer ignore-call */ 
138
               setCompany( $dataset['company'] );

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.

Loading history...
138
			$orderAddr->setVatID( ( isset( $dataset['vatid'] ) ? $dataset['vatid'] : '' ) );
0 ignored issues
show
Bug introduced by
The method setVatID() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

138
			$orderAddr->/** @scrutinizer ignore-call */ 
139
               setVatID( ( isset( $dataset['vatid'] ) ? $dataset['vatid'] : '' ) );

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.

Loading history...
139
			$orderAddr->setSalutation( $dataset['salutation'] );
0 ignored issues
show
Bug introduced by
The method setSalutation() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

139
			$orderAddr->/** @scrutinizer ignore-call */ 
140
               setSalutation( $dataset['salutation'] );

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.

Loading history...
140
			$orderAddr->setTitle( $dataset['title'] );
0 ignored issues
show
Bug introduced by
The method setTitle() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

140
			$orderAddr->/** @scrutinizer ignore-call */ 
141
               setTitle( $dataset['title'] );

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.

Loading history...
141
			$orderAddr->setFirstname( $dataset['firstname'] );
0 ignored issues
show
Bug introduced by
The method setFirstname() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

141
			$orderAddr->/** @scrutinizer ignore-call */ 
142
               setFirstname( $dataset['firstname'] );

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.

Loading history...
142
			$orderAddr->setLastname( $dataset['lastname'] );
0 ignored issues
show
Bug introduced by
The method setLastname() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

142
			$orderAddr->/** @scrutinizer ignore-call */ 
143
               setLastname( $dataset['lastname'] );

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.

Loading history...
143
			$orderAddr->setAddress1( $dataset['address1'] );
0 ignored issues
show
Bug introduced by
The method setAddress1() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

143
			$orderAddr->/** @scrutinizer ignore-call */ 
144
               setAddress1( $dataset['address1'] );

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.

Loading history...
144
			$orderAddr->setAddress2( $dataset['address2'] );
0 ignored issues
show
Bug introduced by
The method setAddress2() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

144
			$orderAddr->/** @scrutinizer ignore-call */ 
145
               setAddress2( $dataset['address2'] );

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.

Loading history...
145
			$orderAddr->setAddress3( $dataset['address3'] );
0 ignored issues
show
Bug introduced by
The method setAddress3() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

145
			$orderAddr->/** @scrutinizer ignore-call */ 
146
               setAddress3( $dataset['address3'] );

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.

Loading history...
146
			$orderAddr->setPostal( $dataset['postal'] );
0 ignored issues
show
Bug introduced by
The method setPostal() does not exist on Aimeos\MShop\Attribute\Item\Iface. Did you maybe mean setPosition()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

146
			$orderAddr->/** @scrutinizer ignore-call */ 
147
               setPostal( $dataset['postal'] );

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.

Loading history...
147
			$orderAddr->setCity( $dataset['city'] );
0 ignored issues
show
Bug introduced by
The method setCity() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

147
			$orderAddr->/** @scrutinizer ignore-call */ 
148
               setCity( $dataset['city'] );

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.

Loading history...
148
			$orderAddr->setState( $dataset['state'] );
0 ignored issues
show
Bug introduced by
The method setState() does not exist on Aimeos\MShop\Attribute\Item\Iface. Did you maybe mean setStatus()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

148
			$orderAddr->/** @scrutinizer ignore-call */ 
149
               setState( $dataset['state'] );

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.

Loading history...
149
			$orderAddr->setCountryId( $dataset['countryid'] );
0 ignored issues
show
Bug introduced by
The method setCountryId() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

149
			$orderAddr->/** @scrutinizer ignore-call */ 
150
               setCountryId( $dataset['countryid'] );

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.

Loading history...
150
			$orderAddr->setTelephone( $dataset['telephone'] );
0 ignored issues
show
Bug introduced by
The method setTelephone() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

150
			$orderAddr->/** @scrutinizer ignore-call */ 
151
               setTelephone( $dataset['telephone'] );

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.

Loading history...
151
			$orderAddr->setEmail( $dataset['email'] );
0 ignored issues
show
Bug introduced by
The method setEmail() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

151
			$orderAddr->/** @scrutinizer ignore-call */ 
152
               setEmail( $dataset['email'] );

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.

Loading history...
152
			$orderAddr->setTelefax( $dataset['telefax'] );
0 ignored issues
show
Bug introduced by
The method setTelefax() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

152
			$orderAddr->/** @scrutinizer ignore-call */ 
153
               setTelefax( $dataset['telefax'] );

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.

Loading history...
153
			$orderAddr->setWebsite( $dataset['website'] );
0 ignored issues
show
Bug introduced by
The method setWebsite() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

153
			$orderAddr->/** @scrutinizer ignore-call */ 
154
               setWebsite( $dataset['website'] );

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.

Loading history...
154
			$orderAddr->setLanguageId( $dataset['langid'] );
155
			$orderAddr->setLatitude( $dataset['latitude'] );
0 ignored issues
show
Bug introduced by
The method setLatitude() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

155
			$orderAddr->/** @scrutinizer ignore-call */ 
156
               setLatitude( $dataset['latitude'] );

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.

Loading history...
156
			$orderAddr->setLongitude( $dataset['longitude'] );
0 ignored issues
show
Bug introduced by
The method setLongitude() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

156
			$orderAddr->/** @scrutinizer ignore-call */ 
157
               setLongitude( $dataset['longitude'] );

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.

Loading history...
157
158
			$manager->saveItem( $orderAddr, false );
159
		}
160
	}
161
162
163
	/**
164
	 * Adds the required order base service data.
165
	 *
166
	 * @param \Aimeos\MShop\Common\Manager\Iface $orderBaseManager Order base manager
167
	 * @param array $bases Associative list of key/list pairs
168
	 * @param array $testdata Associative list of key/list pairs
169
	 * @return array Associative list of enhanced order base items
170
	 * @throws \Aimeos\MW\Setup\Exception If no type ID is found
171
	 */
172
	protected function addOrderBaseServiceData( \Aimeos\MShop\Common\Manager\Iface $orderBaseManager,
173
		array $bases, array $testdata )
174
	{
175
		$ordServices = [];
176
		$servIds = $this->getServiceIds( $testdata );
177
		$orderBaseServiceManager = $orderBaseManager->getSubManager( 'service', 'Standard' );
178
		$orderBaseServiceAttrManager = $orderBaseServiceManager->getSubManager( 'attribute', 'Standard' );
179
		$priceManager = \Aimeos\MShop\Price\Manager\Factory::create( $this->additional, 'Standard' );
180
		$ordServ = $orderBaseServiceManager->createItem();
181
182
		$orderBaseManager->begin();
183
184
		foreach( $testdata['order/base/service'] as $key => $dataset )
185
		{
186
			if( !isset( $bases['ids'][$dataset['baseid']] ) ) {
187
				throw new \Aimeos\MW\Setup\Exception( sprintf( 'No base ID found for "%1$s" in order base serive data', $dataset['baseid'] ) );
188
			}
189
190
			if( !isset( $bases['items'][$dataset['baseid']] ) ) {
191
				throw new \Aimeos\MW\Setup\Exception( sprintf( 'No base Item found for "%1$s" in order base service data', $dataset['baseid'] ) );
192
			}
193
194
			$ordServ->setId( null );
195
			$ordServ->setBaseId( $bases['ids'][$dataset['baseid']] );
196
			$ordServ->setType( $dataset['type'] );
197
			$ordServ->setCode( $dataset['code'] );
198
			$ordServ->setName( $dataset['name'] );
0 ignored issues
show
Bug introduced by
The method setName() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

198
			$ordServ->/** @scrutinizer ignore-call */ 
199
             setName( $dataset['name'] );

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.

Loading history...
199
			$ordServ->setMediaUrl( $dataset['mediaurl'] );
0 ignored issues
show
Bug introduced by
The method setMediaUrl() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

199
			$ordServ->/** @scrutinizer ignore-call */ 
200
             setMediaUrl( $dataset['mediaurl'] );

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.

Loading history...
200
201
			if( isset( $dataset['servid'] ) ) {
202
				$ordServ->setServiceId( $servIds[$dataset['servid']] );
0 ignored issues
show
Bug introduced by
The method setServiceId() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

202
				$ordServ->/** @scrutinizer ignore-call */ 
203
              setServiceId( $servIds[$dataset['servid']] );

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.

Loading history...
203
			}
204
205
			$priceItem = $priceManager->createItem();
206
			$priceItem->setCurrencyId( $dataset['currencyid'] );
207
			$priceItem->setValue( $dataset['price'] );
0 ignored issues
show
Bug introduced by
The method setValue() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

207
			$priceItem->/** @scrutinizer ignore-call */ 
208
               setValue( $dataset['price'] );

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.

Loading history...
208
			$priceItem->setCosts( $dataset['shipping'] );
0 ignored issues
show
Bug introduced by
The method setCosts() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

208
			$priceItem->/** @scrutinizer ignore-call */ 
209
               setCosts( $dataset['shipping'] );

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.

Loading history...
209
			$priceItem->setRebate( $dataset['rebate'] );
0 ignored issues
show
Bug introduced by
The method setRebate() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

209
			$priceItem->/** @scrutinizer ignore-call */ 
210
               setRebate( $dataset['rebate'] );

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.

Loading history...
210
			$priceItem->setTaxRate( $dataset['taxrate'] );
0 ignored issues
show
Bug introduced by
The method setTaxRate() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

210
			$priceItem->/** @scrutinizer ignore-call */ 
211
               setTaxRate( $dataset['taxrate'] );

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.

Loading history...
211
			$ordServ->setPrice( $priceItem );
0 ignored issues
show
Bug introduced by
The method setPrice() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

211
			$ordServ->/** @scrutinizer ignore-call */ 
212
             setPrice( $priceItem );

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.

Loading history...
212
213
			$orderBaseServiceManager->saveItem( $ordServ );
214
215
			$ordServices[$key] = $ordServ->getId();
216
			$bases['items'][$dataset['baseid']]->addService( $ordServ, $dataset['type'] ); //adds Services to orderbase
217
		}
218
219
		$this->addOrderBaseServiceAttributeData( $orderBaseServiceAttrManager, $testdata, $ordServices );
220
221
		$orderBaseManager->commit();
222
223
		return $bases['items'];
224
	}
225
226
227
	/**
228
	 * Adds the required order base product data.
229
	 *
230
	 * @param \Aimeos\MShop\Common\Manager\Iface $orderBaseManager Order Base Manager
231
	 * @param array $bases Associative list of key/list pairs
232
	 * @param array $testdata Associative list of key/list pairs
233
	 * @return array Enhanced list of order base items
234
	 * @throws \Aimeos\MW\Setup\Exception If no type ID is found
235
	 */
236
	protected function addOrderBaseProductData( \Aimeos\MShop\Common\Manager\Iface $orderBaseManager,
237
		array $bases, array $testdata )
238
	{
239
		$ordProds = [];
240
		$products = $this->getProductItems( $testdata );
241
		$orderBaseProductManager = $orderBaseManager->getSubManager( 'product', 'Standard' );
242
		$orderBaseProductAttrManager = $orderBaseProductManager->getSubManager( 'attribute', 'Standard' );
243
		$priceManager = \Aimeos\MShop\Price\Manager\Factory::create( $this->additional, 'Standard' );
244
245
		$orderBaseManager->begin();
246
247
		foreach( $testdata['order/base/product'] as $key => $dataset )
248
		{
249
			if( !isset( $bases['ids'][$dataset['baseid']] ) ) {
250
				throw new \Aimeos\MW\Setup\Exception( sprintf( 'No base ID found for "%1$s" in order base product data', $dataset['baseid'] ) );
251
			}
252
253
			if( !isset( $bases['items'][$dataset['baseid']] ) ) {
254
				throw new \Aimeos\MW\Setup\Exception( sprintf( 'No base Item found for "%1$s" in order base product data', $dataset['baseid'] ) );
255
			}
256
257
			$ordProdItem = $orderBaseProductManager->createItem();
258
259
			$ordProdItem->setId( null );
260
			$ordProdItem->setBaseId( $bases['ids'][$dataset['baseid']] );
261
			$ordProdItem->setType( $dataset['type'] );
262
			$ordProdItem->setSupplierCode( $dataset['suppliercode'] );
0 ignored issues
show
Bug introduced by
The method setSupplierCode() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

262
			$ordProdItem->/** @scrutinizer ignore-call */ 
263
                 setSupplierCode( $dataset['suppliercode'] );

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.

Loading history...
263
			$ordProdItem->setProductCode( $dataset['prodcode'] );
0 ignored issues
show
Bug introduced by
The method setProductCode() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

263
			$ordProdItem->/** @scrutinizer ignore-call */ 
264
                 setProductCode( $dataset['prodcode'] );

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.

Loading history...
264
			$ordProdItem->setName( $dataset['name'] );
265
			$ordProdItem->setMediaUrl( $dataset['mediaurl'] );
266
			$ordProdItem->setQuantity( $dataset['amount'] );
0 ignored issues
show
Bug introduced by
The method setQuantity() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

266
			$ordProdItem->/** @scrutinizer ignore-call */ 
267
                 setQuantity( $dataset['amount'] );

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.

Loading history...
267
			$ordProdItem->setFlags( $dataset['flags'] );
0 ignored issues
show
Bug introduced by
The method setFlags() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

267
			$ordProdItem->/** @scrutinizer ignore-call */ 
268
                 setFlags( $dataset['flags'] );

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.

Loading history...
268
			$ordProdItem->setStatus( $dataset['status'] );
269
			$ordProdItem->setPosition( $dataset['pos'] );
270
271
			if( isset( $dataset['stocktype'] ) ) {
272
				$ordProdItem->setStockType( $dataset['stocktype'] );
0 ignored issues
show
Bug introduced by
The method setStockType() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

272
				$ordProdItem->/** @scrutinizer ignore-call */ 
273
                  setStockType( $dataset['stocktype'] );

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.

Loading history...
273
			}
274
275
			if( isset( $dataset['prodid'] ) ) {
276
				$ordProdItem->setProductId( $products[$dataset['prodid']]->getId() );
0 ignored issues
show
Bug introduced by
The method setProductId() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

276
				$ordProdItem->/** @scrutinizer ignore-call */ 
277
                  setProductId( $products[$dataset['prodid']]->getId() );

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.

Loading history...
277
			}
278
279
			// product bundle related fields
280
			if( isset( $dataset['ordprodid'] ) ) {
281
				$ordProdItem->setOrderProductId( $ordProds[$dataset['ordprodid']] );
0 ignored issues
show
Bug introduced by
The method setOrderProductId() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

281
				$ordProdItem->/** @scrutinizer ignore-call */ 
282
                  setOrderProductId( $ordProds[$dataset['ordprodid']] );

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.

Loading history...
282
			}
283
284
			$priceItem = $priceManager->createItem();
285
			$priceItem->setCurrencyId( $dataset['currencyid'] );
286
			$priceItem->setValue( $dataset['price'] );
287
			$priceItem->setCosts( $dataset['shipping'] );
288
			$priceItem->setRebate( $dataset['rebate'] );
289
			$priceItem->setTaxRate( $dataset['taxrate'] );
290
			$ordProdItem->setPrice( $priceItem );
291
292
			$bases['items'][$dataset['baseid']]->addProduct( $ordProdItem, $dataset['pos'] ); //adds Products to orderbase
293
			$ordProds[$key] = $orderBaseProductManager->saveItem( $ordProdItem )->getId();
294
		}
295
296
		$this->addOrderBaseProductAttributeData( $orderBaseProductAttrManager, $testdata, $ordProds, $products );
297
298
		$orderBaseManager->commit();
299
300
		return $bases['items'];
301
	}
302
303
304
	/**
305
	 * Adds the order product attribute test data.
306
	 *
307
	 * @param \Aimeos\MShop\Common\Manager\Iface $manager
308
	 * @param array $testdata
309
	 * @param array $ordProds
310
	 * @param \Aimeos\MShop\Product\Item\Iface[] $products
311
	 * @throws \Aimeos\MW\Setup\Exception
312
	 */
313
	protected function addOrderBaseProductAttributeData( \Aimeos\MShop\Common\Manager\Iface $manager,
314
		array $testdata, array $ordProds, array $products )
315
	{
316
		$attrCodes = [];
317
		$attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::create( $this->additional, 'Standard' );
318
		$attributes = $attributeManager->searchItems( $attributeManager->createSearch() );
319
320
		foreach( $attributes as $attrItem ) {
321
			$attrCodes[$attrItem->getType()][] = $attrItem;
322
		}
323
324
		$ordProdAttr = $manager->createItem();
325
326
		foreach( $testdata['order/base/product/attr'] as $dataset )
327
		{
328
			if( !isset( $ordProds[$dataset['ordprodid']] ) ) {
329
				throw new \Aimeos\MW\Setup\Exception( sprintf( 'No order product ID found for "%1$s"', $dataset['ordprodid'] ) );
330
			}
331
332
			$ordProdAttr->setId( null );
333
			$ordProdAttr->setParentId( $ordProds[$dataset['ordprodid']] );
0 ignored issues
show
Bug introduced by
The method setParentId() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

333
			$ordProdAttr->/** @scrutinizer ignore-call */ 
334
                 setParentId( $ordProds[$dataset['ordprodid']] );

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.

Loading history...
334
			$ordProdAttr->setCode( $dataset['code'] );
335
			$ordProdAttr->setValue( $dataset['value'] );
336
			$ordProdAttr->setName( $dataset['name'] );
337
			$ordProdAttr->setQuantity( $dataset['quantity'] );
338
339
			if( isset( $attrCodes[$dataset['code']] ) )
340
			{
341
				foreach( (array) $attrCodes[$dataset['code']] as $attrItem )
342
				{
343
					if( $attrItem->getCode() == $dataset['value'] ) {
344
						$ordProdAttr->setAttributeId( $attrItem->getId() );
0 ignored issues
show
Bug introduced by
The method setAttributeId() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

344
						$ordProdAttr->/** @scrutinizer ignore-call */ 
345
                    setAttributeId( $attrItem->getId() );

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.

Loading history...
345
					}
346
				}
347
			}
348
349
			if( isset( $dataset['type'] ) ) {
350
				$ordProdAttr->setType( $dataset['type'] );
351
			}
352
353
			$manager->saveItem( $ordProdAttr, false );
354
		}
355
	}
356
357
358
	/**
359
	 * Adds the order service attributes.
360
	 *
361
	 * @param \Aimeos\MShop\Common\Manager\Iface $manager
362
	 * @param array $testdata
363
	 * @param array $ordServices
364
	 * @throws \Aimeos\MW\Setup\Exception
365
	 */
366
	protected function addOrderBaseServiceAttributeData( \Aimeos\MShop\Common\Manager\Iface $manager,
367
		array $testdata, array $ordServices )
368
	{
369
		$ordServAttr = $manager->createItem();
370
371
		foreach( $testdata['order/base/service/attr'] as $dataset )
372
		{
373
			if( !isset( $ordServices[$dataset['ordservid']] ) ) {
374
				throw new \Aimeos\MW\Setup\Exception( sprintf( 'No order service ID found for "%1$s"', $dataset['ordservid'] ) );
375
			}
376
377
			$ordServAttr->setId( null );
378
			$ordServAttr->setParentId( $ordServices[$dataset['ordservid']] );
379
			$ordServAttr->setCode( $dataset['code'] );
380
			$ordServAttr->setValue( $dataset['value'] );
381
			$ordServAttr->setName( $dataset['name'] );
382
			$ordServAttr->setType( $dataset['type'] );
383
			$ordServAttr->setQuantity( $dataset['quantity'] );
384
385
			if( isset( $dataset['attrid'] ) ) {
386
				$ordServAttr->setAttributeId( $dataset['attrid'] );
387
			}
388
389
			$manager->saveItem( $ordServAttr, false );
390
		}
391
	}
392
393
394
	/**
395
	 * Adds the order test data.
396
	 *
397
	 * @param \Aimeos\MShop\Common\Manager\Iface $orderManager Order manager
398
	 * @param array $baseIds List of ids
399
	 * @param array $testdata Associative list of key/list pairs
400
	 * @throws \Aimeos\MW\Setup\Exception If no type ID is found
401
	 */
402
	protected function addOrderData( \Aimeos\MShop\Common\Manager\Iface $orderManager, array $baseIds, array $testdata )
403
	{
404
		$orderStatusManager = $orderManager->getSubManager( 'status', 'Standard' );
405
406
		$ords = [];
407
		$ordItem = $orderManager->createItem();
408
409
		$orderManager->begin();
410
411
		foreach( $testdata['order'] as $key => $dataset )
412
		{
413
			if( !isset( $baseIds[$dataset['baseid']] ) ) {
414
				throw new \Aimeos\MW\Setup\Exception( sprintf( 'No base ID found for "%1$s"', $dataset['baseid'] ) );
415
			}
416
417
			$ordItem->setId( null );
418
			$ordItem->setType( $dataset['type'] );
419
			$ordItem->setBaseId( $baseIds[$dataset['baseid']] );
420
			$ordItem->setDeliveryStatus( $dataset['statusdelivery'] );
0 ignored issues
show
Bug introduced by
The method setDeliveryStatus() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

420
			$ordItem->/** @scrutinizer ignore-call */ 
421
             setDeliveryStatus( $dataset['statusdelivery'] );

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.

Loading history...
421
			$ordItem->setPaymentStatus( $dataset['statuspayment'] );
0 ignored issues
show
Bug introduced by
The method setPaymentStatus() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

421
			$ordItem->/** @scrutinizer ignore-call */ 
422
             setPaymentStatus( $dataset['statuspayment'] );

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.

Loading history...
422
			$ordItem->setDateDelivery( $dataset['datedelivery'] );
0 ignored issues
show
Bug introduced by
The method setDateDelivery() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

422
			$ordItem->/** @scrutinizer ignore-call */ 
423
             setDateDelivery( $dataset['datedelivery'] );

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.

Loading history...
423
			$ordItem->setDatePayment( $dataset['datepayment'] );
0 ignored issues
show
Bug introduced by
The method setDatePayment() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

423
			$ordItem->/** @scrutinizer ignore-call */ 
424
             setDatePayment( $dataset['datepayment'] );

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.

Loading history...
424
			$ordItem->setRelatedId( $dataset['relatedid'] );
0 ignored issues
show
Bug introduced by
The method setRelatedId() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

424
			$ordItem->/** @scrutinizer ignore-call */ 
425
             setRelatedId( $dataset['relatedid'] );

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.

Loading history...
425
426
			$orderManager->saveItem( $ordItem );
427
			$ords[$key] = $ordItem->getId();
428
		}
429
430
		$ordStat = $orderStatusManager->createItem();
431
		foreach( $testdata['order/status'] as $dataset )
432
		{
433
			if( !isset( $ords[$dataset['parentid']] ) ) {
434
				throw new \Aimeos\MW\Setup\Exception( sprintf( 'No order ID found for "%1$s"', $dataset['parentid'] ) );
435
			}
436
437
			$ordStat->setId( null );
438
			$ordStat->setParentId( $ords[$dataset['parentid']] );
439
			$ordStat->setType( $dataset['type'] );
440
			$ordStat->setValue( $dataset['value'] );
441
442
			$orderStatusManager->saveItem( $ordStat, false );
443
		}
444
445
		$orderManager->commit();
446
	}
447
448
449
	/**
450
	 * Returns the customer IDs for the given test data.
451
	 *
452
	 * @param array $testdata Test data
453
	 * @return array Customer Ids
454
	 */
455
	protected function getCustomerIds( array $testdata )
456
	{
457
		$customercodes = $customerIds = [];
458
459
		foreach( $testdata['order/base'] as $key => $dataset ) {
460
			$customercodes[] = $dataset['customerid'];
461
		}
462
463
		$customerManager = \Aimeos\MShop\Customer\Manager\Factory::create( $this->additional, 'Standard' );
464
		$search = $customerManager->createSearch();
465
		$search->setConditions( $search->compare( '==', 'customer.code', $customercodes ) );
466
467
		foreach( $customerManager->searchItems( $search ) as $id => $customerItem ) {
468
			$customerIds[$customerItem->getCode()] = $id;
469
		}
470
471
		return $customerIds;
472
	}
473
474
475
	/**
476
	 * Returns the product items for the given test data.
477
	 *
478
	 * @param array $testdata Test data
479
	 * @return \Aimeos\MShop\Product\Item\Iface[] Product Items
480
	 */
481
	protected function getProductItems( array $testdata )
482
	{
483
		$codes = $items = [];
484
		$productManager = \Aimeos\MShop\Product\Manager\Factory::create( $this->additional, 'Standard' );
485
486
		foreach( $testdata['order/base/product'] as $key => $dataset )
487
		{
488
			if( isset( $dataset['prodid'] ) ) {
489
				$codes[$key] = $dataset['prodid'];
490
			}
491
		}
492
493
		$search = $productManager->createSearch();
494
		$search->setConditions( $search->compare( '==', 'product.code', $codes ) );
495
		$result = $productManager->searchItems( $search );
496
497
		foreach( $result as $item ) {
498
			$items[$item->getCode()] = $item;
499
		}
500
501
		return $items;
502
	}
503
504
505
	/**
506
	 * Returns the service item IDs for the given test data.
507
	 *
508
	 * @param array $testdata Test data
509
	 * @return array List of service IDs
510
	 */
511
	protected function getServiceIds( array $testdata )
512
	{
513
		$services = $servIds = [];
514
		$serviceManager = \Aimeos\MShop\Service\Manager\Factory::create( $this->additional, 'Standard' );
515
516
		foreach( $testdata['order/base/service'] as $key => $dataset )
517
		{
518
			if( isset( $dataset['servid'] ) ) {
519
				$services[$key] = $dataset['servid'];
520
			}
521
		}
522
523
		$search = $serviceManager->createSearch();
524
		$search->setConditions( $search->compare( '==', 'service.code', $services ) );
525
		$servicesResult = $serviceManager->searchItems( $search );
526
527
		foreach( $servicesResult as $id => $service ) {
528
			$servIds[$service->getCode()] = $id;
529
		}
530
531
		return $servIds;
532
	}
533
}
534