QuoteIdToMaskedQuoteIdTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\Quote\Model;
  8. use Magento\Framework\Exception\NoSuchEntityException;
  9. use Magento\TestFramework\Helper\Bootstrap as BootstrapHelper;
  10. use Magento\Quote\Model\ResourceModel\Quote as QuoteResource;
  11. class QuoteIdToMaskedQuoteIdTest extends \PHPUnit\Framework\TestCase
  12. {
  13. /**
  14. * @var QuoteResource
  15. */
  16. private $quoteResource;
  17. /**
  18. * @var QuoteFactory
  19. */
  20. private $quoteFactory;
  21. /**
  22. * @var QuoteIdToMaskedQuoteIdInterface
  23. */
  24. private $quoteIdToMaskedQuoteId;
  25. protected function setUp()
  26. {
  27. $objectManager = BootstrapHelper::getObjectManager();
  28. $this->quoteIdToMaskedQuoteId = $objectManager->create(QuoteIdToMaskedQuoteIdInterface::class);
  29. $this->quoteFactory = $objectManager->create(QuoteFactory::class);
  30. $this->quoteResource = $objectManager->create(QuoteResource::class);
  31. }
  32. /**
  33. * @magentoDataFixture Magento/Sales/_files/quote.php
  34. */
  35. public function testMaskedQuoteId()
  36. {
  37. $quote = $this->quoteFactory->create();
  38. $this->quoteResource->load($quote, 'test01', 'reserved_order_id');
  39. $maskedQuoteId = $this->quoteIdToMaskedQuoteId->execute((int) $quote->getId());
  40. self::assertNotEmpty($maskedQuoteId);
  41. }
  42. public function testMaskedQuoteIdWithNonExistentQuoteId()
  43. {
  44. self::expectException(NoSuchEntityException::class);
  45. $this->quoteIdToMaskedQuoteId->execute(0);
  46. }
  47. }