OperationPoolTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\EntityManager\Test\Unit;
  7. use PHPUnit\Framework\TestCase;
  8. use Magento\Framework\ObjectManagerInterface;
  9. use Magento\Framework\EntityManager\OperationPool;
  10. class OperationPoolTest extends TestCase
  11. {
  12. public function testGetOperationUsesDefaultValueForEntityThatDoesNotProvideCustomMapping()
  13. {
  14. $objectManagerMock = $this->createMock(ObjectManagerInterface::class);
  15. $operationPool = new OperationPool(
  16. $objectManagerMock,
  17. []
  18. );
  19. $objectManagerMock->expects($this->once())
  20. ->method('get')
  21. ->with(\Magento\Framework\EntityManager\Operation\Read::class);
  22. $operationPool->getOperation('entity_type', 'read');
  23. }
  24. public function testGetOperationUsesOverriddenDefaultValueForEntityThatDoesNotProvideCustomMapping()
  25. {
  26. $customReadOperation = 'CustomReadOperation';
  27. $objectManagerMock = $this->createMock(ObjectManagerInterface::class);
  28. $operationPool = new OperationPool(
  29. $objectManagerMock,
  30. [
  31. 'default' => [
  32. 'read' => $customReadOperation,
  33. 'new' => 'CustomNewOperation',
  34. ],
  35. ]
  36. );
  37. $objectManagerMock->expects($this->once())
  38. ->method('get')
  39. ->with($customReadOperation);
  40. $operationPool->getOperation('entity_type', 'read');
  41. }
  42. }