Completed
Push — 2016.04 ( 690368...e61816 )
by Aimeos
04:37
created

CustomerAddTypo3TestData   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 52
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getPreDependencies() 0 4 1
B process() 0 35 4
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2013
6
 * @copyright Aimeos (aimeos.org), 2014
7
 */
8
9
10
namespace Aimeos\MW\Setup\Task;
11
12
13
/**
14
 * Adds TYPO3 customer test data.
15
 */
16
class CustomerAddTypo3TestData extends \Aimeos\MW\Setup\Task\CustomerAddTestData
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( 'TablesAddTypo3TestData' );
26
	}
27
28
29
	/**
30
	 * Adds customer TYPO3 test data.
31
	 */
32
	protected function process()
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 TYPO3 customer test data', 0 );
40
		$this->additional->setEditor( 'ai-typo3:unittest' );
41
42
		$parentIds = array();
43
		$ds = DIRECTORY_SEPARATOR;
44
		$path = __DIR__ . $ds . 'data' . $ds . 'customer.php';
45
46
		if( ( $testdata = include( $path ) ) == false ){
47
			throw new \Aimeos\MShop\Exception( sprintf( 'No file "%1$s" found for customer domain', $path ) );
48
		}
49
50
51
		$customerManager = \Aimeos\MShop\Customer\Manager\Factory::createManager( $this->additional, 'Typo3' );
52
		$customerAddressManager = $customerManager->getSubManager( 'address', 'Typo3' );
53
54
		foreach( $customerManager->searchItems( $customerManager->createSearch() ) as $id => $item ) {
55
			$parentIds[ 'customer/' . $item->getCode() ] = $id;
56
		}
57
58
		$this->conn->begin();
59
60
		$this->addCustomerAddressData( $testdata, $customerAddressManager, $parentIds );
61
62
		$this->conn->commit();
63
64
65
		$this->status( 'done' );
66
	}
67
}
68