RequestFactoryTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\App\Test\Unit;
  7. use \Magento\Framework\App\RequestFactory;
  8. class RequestFactoryTest extends \PHPUnit\Framework\TestCase
  9. {
  10. /**
  11. * @var RequestFactory
  12. */
  13. protected $model;
  14. /**
  15. * @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
  16. */
  17. protected $objectManagerMock;
  18. protected function setUp()
  19. {
  20. $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
  21. $this->model = new RequestFactory($this->objectManagerMock);
  22. }
  23. /**
  24. * @covers \Magento\Framework\App\RequestFactory::__construct
  25. * @covers \Magento\Framework\App\RequestFactory::create
  26. */
  27. public function testCreate()
  28. {
  29. $arguments = ['some_key' => 'same_value'];
  30. $appRequest = $this->createMock(\Magento\Framework\App\RequestInterface::class);
  31. $this->objectManagerMock->expects($this->once())
  32. ->method('create')
  33. ->with(\Magento\Framework\App\RequestInterface::class, $arguments)
  34. ->will($this->returnValue($appRequest));
  35. $this->assertEquals($appRequest, $this->model->create($arguments));
  36. }
  37. }