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\Framework\ObjectManagerInterface; |
9
|
|
|
use Magento\TestFramework\Helper\Bootstrap; |
|
|
|
|
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Object that can be returned from customer fixture, contains ids for test expectations |
13
|
|
|
*/ |
14
|
|
|
class CustomerFixture |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @var CustomerInterface |
18
|
|
|
*/ |
19
|
|
|
private $customer; |
20
|
|
|
|
21
|
|
|
public function __construct(CustomerInterface $customer) |
22
|
|
|
{ |
23
|
|
|
$this->customer = $customer; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function getDefaultShippingAddressId() : int |
27
|
|
|
{ |
28
|
|
|
return $this->customer->getDefaultShipping(); |
|
|
|
|
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function getDefaultBillingAddressId() : int |
32
|
|
|
{ |
33
|
|
|
return $this->customer->getDefaultBilling(); |
|
|
|
|
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function getOtherAddressId() : int |
37
|
|
|
{ |
38
|
|
|
return $this->getNonDefaultAddressIds()[0]; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function getNonDefaultAddressIds() : array |
42
|
|
|
{ |
43
|
|
|
return array_values( |
44
|
|
|
array_diff( |
45
|
|
|
$this->getAllAddressIds(), |
46
|
|
|
[$this->getDefaultBillingAddressId(), $this->getDefaultShippingAddressId()] |
47
|
|
|
) |
48
|
|
|
); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function getAllAddressIds(): array |
52
|
|
|
{ |
53
|
|
|
return array_map( |
54
|
|
|
function (AddressInterface $address) { |
55
|
|
|
return $address->getId(); |
56
|
|
|
}, |
57
|
|
|
$this->customer->getAddresses() |
|
|
|
|
58
|
|
|
); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function getId() : int |
62
|
|
|
{ |
63
|
|
|
return $this->customer->getId(); |
|
|
|
|
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function getConfirmation() : string |
67
|
|
|
{ |
68
|
|
|
return $this->customer->getConfirmation(); |
|
|
|
|
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function getEmail() : string |
72
|
|
|
{ |
73
|
|
|
return $this->customer->getEmail(); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function login(Session $session = null) |
77
|
|
|
{ |
78
|
|
|
if ($session === null) { |
79
|
|
|
$objectManager = Bootstrap::getObjectManager(); |
80
|
|
|
$objectManager->removeSharedInstance(Session::class); |
81
|
|
|
$session = $objectManager->get(Session::class); |
82
|
|
|
} |
83
|
|
|
$session->setCustomerId($this->getId()); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function logout(Session $session = null) |
87
|
|
|
{ |
88
|
|
|
if ($session === null) { |
89
|
|
|
$objectManager = Bootstrap::getObjectManager(); |
90
|
|
|
$session = $objectManager->get(Session::class); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
$session->logout(); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
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