AdditionalTest.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Persistent\Block\Header;
  7. /**
  8. * @magentoDataFixture Magento/Persistent/_files/persistent.php
  9. */
  10. class AdditionalTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * @var \Magento\Persistent\Block\Header\Additional
  14. */
  15. protected $_block;
  16. /**
  17. * @var \Magento\Persistent\Helper\Session
  18. */
  19. protected $_persistentSessionHelper;
  20. /**
  21. * @var \Magento\Customer\Model\Session
  22. */
  23. protected $_customerSession;
  24. /**
  25. * @var \Magento\Framework\ObjectManagerInterface
  26. */
  27. protected $_objectManager;
  28. public function setUp()
  29. {
  30. $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
  31. /** @var \Magento\Persistent\Helper\Session $persistentSessionHelper */
  32. $this->_persistentSessionHelper = $this->_objectManager->create(\Magento\Persistent\Helper\Session::class);
  33. $this->_customerSession = $this->_objectManager->get(\Magento\Customer\Model\Session::class);
  34. $this->_block = $this->_objectManager->create(\Magento\Persistent\Block\Header\Additional::class);
  35. }
  36. /**
  37. * @magentoConfigFixture current_store persistent/options/customer 1
  38. * @magentoConfigFixture current_store persistent/options/enabled 1
  39. * @magentoConfigFixture current_store persistent/options/remember_enabled 1
  40. * @magentoConfigFixture current_store persistent/options/remember_default 1
  41. * @magentoAppArea frontend
  42. * @magentoAppIsolation enabled
  43. */
  44. public function testToHtml()
  45. {
  46. $this->_customerSession->loginById(1);
  47. $translation = __('Not you?');
  48. $this->assertContains(
  49. '<a href="' . $this->_block->getHref() . '">' . $translation . '</a>',
  50. $this->_block->toHtml()
  51. );
  52. $this->_customerSession->logout();
  53. }
  54. }