11 class BookTest extends \PHPUnit\Framework\TestCase
23 protected function setUp()
26 $blockMock = $this->getMockBuilder(
27 \
Magento\Framework\View\Element\BlockInterface::class
28 )->disableOriginalConstructor()->setMethods(
29 [
'setTitle',
'toHtml']
31 $blockMock->expects($this->any())->method(
'setTitle');
34 ->get(\
Magento\Customer\Helper\Session\CurrentCustomer::class);
37 $layout->setBlock(
'head', $blockMock);
38 $this->_block = $layout
40 \
Magento\Customer\Block\Address\Book::class,
42 [
'currentCustomer' => $this->currentCustomer]
46 protected function tearDown()
58 'http://localhost/index.php/customer/address/edit/id/1/',
59 $this->_block->getAddressEditUrl(1)
74 $this->assertEquals($expected, $this->_block->hasPrimaryAddress());
79 return [
'0' => [0,
false],
'1' => [1,
true],
'5' => [5,
false]];
88 $this->currentCustomer->setCustomerId(1);
89 $this->assertNotNull($this->_block->getAdditionalAddresses());
90 $this->assertCount(1, $this->_block->getAdditionalAddresses());
91 $this->assertInstanceOf(
92 \
Magento\Customer\Api\Data\AddressInterface::class,
93 $this->_block->getAdditionalAddresses()[0]
95 $this->assertEquals(2, $this->_block->getAdditionalAddresses()[0]->getId());
105 $this->currentCustomer->setCustomerId(
$customerId);
107 $this->assertEquals($expected, $this->_block->getAdditionalAddresses());
112 return [
'0' => [0,
false],
'5' => [5,
false]];
121 $expected =
"John Smith<br />\nCompanyName<br />\nGreen str, 67<br />\n\n\n\nCityM, Alabama, 75477<br />" .
122 "\nUnited States<br />\nT: <a href=\"tel:3468676\">3468676</a>\n\n";
124 \
Magento\Customer\Api\AddressRepositoryInterface::class
126 $html = $this->_block->getAddressHtml(
$address);
127 $this->assertEquals($expected, $html);
132 $this->assertEquals(
'', $this->_block->getAddressHtml(
null));
138 public function testGetCustomer()
142 \
Magento\Customer\Api\CustomerRepositoryInterface::class
146 $this->currentCustomer->setCustomerId(1);
147 $object = $this->_block->getCustomer();
153 $this->assertNull($this->_block->getCustomer());
164 $this->currentCustomer->setCustomerId(
$customerId);
165 $this->assertEquals($expected, $this->_block->getDefaultBilling());
170 return [
'0' => [0,
null],
'1' => [1, 1],
'5' => [5,
null]];
182 $this->currentCustomer->setCustomerId(
$customerId);
184 $this->assertEquals($expected, $this->_block->getDefaultShipping());
189 return [
'0' => [0,
null],
'1' => [1, 1],
'5' => [5,
null]];
198 $this->assertInstanceOf(\
Magento\Customer\Api\Data\AddressInterface::class, $this->_block->getAddressById(1));
199 $this->assertNull($this->_block->getAddressById(5));
testGetCustomerMissingCustomer()
hasPrimaryAddressDataProvider()
testHasPrimaryAddress($customerId, $expected)
testGetAdditionalAddresses()
testGetDefaultShipping($customerId, $expected)
getDefaultShippingDataProvider()
getDefaultBillingDataProvider()
testGetAddressHtmlWithoutAddress()
getAdditionalAddressesDataProvider()
testGetDefaultBilling($customerId, $expected)
static getObjectManager()
testGetAdditionalAddressesNegative($customerId, $expected)