Passed
Push — master ( 8f16ed...3311dc )
by Aimeos
10:04
created

mshoplib/setup/unitperf/CustomerAddPerfData.php (1 issue)

1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015-2018
6
 */
7
8
9
namespace Aimeos\MW\Setup\Task;
10
11
12
/**
13
 * Adds performance records to customer table.
14
 */
15
class CustomerAddPerfData extends \Aimeos\MW\Setup\Task\Base
16
{
17
	public function __construct( \Aimeos\MW\Setup\DBSchema\Iface $schema, \Aimeos\MW\DB\Connection\Iface $conn, $additional = null )
18
	{
19
		\Aimeos\MW\Common\Base::checkClass( \Aimeos\MShop\Context\Item\Iface::class, $additional );
20
21
		parent::__construct( $schema, $conn, $additional );
22
	}
23
24
25
	/**
26
	 * Returns the list of task names which this task depends on.
27
	 *
28
	 * @return string[] List of task names
29
	 */
30
	public function getPreDependencies()
31
	{
32
		return ['MShopAddTypeDataUnitperf', 'LocaleAddPerfData', 'MShopSetLocale'];
33
	}
34
35
36
	/**
37
	 * Returns the list of task names which depends on this task.
38
	 *
39
	 * @return array List of task names
40
	 */
41
	public function getPostDependencies()
42
	{
43
		return [];
44
	}
45
46
47
	/**
48
	 * Inserts customer items.
49
	 */
50
	public function migrate()
51
	{
52
		$this->msg( 'Adding customer performance data', 0 );
53
54
		$customerManager = \Aimeos\MShop\Customer\Manager\Factory::create( $this->additional );
55
56
		$customerItem = $customerManager->createItem();
57
		$customerItem->setCode( '[email protected]' );
58
		$customerItem->setLabel( 'Test demo unitperf user' );
59
		$customerItem->setPassword( sha1( microtime( true ) . getmypid() . rand() ) );
60
		$customerItem->setStatus( 1 );
61
62
		$addrItem = $customerItem->getPaymentAddress();
0 ignored issues
show
The method getPaymentAddress() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

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

62
		/** @scrutinizer ignore-call */ 
63
  $addrItem = $customerItem->getPaymentAddress();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
63
		$addrItem->setCompany( 'Test company' );
64
		$addrItem->setVatID( 'DE999999999' );
65
		$addrItem->setSalutation( 'mr' );
66
		$addrItem->setFirstname( 'Testdemo' );
67
		$addrItem->setLastname( 'Perfuser' );
68
		$addrItem->setAddress1( 'Test street' );
69
		$addrItem->setAddress2( '1' );
70
		$addrItem->setPostal( '1000' );
71
		$addrItem->setCity( 'Test city' );
72
		$addrItem->setLanguageId( 'en' );
73
		$addrItem->setCountryId( 'DE' );
74
		$addrItem->setEmail( '[email protected]' );
75
76
		$customerManager->saveItem( $customerItem );
77
78
		$this->status( 'done' );
79
	}
80
}
81