CompanyTest.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Customer\Block\Widget;
  7. /**
  8. * Test class for \Magento\Customer\Block\Widget\Taxvat
  9. *
  10. * @magentoAppArea frontend
  11. */
  12. class CompanyTest extends \PHPUnit\Framework\TestCase
  13. {
  14. /**
  15. * @magentoAppIsolation enabled
  16. */
  17. public function testToHtml()
  18. {
  19. /** @var \Magento\Customer\Block\Widget\Company $block */
  20. $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
  21. \Magento\Customer\Block\Widget\Company::class
  22. );
  23. $this->assertContains('title="Company"', $block->toHtml());
  24. $this->assertNotContains('required', $block->toHtml());
  25. }
  26. /**
  27. * @magentoAppIsolation enabled
  28. * @magentoDbIsolation enabled
  29. */
  30. public function testToHtmlRequired()
  31. {
  32. /** @var \Magento\Customer\Model\Attribute $model */
  33. $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
  34. \Magento\Customer\Model\Attribute::class
  35. );
  36. $model->loadByCode('customer_address', 'company')->setIsRequired(true);
  37. $model->save();
  38. /** @var \Magento\Customer\Block\Widget\Company $block */
  39. $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
  40. \Magento\Customer\Block\Widget\Company::class
  41. );
  42. $this->assertContains('title="Company"', $block->toHtml());
  43. $this->assertContains('required', $block->toHtml());
  44. }
  45. protected function tearDown()
  46. {
  47. /** @var \Magento\Eav\Model\Config $eavConfig */
  48. $eavConfig = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Eav\Model\Config::class);
  49. $eavConfig->clear();
  50. }
  51. }