41 $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
43 $this->customer = $this->getMockBuilder(\
Magento\
Customer\Model\Customer::class)
44 ->disableOriginalConstructor()
46 $this->customer->expects($this->any())
48 ->will($this->returnValue(self::ORIG_CUSTOMER_ID));
49 $this->customer->expects($this->any())
51 ->will($this->returnSelf());
53 $this->customerFactory = $this->getMockBuilder(\
Magento\
Customer\Model\CustomerFactory::class)
54 ->disableOriginalConstructor()
55 ->setMethods([
'create'])
57 $this->customerFactory->expects($this->any())
59 ->will($this->returnValue($this->customer));
62 ->disableOriginalConstructor()
65 $this->address = $this->objectManager->getObject(
68 'customerFactory' => $this->customerFactory,
69 'resource' => $this->resource,
76 $this->address->setParentId(self::ORIG_PARENT_ID);
77 $this->assertEquals(self::ORIG_PARENT_ID, $this->address->getCustomerId());
79 $this->address->setCustomerId(self::ORIG_CUSTOMER_ID);
80 $this->assertEquals(self::ORIG_CUSTOMER_ID, $this->address->getCustomerId());
83 public function testCustomer()
85 $this->address->unsetData(
'customer_id');
86 $this->assertFalse($this->address->getCustomer());
88 $this->address->setCustomerId(self::ORIG_CUSTOMER_ID);
90 $customer = $this->address->getCustomer();
91 $this->assertEquals(self::ORIG_CUSTOMER_ID,
$customer->getId());
95 ->disableOriginalConstructor()
99 ->will($this->returnValue(self::ORIG_CUSTOMER_ID + 1));
102 $this->assertEquals(self::ORIG_CUSTOMER_ID + 1, $this->address->getCustomerId());
107 $resultValue =
'test';
109 $this->resource->expects($this->any())
110 ->method(
'loadAllAttributes')
111 ->will($this->returnSelf());
112 $this->resource->expects($this->any())
113 ->method(
'getSortedAttributes')
114 ->will($this->returnValue($resultValue));
116 $this->assertEquals($resultValue, $this->address->getAttributes());
121 $this->address->setRegionId(1);
122 $this->assertEquals(1, $this->address->getRegionId());
127 $mockEntityType = $this->getMockBuilder(\
Magento\Eav\Model\Entity\Type::class)
128 ->disableOriginalConstructor()
130 $mockEntityType->expects($this->any())
132 ->will($this->returnValue(self::ORIG_CUSTOMER_ID));
134 $this->resource->expects($this->any())
135 ->method(
'getEntityType')
136 ->will($this->returnValue($mockEntityType));
138 $this->assertEquals(self::ORIG_CUSTOMER_ID, $this->address->getEntityTypeId());