FingerprintTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Signifyd\Block;
  7. use Magento\Framework\App\Area;
  8. use Magento\Framework\App\ObjectManager;
  9. use Magento\Framework\View\LayoutInterface;
  10. use Magento\TestFramework\Helper\Bootstrap;
  11. class FingerprintTest extends \PHPUnit\Framework\TestCase
  12. {
  13. /**
  14. * @var ObjectManager
  15. */
  16. private $objectManager;
  17. /**
  18. * @inheritdoc
  19. */
  20. protected function setUp()
  21. {
  22. $bootstrap = Bootstrap::getInstance();
  23. $bootstrap->loadArea(Area::AREA_FRONTEND);
  24. $this->objectManager = Bootstrap::getObjectManager();
  25. }
  26. /**
  27. * Checks if session id attribute is present when the module is enabled.
  28. *
  29. * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
  30. */
  31. public function testSessionIdPresent()
  32. {
  33. self::assertContains('data-order-session-id', $this->getBlockContents());
  34. }
  35. /**
  36. * Checks if block is an empty when the module is disabled.
  37. *
  38. * @magentoConfigFixture current_store fraud_protection/signifyd/active 0
  39. */
  40. public function testBlockEmpty()
  41. {
  42. self::assertEmpty($this->getBlockContents());
  43. }
  44. /**
  45. * Renders block contents.
  46. *
  47. * @return string
  48. */
  49. private function getBlockContents()
  50. {
  51. $block = $this->objectManager->get(LayoutInterface::class)
  52. ->createBlock(Fingerprint::class);
  53. return $block->fetchView($block->getTemplateFile());
  54. }
  55. }