EventFactoryTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Test\Unit;
  7. class EventFactoryTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Magento\Framework\EventFactory
  11. */
  12. protected $_model;
  13. /**
  14. * @var \PHPUnit_Framework_MockObject_MockObject
  15. */
  16. protected $_objectManagerMock;
  17. /**
  18. * @var \Magento\Framework\Event
  19. */
  20. protected $_expectedObject;
  21. protected function setUp()
  22. {
  23. $this->_objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
  24. $this->_model = new \Magento\Framework\EventFactory($this->_objectManagerMock);
  25. $this->_expectedObject = $this->getMockBuilder(\Magento\Framework\Event::class)->getMock();
  26. }
  27. public function testCreate()
  28. {
  29. $arguments = ['property' => 'value'];
  30. $this->_objectManagerMock->expects(
  31. $this->once()
  32. )->method(
  33. 'create'
  34. )->with(
  35. \Magento\Framework\Event::class,
  36. $arguments
  37. )->will(
  38. $this->returnValue($this->_expectedObject)
  39. );
  40. $this->assertEquals($this->_expectedObject, $this->_model->create($arguments));
  41. }
  42. }