Passed
Push — master ( ef7004...60f145 )
by Aimeos
09:20
created

OrderAddBasketTestData::getCustomer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2022
6
 */
7
8
9
namespace Aimeos\Upscheme\Task;
10
11
12
/**
13
 * Adds order basket test data.
14
 */
15
class OrderAddBasketTestData extends Base
16
{
17
	/**
18
	 * Returns the list of task names which this task depends on.
19
	 *
20
	 * @return string[] List of task names
21
	 */
22
	public function after() : array
23
	{
24
		return ['Order'];
25
	}
26
27
28
	/**
29
	 * Adds order test data.
30
	 */
31
	public function up()
32
	{
33
		$this->info( 'Adding order basket test data', 'vv' );
34
35
		$context = $this->context()->setEditor( 'core' );
0 ignored issues
show
Bug introduced by
The method context() does not exist on Aimeos\Upscheme\Task\OrderAddBasketTestData. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

35
		$context = $this->/** @scrutinizer ignore-call */ context()->setEditor( 'core' );
Loading history...
36
37
		$ds = DIRECTORY_SEPARATOR;
38
		$path = __DIR__ . $ds . 'data' . $ds . 'order-basket.php';
39
40
		if( ( $testdata = include( $path ) ) == false ) {
41
			throw new \RuntimeException( sprintf( 'No file "%1$s" found for order baskets', $path ) );
42
		}
43
44
		$manager = \Aimeos\MShop::create( $context, 'order/basket', 'Standard' );
45
46
		foreach( $testdata as $entry ) {
47
			$manager->save( $manager->create()->fromArray( $entry, true ) )->setCustomerId( $this->getCustomer()->getId() );
48
		}
49
	}
50
51
52
	protected function getCustomer() : \Aimeos\MShop\Customer\Item\Iface
53
	{
54
		$manager = \Aimeos\MShop::create( $this->context(), 'customer', 'Standard' );
55
		return $manager->find( '[email protected]' );
56
	}
57
}
58