Total Complexity | 5 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | class BasketTestData 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 basket test data. |
||
30 | */ |
||
31 | public function up() |
||
32 | { |
||
33 | $this->info( 'Adding basket test data', 'vv' ); |
||
34 | $context = $this->context()->setEditor( 'core' ); |
||
|
|||
35 | |||
36 | $path = __DIR__ . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'basket.php'; |
||
37 | |||
38 | if( ( $testdata = include( $path ) ) == false ) { |
||
39 | throw new \RuntimeException( sprintf( 'No file "%1$s" found for baskets', $path ) ); |
||
40 | } |
||
41 | |||
42 | $orderManager = \Aimeos\MShop::create( $context, 'order', 'Standard' ); |
||
43 | $manager = \Aimeos\MShop::create( $context, 'basket', 'Standard' ); |
||
44 | $manager->begin(); |
||
45 | |||
46 | foreach( $testdata as $entry ) { |
||
47 | $manager->save( $manager->create()->fromArray( $entry, true )->setItem( $orderManager->create() ) ); |
||
48 | } |
||
49 | |||
50 | $manager->commit(); |
||
51 | } |
||
52 | |||
53 | |||
54 | protected function getCustomer() : \Aimeos\MShop\Customer\Item\Iface |
||
58 | } |
||
59 | } |
||
60 |