1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace TddWizard\Fixtures\Customer; |
4
|
|
|
|
5
|
|
|
use Magento\Customer\Api\AddressRepositoryInterface; |
6
|
|
|
use Magento\Customer\Api\Data\AddressInterface; |
7
|
|
|
use Magento\Framework\ObjectManagerInterface; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Builder to be used by fixtures |
11
|
|
|
*/ |
12
|
|
|
class AddressBuilder |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @var AddressInterface |
16
|
|
|
*/ |
17
|
|
|
private $address; |
18
|
|
|
/** |
19
|
|
|
* @var AddressRepositoryInterface |
20
|
|
|
*/ |
21
|
|
|
private $addressRepository; |
22
|
|
|
|
23
|
|
|
public function __construct(AddressRepositoryInterface $addressRepository, AddressInterface $address) |
24
|
|
|
{ |
25
|
|
|
$this->address = $address; |
26
|
|
|
$this->addressRepository = $addressRepository; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function __clone() |
30
|
|
|
{ |
31
|
|
|
$this->address = clone $this->address; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function withCustomAttributes(array $values) : AddressBuilder |
35
|
|
|
{ |
36
|
|
|
$builder = clone $this; |
37
|
|
|
foreach ($values as $code => $value) { |
38
|
|
|
$builder->address->setCustomAttribute($code, $value); |
39
|
|
|
} |
40
|
|
|
return $builder; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public static function anAddress(ObjectManagerInterface $objectManager = null) : AddressBuilder |
44
|
|
|
{ |
45
|
|
|
if ($objectManager === null) { |
46
|
|
|
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); |
|
|
|
|
47
|
|
|
} |
48
|
|
|
/** @var AddressInterface $address */ |
49
|
|
|
$address = $objectManager->create(AddressInterface::class); |
50
|
|
|
$address |
51
|
|
|
->setTelephone('3468676') |
52
|
|
|
->setPostcode('75477') |
53
|
|
|
->setCountryId('US') |
54
|
|
|
->setCity('CityM') |
55
|
|
|
->setCompany('CompanyName') |
56
|
|
|
->setStreet(['Green str, 67']) |
57
|
|
|
->setLastname('Smith') |
58
|
|
|
->setFirstname('John') |
59
|
|
|
->setRegionId(1); |
60
|
|
|
return new self($objectManager->create(AddressRepositoryInterface::class), $address); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function asDefaultShipping() : AddressBuilder |
64
|
|
|
{ |
65
|
|
|
$builder = clone $this; |
66
|
|
|
$builder->address->setIsDefaultShipping(true); |
67
|
|
|
return $builder; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function asDefaultBilling() : AddressBuilder |
71
|
|
|
{ |
72
|
|
|
$builder = clone $this; |
73
|
|
|
$builder->address->setIsDefaultBilling(true); |
74
|
|
|
return $builder; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function build() : AddressInterface |
78
|
|
|
{ |
79
|
|
|
return $this->addressRepository->save($this->address); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function buildWithoutSave() : AddressInterface |
83
|
|
|
{ |
84
|
|
|
return clone $this->address; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function withPrefix($prefix) : AddressBuilder |
88
|
|
|
{ |
89
|
|
|
$builder = clone $this; |
90
|
|
|
$builder->address->setPrefix($prefix); |
91
|
|
|
return $builder; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function withFirstname($firstname) : AddressBuilder |
95
|
|
|
{ |
96
|
|
|
$builder = clone $this; |
97
|
|
|
$builder->address->setFirstname($firstname); |
98
|
|
|
return $builder; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
public function withLastname($lastname) : AddressBuilder |
102
|
|
|
{ |
103
|
|
|
$builder = clone $this; |
104
|
|
|
$builder->address->setLastname($lastname); |
105
|
|
|
return $builder; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
public function withStreet($street) : AddressBuilder |
109
|
|
|
{ |
110
|
|
|
$builder = clone $this; |
111
|
|
|
$builder->address->setStreet((array) $street); |
112
|
|
|
return $builder; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function withCompany($company) : AddressBuilder |
116
|
|
|
{ |
117
|
|
|
$builder = clone $this; |
118
|
|
|
$builder->address->setCompany($company); |
119
|
|
|
return $builder; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function withTelephone($telephone) : AddressBuilder |
123
|
|
|
{ |
124
|
|
|
$builder = clone $this; |
125
|
|
|
$builder->address->setTelephone($telephone); |
126
|
|
|
return $builder; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
public function withPostcode($postcode) : AddressBuilder |
130
|
|
|
{ |
131
|
|
|
$builder = clone $this; |
132
|
|
|
$builder->address->setPostcode($postcode); |
133
|
|
|
return $builder; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
public function withCity($city) : AddressBuilder |
137
|
|
|
{ |
138
|
|
|
$builder = clone $this; |
139
|
|
|
$builder->address->setCity($city); |
140
|
|
|
return $builder; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
public function withCountryId($countryId) : AddressBuilder |
144
|
|
|
{ |
145
|
|
|
$builder = clone $this; |
146
|
|
|
$builder->address->setCountryId($countryId); |
147
|
|
|
return $builder; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
public function withRegionId($regionId) : AddressBuilder |
151
|
|
|
{ |
152
|
|
|
$builder = clone $this; |
153
|
|
|
$builder->address->setRegionId($regionId); |
154
|
|
|
return $builder; |
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
|
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