20 private $addressFactory;
24 $this->addressFactory = $this->getMockBuilder(\
Magento\
Customer\Model\AddressFactory::class)
25 ->disableOriginalConstructor()
26 ->setMethods([
'create'])
28 $this->unit = new \Magento\Customer\Model\AddressRegistry($this->addressFactory);
35 ->disableOriginalConstructor()
36 ->setMethods([
'load',
'getId',
'__wakeup'])
41 ->will($this->returnValue(
$address));
44 ->will($this->returnValue($addressId));
45 $this->addressFactory->expects($this->once())
47 ->will($this->returnValue(
$address));
48 $actual = $this->unit->retrieve($addressId);
49 $this->assertEquals(
$address, $actual);
50 $actualCached = $this->unit->retrieve($addressId);
51 $this->assertEquals(
$address, $actualCached);
61 ->setMethods([
'load',
'getId',
'__wakeup'])
62 ->disableOriginalConstructor()
67 ->will($this->returnValue(
$address));
70 ->will($this->returnValue(
null));
71 $this->addressFactory->expects($this->once())
73 ->will($this->returnValue(
$address));
74 $this->unit->retrieve($addressId);
81 ->disableOriginalConstructor()
82 ->setMethods([
'load',
'getId',
'__wakeup'])
87 ->will($this->returnValue(
$address));
90 ->will($this->returnValue($addressId));
91 $this->addressFactory->expects($this->exactly(2))
93 ->will($this->returnValue(
$address));
94 $actual = $this->unit->retrieve($addressId);
95 $this->assertEquals(
$address, $actual);
96 $this->unit->remove($addressId);
97 $actual = $this->unit->retrieve($addressId);
98 $this->assertEquals(
$address, $actual);