init
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Customer\Block\Widget;
|
||||
|
||||
/**
|
||||
* Test class for \Magento\Customer\Block\Widget\Taxvat
|
||||
*
|
||||
* @magentoAppArea frontend
|
||||
*/
|
||||
class CompanyTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @magentoAppIsolation enabled
|
||||
*/
|
||||
public function testToHtml()
|
||||
{
|
||||
/** @var \Magento\Customer\Block\Widget\Company $block */
|
||||
$block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Customer\Block\Widget\Company::class
|
||||
);
|
||||
|
||||
$this->assertStringContainsString('title="Company"', $block->toHtml());
|
||||
$this->assertStringNotContainsString('required', $block->toHtml());
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoAppIsolation enabled
|
||||
* @magentoDbIsolation enabled
|
||||
*/
|
||||
public function testToHtmlRequired()
|
||||
{
|
||||
/** @var \Magento\Customer\Model\Attribute $model */
|
||||
$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Customer\Model\Attribute::class
|
||||
);
|
||||
$model->loadByCode('customer_address', 'company')->setIsRequired(true);
|
||||
$model->save();
|
||||
|
||||
/** @var \Magento\Customer\Block\Widget\Company $block */
|
||||
$block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Customer\Block\Widget\Company::class
|
||||
);
|
||||
|
||||
$this->assertStringContainsString('title="Company"', $block->toHtml());
|
||||
$this->assertStringContainsString('required', $block->toHtml());
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
/** @var \Magento\Eav\Model\Config $eavConfig */
|
||||
$eavConfig = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Eav\Model\Config::class);
|
||||
$eavConfig->clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test class for \Magento\Customer\Block\Widget\Dob
|
||||
*/
|
||||
namespace Magento\Customer\Block\Widget;
|
||||
|
||||
class DobTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testGetDateFormat()
|
||||
{
|
||||
$block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Customer\Block\Widget\Dob::class
|
||||
);
|
||||
$this->assertNotEmpty($block->getDateFormat());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Customer\Block\Widget;
|
||||
|
||||
/**
|
||||
* Test class for \Magento\Customer\Block\Widget\Taxvat
|
||||
*
|
||||
* @magentoAppArea frontend
|
||||
*/
|
||||
class FaxTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @magentoAppIsolation enabled
|
||||
*/
|
||||
public function testToHtml()
|
||||
{
|
||||
/** @var \Magento\Customer\Block\Widget\Fax $block */
|
||||
$block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Customer\Block\Widget\Fax::class
|
||||
);
|
||||
|
||||
$this->assertStringContainsString('title="Fax"', $block->toHtml());
|
||||
$this->assertStringNotContainsString('required', $block->toHtml());
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoAppIsolation enabled
|
||||
* @magentoDbIsolation enabled
|
||||
*/
|
||||
public function testToHtmlRequired()
|
||||
{
|
||||
/** @var \Magento\Customer\Model\Attribute $model */
|
||||
$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Customer\Model\Attribute::class
|
||||
);
|
||||
$model->loadByCode('customer_address', 'fax')->setIsRequired(true);
|
||||
$model->save();
|
||||
|
||||
/** @var \Magento\Customer\Block\Widget\Fax $block */
|
||||
$block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Customer\Block\Widget\Fax::class
|
||||
);
|
||||
|
||||
$this->assertStringContainsString('title="Fax"', $block->toHtml());
|
||||
$this->assertStringContainsString('required', $block->toHtml());
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
/** @var \Magento\Eav\Model\Config $eavConfig */
|
||||
$eavConfig = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Eav\Model\Config::class);
|
||||
$eavConfig->clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Customer\Block\Widget;
|
||||
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
/**
|
||||
* @magentoAppArea frontend
|
||||
*/
|
||||
class GenderTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/** @var Gender */
|
||||
protected $_block;
|
||||
|
||||
/** @var \Magento\Customer\Model\Attribute */
|
||||
private $_model;
|
||||
|
||||
/**
|
||||
* Test initialization and set up. Create the Gender block.
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
$objectManager->get(\Magento\Framework\App\State::class)->setAreaCode('frontend');
|
||||
$this->_block = $objectManager->get(
|
||||
\Magento\Framework\View\LayoutInterface::class
|
||||
)->createBlock(
|
||||
\Magento\Customer\Block\Widget\Gender::class
|
||||
);
|
||||
$this->_model = $objectManager->create(\Magento\Customer\Model\Attribute::class);
|
||||
$this->_model->loadByCode('customer', 'gender');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the Gender::getGenderOptions() method.
|
||||
* @return void
|
||||
*/
|
||||
public function testGetGenderOptions()
|
||||
{
|
||||
$options = $this->_block->getGenderOptions();
|
||||
$this->assertIsArray($options);
|
||||
$this->assertNotEmpty($options);
|
||||
$this->assertContainsOnlyInstancesOf(\Magento\Customer\Model\Data\Option::class, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the Gender::toHtml() method.
|
||||
* @return void
|
||||
*/
|
||||
public function testToHtml()
|
||||
{
|
||||
$html = $this->_block->toHtml();
|
||||
$attributeLabel = $this->_model->getStoreLabel();
|
||||
$this->assertStringContainsString('<span>' . $attributeLabel . '</span>', $html);
|
||||
$this->assertStringContainsString('<option value="1">Male</option>', $html);
|
||||
$this->assertStringContainsString('<option value="2">Female</option>', $html);
|
||||
$this->assertStringContainsString('<option value="3">Not Specified</option>', $html);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Customer\Block\Widget;
|
||||
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
/**
|
||||
* Test \Magento\Customer\Block\Widget\Name
|
||||
* @magentoAppArea frontend
|
||||
*/
|
||||
class NameTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/** @var Name */
|
||||
protected $_block;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
$objectManager->get(\Magento\Framework\App\State::class)->setAreaCode('frontend');
|
||||
$this->_block = $objectManager->get(
|
||||
\Magento\Framework\View\LayoutInterface::class
|
||||
)->createBlock(
|
||||
\Magento\Customer\Block\Widget\Name::class
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoAppIsolation enabled
|
||||
*/
|
||||
public function testToHtmlSimpleName()
|
||||
{
|
||||
/** @var \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerFactory */
|
||||
$customerFactory = Bootstrap::getObjectManager()->get(
|
||||
\Magento\Customer\Api\Data\CustomerInterfaceFactory::class
|
||||
);
|
||||
$customerDataObject = $customerFactory->create();
|
||||
$customerDataObject->setFirstname('Jane');
|
||||
$customerDataObject->setLastname('Doe');
|
||||
$this->_block->setObject($customerDataObject);
|
||||
|
||||
$html = $this->_block->toHtml();
|
||||
|
||||
$this->assertStringContainsString('title="First Name"', $html);
|
||||
$this->assertStringContainsString('value="Jane"', $html);
|
||||
$this->assertStringContainsString('title="Last Name"', $html);
|
||||
$this->assertStringContainsString('value="Doe"', $html);
|
||||
$this->assertStringNotContainsString('title="Middle Name/Initial"', $html);
|
||||
$this->assertStringNotContainsString('title="Name Prefix"', $html);
|
||||
$this->assertStringNotContainsString('title="Name Suffix"', $html);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoAppIsolation enabled
|
||||
* @magentoDataFixture Magento/Customer/_files/attribute_user_fullname.php
|
||||
*/
|
||||
public function testToHtmlFancyName()
|
||||
{
|
||||
/** @var \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerFactory */
|
||||
$customerFactory = Bootstrap::getObjectManager()->get(
|
||||
\Magento\Customer\Api\Data\CustomerInterfaceFactory::class
|
||||
);
|
||||
$customerDataObject = $customerFactory->create();
|
||||
$customerDataObject->setPrefix(
|
||||
'Dr.'
|
||||
)->setFirstname(
|
||||
'Jane'
|
||||
)->setMiddlename(
|
||||
'Roe'
|
||||
)->setLastname(
|
||||
'Doe'
|
||||
)->setSuffix(
|
||||
'Ph.D.'
|
||||
);
|
||||
$this->_block->setObject($customerDataObject);
|
||||
|
||||
$html = $this->_block->toHtml();
|
||||
|
||||
$this->assertStringContainsString('title="First Name"', $html);
|
||||
$this->assertStringContainsString('value="Jane"', $html);
|
||||
$this->assertStringContainsString('title="Last Name"', $html);
|
||||
$this->assertStringContainsString('value="Doe"', $html);
|
||||
$this->assertStringContainsString('title="Middle Name/Initial"', $html);
|
||||
$this->assertStringContainsString('value="Roe"', $html);
|
||||
$this->assertStringContainsString('title="Name Prefix"', $html);
|
||||
$this->assertStringContainsString('value="Dr."', $html);
|
||||
$this->assertStringContainsString('title="Name Suffix"', $html);
|
||||
$this->assertStringContainsString('value="Ph.D."', $html);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Customer\Block\Widget;
|
||||
|
||||
/**
|
||||
* Test class for \Magento\Customer\Block\Widget\Taxvat
|
||||
*
|
||||
* @magentoAppArea frontend
|
||||
*/
|
||||
class TaxvatTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @magentoAppIsolation enabled
|
||||
*/
|
||||
public function testToHtml()
|
||||
{
|
||||
/** @var \Magento\Customer\Block\Widget\Taxvat $block */
|
||||
$block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Customer\Block\Widget\Taxvat::class
|
||||
);
|
||||
|
||||
$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Customer\Model\Attribute::class
|
||||
);
|
||||
$model->loadByCode('customer', 'taxvat');
|
||||
$attributeLabel = $model->getStoreLabel();
|
||||
|
||||
$this->assertStringContainsString('title="' . $block->escapeHtmlAttr($attributeLabel) . '"', $block->toHtml());
|
||||
$this->assertStringNotContainsString('required', $block->toHtml());
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoAppIsolation enabled
|
||||
* @magentoDbIsolation enabled
|
||||
*/
|
||||
public function testToHtmlRequired()
|
||||
{
|
||||
/** @var \Magento\Customer\Model\Attribute $model */
|
||||
$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Customer\Model\Attribute::class
|
||||
);
|
||||
$model->loadByCode('customer', 'taxvat')->setIsRequired(true);
|
||||
$model->save();
|
||||
$attributeLabel = $model->getStoreLabel();
|
||||
|
||||
/** @var \Magento\Customer\Block\Widget\Taxvat $block */
|
||||
$block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Customer\Block\Widget\Taxvat::class
|
||||
);
|
||||
|
||||
$this->assertStringContainsString('title="' . $block->escapeHtmlAttr($attributeLabel) . '"', $block->toHtml());
|
||||
$this->assertStringContainsString('required', $block->toHtml());
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
/** @var \Magento\Eav\Model\Config $eavConfig */
|
||||
$eavConfig = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Eav\Model\Config::class);
|
||||
$eavConfig->clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Customer\Block\Widget;
|
||||
|
||||
/**
|
||||
* Test class for \Magento\Customer\Block\Widget\Taxvat
|
||||
*
|
||||
* @magentoAppArea frontend
|
||||
*/
|
||||
class TelephoneTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @magentoAppIsolation enabled
|
||||
*/
|
||||
public function testToHtml()
|
||||
{
|
||||
/** @var \Magento\Customer\Block\Widget\Telephone $block */
|
||||
$block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Customer\Block\Widget\Telephone::class
|
||||
);
|
||||
|
||||
$this->assertStringContainsString('title="Phone Number"', $block->toHtml());
|
||||
$this->assertStringContainsString('required', $block->toHtml());
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoAppIsolation enabled
|
||||
* @magentoDbIsolation enabled
|
||||
*/
|
||||
public function testToHtmlRequired()
|
||||
{
|
||||
/** @var \Magento\Customer\Model\Attribute $model */
|
||||
$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Customer\Model\Attribute::class
|
||||
);
|
||||
$model->loadByCode('customer_address', 'telephone')->setIsRequired(false);
|
||||
$model->save();
|
||||
|
||||
/** @var \Magento\Customer\Block\Widget\Telephone $block */
|
||||
$block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Customer\Block\Widget\Telephone::class
|
||||
);
|
||||
|
||||
$this->assertStringContainsString('title="Phone Number"', $block->toHtml());
|
||||
$this->assertStringNotContainsString('required', $block->toHtml());
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
/** @var \Magento\Eav\Model\Config $eavConfig */
|
||||
$eavConfig = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Eav\Model\Config::class);
|
||||
$eavConfig->clear();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user