![]() 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-cms/Test/Unit/Controller/Page/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Cms\Test\Unit\Controller\Page; use Magento\Cms\Controller\Adminhtml\Page\PostDataProcessor; use Magento\Framework\Message\ManagerInterface; use Magento\Framework\Stdlib\DateTime\Filter\Date; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Framework\View\Model\Layout\Update\ValidatorFactory; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class PostDataProcessorTest extends TestCase { /** * @var Date|MockObject */ protected $dateFilterMock; /** * @var ManagerInterface|MockObject */ protected $messageManagerMock; /** * @var ValidatorFactory|MockObject */ protected $validatorFactoryMock; /** * @var PostDataProcessor */ protected $postDataProcessor; protected function setUp(): void { $this->dateFilterMock = $this->getMockBuilder(Date::class) ->disableOriginalConstructor() ->getMock(); $this->messageManagerMock = $this->getMockBuilder(ManagerInterface::class) ->getMockForAbstractClass(); $this->validatorFactoryMock = $this->getMockBuilder(ValidatorFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->postDataProcessor = (new ObjectManager($this))->getObject( PostDataProcessor::class, [ 'dateFilter' => $this->dateFilterMock, 'messageManager' => $this->messageManagerMock, 'validatorFactory' => $this->validatorFactoryMock ] ); } public function testValidateRequireEntry() { $postData = [ 'title' => '' ]; $this->messageManagerMock->expects($this->once()) ->method('addErrorMessage') ->with(__('To apply changes you should fill in hidden required "%1" field', 'Page Title')); $this->assertFalse($this->postDataProcessor->validateRequireEntry($postData)); } public function testFilter() { $this->assertSame(['key' => 'value'], $this->postDataProcessor->filter(['key' => 'value'])); } }