![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-robots/Test/Unit/Controller/Index/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Robots\Test\Unit\Controller\Index; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Framework\View\Result\Page; use Magento\Framework\View\Result\PageFactory; use Magento\Robots\Controller\Index\Index; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class IndexTest extends TestCase { /** * @var Index */ private $controller; /** * @var PageFactory|MockObject */ private $resultPageFactoryMock; protected function setUp(): void { $this->resultPageFactoryMock = $this->getMockBuilder(PageFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $objectManager = new ObjectManager($this); $this->controller = $objectManager->getObject( Index::class, [ 'resultPageFactory' => $this->resultPageFactoryMock ] ); } /** * Check the basic flow of execute() method */ public function testExecute() { $resultPageMock = $this->getMockBuilder(Page::class) ->disableOriginalConstructor() ->getMock(); $resultPageMock->expects($this->once()) ->method('addHandle') ->with('robots_index_index'); $resultPageMock->expects($this->once()) ->method('setHeader') ->with('Content-Type', 'text/plain'); $this->resultPageFactoryMock->method('create') ->with(true) ->willReturn($resultPageMock); $this->assertInstanceOf( Page::class, $this->controller->execute() ); } }