ActionFactoryTest.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\Framework\Mview\Test\Unit;
  7. class ActionFactoryTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Magento\Framework\Mview\ActionFactory|\PHPUnit_Framework_MockObject_MockObject
  11. */
  12. protected $model;
  13. /**
  14. * @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
  15. */
  16. protected $objectManagerMock;
  17. protected function setUp()
  18. {
  19. $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
  20. $this->model = new \Magento\Framework\Mview\ActionFactory($this->objectManagerMock);
  21. }
  22. /**
  23. * @expectedException \InvalidArgumentException
  24. * @expectedExceptionMessage NotAction doesn't implement \Magento\Framework\Mview\ActionInterface
  25. */
  26. public function testGetWithException()
  27. {
  28. $notActionInterfaceMock = $this->getMockBuilder('Action')->getMock();
  29. $this->objectManagerMock->expects(
  30. $this->once()
  31. )->method(
  32. 'get'
  33. )->with(
  34. 'NotAction'
  35. )->will(
  36. $this->returnValue($notActionInterfaceMock)
  37. );
  38. $this->model->get('NotAction');
  39. }
  40. public function testGet()
  41. {
  42. $actionInterfaceMock = $this->getMockForAbstractClass(
  43. \Magento\Framework\Mview\ActionInterface::class,
  44. [],
  45. '',
  46. false
  47. );
  48. $this->objectManagerMock->expects(
  49. $this->once()
  50. )->method(
  51. 'get'
  52. )->with(
  53. \Magento\Framework\Mview\ActionInterface::class
  54. )->will(
  55. $this->returnValue($actionInterfaceMock)
  56. );
  57. $this->model->get(\Magento\Framework\Mview\ActionInterface::class);
  58. $this->assertInstanceOf(\Magento\Framework\Mview\ActionInterface::class, $actionInterfaceMock);
  59. }
  60. }