1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace TddWizard\Fixtures\Customer; |
4
|
|
|
|
5
|
|
|
use Magento\Customer\Api\Data\AddressInterface; |
6
|
|
|
use Magento\Customer\Api\Data\CustomerInterface; |
7
|
|
|
use Magento\Customer\Model\Session; |
8
|
|
|
use Magento\TestFramework\Helper\Bootstrap; |
|
|
|
|
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Object that can be returned from customer fixture, contains ids for test expectations |
12
|
|
|
*/ |
13
|
|
|
class CustomerFixture |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var CustomerInterface |
17
|
|
|
*/ |
18
|
|
|
private $customer; |
19
|
|
|
|
20
|
41 |
|
public function __construct(CustomerInterface $customer) |
21
|
|
|
{ |
22
|
41 |
|
$this->customer = $customer; |
23
|
41 |
|
} |
24
|
|
|
|
25
|
|
|
public function getDefaultShippingAddressId(): int |
26
|
|
|
{ |
27
|
|
|
return $this->customer->getDefaultShipping(); |
|
|
|
|
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function getDefaultBillingAddressId(): int |
31
|
|
|
{ |
32
|
|
|
return $this->customer->getDefaultBilling(); |
|
|
|
|
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function getOtherAddressId(): int |
36
|
|
|
{ |
37
|
|
|
return $this->getNonDefaultAddressIds()[0]; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function getNonDefaultAddressIds(): array |
41
|
|
|
{ |
42
|
|
|
return array_values( |
43
|
|
|
array_diff( |
44
|
|
|
$this->getAllAddressIds(), |
45
|
|
|
[$this->getDefaultBillingAddressId(), $this->getDefaultShippingAddressId()] |
46
|
|
|
) |
47
|
|
|
); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function getAllAddressIds(): array |
51
|
|
|
{ |
52
|
|
|
return array_map( |
53
|
|
|
function (AddressInterface $address) { |
54
|
|
|
return $address->getId(); |
55
|
|
|
}, |
56
|
|
|
$this->customer->getAddresses() |
|
|
|
|
57
|
|
|
); |
58
|
|
|
} |
59
|
|
|
|
60
|
40 |
|
public function getId(): int |
61
|
|
|
{ |
62
|
40 |
|
return $this->customer->getId(); |
|
|
|
|
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function getConfirmation(): string |
66
|
|
|
{ |
67
|
|
|
return $this->customer->getConfirmation(); |
|
|
|
|
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function getEmail(): string |
71
|
|
|
{ |
72
|
|
|
return $this->customer->getEmail(); |
73
|
|
|
} |
74
|
|
|
|
75
|
29 |
|
public function login(Session $session = null): void |
76
|
|
|
{ |
77
|
29 |
|
if ($session === null) { |
78
|
29 |
|
$objectManager = Bootstrap::getObjectManager(); |
79
|
29 |
|
$objectManager->removeSharedInstance(Session::class); |
80
|
29 |
|
$session = $objectManager->get(Session::class); |
81
|
|
|
} |
82
|
29 |
|
$session->setCustomerId($this->getId()); |
83
|
29 |
|
} |
84
|
|
|
|
85
|
28 |
|
public function logout(Session $session = null): void |
86
|
|
|
{ |
87
|
28 |
|
if ($session === null) { |
88
|
28 |
|
$objectManager = Bootstrap::getObjectManager(); |
89
|
28 |
|
$session = $objectManager->get(Session::class); |
90
|
|
|
} |
91
|
|
|
|
92
|
28 |
|
$session->logout(); |
93
|
28 |
|
} |
94
|
|
|
|
95
|
|
|
public function rollback(): void |
96
|
|
|
{ |
97
|
|
|
CustomerFixtureRollback::create()->execute($this); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths