1 | <?php |
||
15 | class CustomerAddLaravelTestData extends \Aimeos\MW\Setup\Task\CustomerAddTestData |
||
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 getPreDependencies() |
||
23 | { |
||
24 | return array( 'TablesAddLaravelTestData' ); |
||
25 | } |
||
26 | |||
27 | |||
28 | /** |
||
29 | * Adds attribute test data. |
||
30 | */ |
||
31 | public function migrate() |
||
32 | { |
||
33 | $iface = '\\Aimeos\\MShop\\Context\\Item\\Iface'; |
||
34 | if( !( $this->additional instanceof $iface ) ) { |
||
35 | throw new \Aimeos\MW\Setup\Exception( sprintf( 'Additionally provided object is not of type "%1$s"', $iface ) ); |
||
36 | } |
||
37 | |||
38 | $this->msg( 'Adding Laravel customer test data', 0 ); |
||
39 | $this->additional->setEditor( 'ai-laravel:unittest' ); |
||
40 | |||
41 | $parentIds = array(); |
||
42 | $ds = DIRECTORY_SEPARATOR; |
||
43 | $path = __DIR__ . $ds . 'data' . $ds . 'customer.php'; |
||
44 | |||
45 | if( ( $testdata = include( $path ) ) == false ){ |
||
46 | throw new \Aimeos\MShop\Exception( sprintf( 'No file "%1$s" found for customer domain', $path ) ); |
||
47 | } |
||
48 | |||
49 | |||
50 | $customerManager = \Aimeos\MShop\Customer\Manager\Factory::createManager( $this->additional, 'Laravel' ); |
||
51 | $customerAddressManager = $customerManager->getSubManager( 'address', 'Laravel' ); |
||
52 | |||
53 | $this->cleanupCustomerData( $customerManager, $customerAddressManager ); |
||
54 | |||
55 | $this->conn->begin(); |
||
56 | |||
57 | $parentIds = $this->addCustomerData( $testdata, $customerManager, $customerAddressManager->createItem() ); |
||
58 | $this->addCustomerAddressData( $testdata, $customerAddressManager, $parentIds ); |
||
59 | |||
60 | $this->conn->commit(); |
||
61 | |||
62 | |||
63 | $this->status( 'done' ); |
||
64 | } |
||
65 | |||
66 | |||
67 | /** |
||
68 | * Removes all customer unit test entries |
||
69 | * |
||
70 | * @param \Aimeos\MShop\Common\Manager\Iface $customerManager Customer manager |
||
71 | * @param \Aimeos\MShop\Common\Manager\Iface $customerAddressManager Customer address manager |
||
72 | */ |
||
73 | protected function cleanupCustomerData( \Aimeos\MShop\Common\Manager\Iface $customerManager, \Aimeos\MShop\Common\Manager\Iface $customerAddressManager ) |
||
86 | } |
||
87 |