BulkNotificationManagementTest.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\AsynchronousOperations\Model;
  7. use Magento\AsynchronousOperations\Api\Data\BulkSummaryInterface;
  8. use Magento\TestFramework\Helper\Bootstrap;
  9. use Magento\Framework\ObjectManagerInterface;
  10. class BulkNotificationManagementTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * @var BulkNotificationManagement
  14. */
  15. private $model;
  16. /**
  17. * @var ObjectManagerInterface
  18. */
  19. private $objectManager;
  20. protected function setUp()
  21. {
  22. $this->objectManager = Bootstrap::getObjectManager();
  23. $this->model = $this->objectManager->create(
  24. BulkNotificationManagement::class
  25. );
  26. }
  27. /**
  28. * @magentoDataFixture Magento/AsynchronousOperations/_files/bulk.php
  29. */
  30. public function testAcknowledgeBulks()
  31. {
  32. $this->model->acknowledgeBulks(['bulk-uuid-5']);
  33. $acknowledgedBulks = $this->model->getAcknowledgedBulksByUser(1);
  34. $this->assertCount(1, $acknowledgedBulks);
  35. /** @var BulkSummaryInterface $acknowledgedBulk */
  36. $acknowledgedBulk = array_pop($acknowledgedBulks);
  37. $this->assertEquals('bulk-uuid-5', $acknowledgedBulk->getBulkId());
  38. }
  39. /**
  40. * @magentoDataFixture Magento/AsynchronousOperations/_files/acknowledged_bulk.php
  41. */
  42. public function testIgnoreBulks()
  43. {
  44. // 'bulk-uuid-5' and 'bulk-uuid-4' are marked as acknowledged in fixture
  45. $this->model->ignoreBulks(['bulk-uuid-5']);
  46. $acknowledgedBulks = $this->model->getAcknowledgedBulksByUser(1);
  47. $this->assertCount(1, $acknowledgedBulks);
  48. /** @var BulkSummaryInterface $acknowledgedBulk */
  49. $acknowledgedBulk = array_pop($acknowledgedBulks);
  50. $this->assertEquals('bulk-uuid-4', $acknowledgedBulk->getBulkId());
  51. }
  52. /**
  53. * @magentoDataFixture Magento/AsynchronousOperations/_files/acknowledged_bulk.php
  54. */
  55. public function testGetAcknowledgedBulks()
  56. {
  57. // 'bulk-uuid-5' and 'bulk-uuid-4' are marked as acknowledged in fixture
  58. $acknowledgedBulks = $this->model->getAcknowledgedBulksByUser(1);
  59. $this->assertCount(2, $acknowledgedBulks);
  60. }
  61. /**
  62. * @magentoDataFixture Magento/AsynchronousOperations/_files/acknowledged_bulk.php
  63. */
  64. public function testGetIgnoredBulks()
  65. {
  66. // 'bulk-uuid-5' and 'bulk-uuid-4' are marked as acknowledged in fixture. Fixture creates 5 bulks in total.
  67. $ignoredBulks = $this->model->getIgnoredBulksByUser(1);
  68. $this->assertCount(3, $ignoredBulks);
  69. }
  70. }