Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RedirectFactoryTest.php
Go to the documentation of this file.
1 <?php
10 
12 
13 class RedirectFactoryTest extends \PHPUnit\Framework\TestCase
14 {
16  private $model;
17 
19  private $objectManagerMock;
20 
21  protected function setUp()
22  {
23  $objectManager = new ObjectManager($this);
24  $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
25  $this->model = $objectManager->getObject(
26  \Magento\Framework\Controller\Result\RedirectFactory::class,
27  ['objectManager' => $this->objectManagerMock]
28  );
29  }
30 
31  public function testCreate()
32  {
33  $redirect = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class)
34  ->disableOriginalConstructor()
35  ->getMock();
36 
37  $this->objectManagerMock->expects($this->once())->method('create')
38  ->willReturn($redirect);
39 
40  $resultRedirect = $this->model->create();
41  $this->assertInstanceOf(\Magento\Framework\Controller\Result\Redirect::class, $resultRedirect);
42  $this->assertSame($redirect, $resultRedirect);
43  }
44 }
$objectManager
Definition: bootstrap.php:17