Completed
Push — master ( 94b58b...843436 )
by Aimeos
02:17
created

CustomerListAddLaravelTestData::migrate()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 9.472
c 0
b 0
f 0
cc 4
nc 4
nop 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2014-2017
6
 */
7
8
9
namespace Aimeos\MW\Setup\Task;
10
11
12
/**
13
 * Adds customer list test data.
14
 */
15
class CustomerListAddLaravelTestData
16
	extends \Aimeos\MW\Setup\Task\CustomerListAddTestData
0 ignored issues
show
Coding Style introduced by
The extends keyword must be on the same line as the class name
Loading history...
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 array( 'TablesCreateLaravel', 'CustomerAddLaravelTestData', 'LocaleAddTestData', 'TextAddTestData' );
26
	}
27
28
29
	/**
30
	 * Adds attribute test data.
31
	 */
32
	public function migrate()
33
	{
34
		$iface = '\\Aimeos\\MShop\\Context\\Item\\Iface';
35
		if( !( $this->additional instanceof $iface ) ) {
36
			throw new \Aimeos\MW\Setup\Exception( sprintf( 'Additionally provided object is not of type "%1$s"', $iface ) );
37
		}
38
39
		$this->msg( 'Adding customer-list Laravel test data', 0 );
40
		$this->additional->setEditor( 'ai-laravel:unittest' );
41
42
		$ds = DIRECTORY_SEPARATOR;
43
		$path = __DIR__ . $ds . 'data' . $ds . 'customer-list.php';
44
45
		if( ( $testdata = include( $path ) ) == false ){
46
			throw new \Aimeos\MShop\Exception( sprintf( 'No file "%1$s" found for customer list domain', $path ) );
47
		}
48
49
		$refKeys = [];
50
		foreach( $testdata['customer/lists'] as $dataset ) {
51
			$refKeys[ $dataset['domain'] ][] = $dataset['refid'];
52
		}
53
54
		$refIds = [];
55
		$refIds['text'] = $this->getTextData( $refKeys['text'] );
56
		$this->addCustomerListData( $testdata, $refIds, 'Laravel' );
57
58
		$this->status( 'done' );
59
	}
60
}