![]() 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-contact/Test/Unit/Block/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Contact\Test\Unit\Block; use Magento\Contact\Block\ContactForm; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; use Magento\Framework\UrlInterface; use Magento\Framework\View\Element\Template\Context; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; /** * @covers \Magento\Contact\Block\ContactForm */ class ContactFormTest extends TestCase { /** * @var ContactForm */ private $contactForm; /** * @var Context|MockObject */ private $contextMock; /** * @var UrlInterface|MockObject */ private $urlBuilderMock; /** * {@inheritDoc} */ protected function setUp(): void { $this->contextMock = $this->getMockBuilder(Context::class) ->disableOriginalConstructor() ->setMethods(['getUrlBuilder']) ->getMock(); $this->urlBuilderMock = $this->getMockBuilder(UrlInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->contextMock->expects($this->any()) ->method('getUrlBuilder') ->willReturn($this->urlBuilderMock); $this->contactForm = (new ObjectManagerHelper($this))->getObject( ContactForm::class, [ 'context' => $this->contextMock ] ); } /** * Test isScopePrivate() */ public function testScope(): void { $this->assertTrue($this->contactForm->isScopePrivate()); } /** * Test get form action */ public function testGetFormAction(): void { $this->urlBuilderMock->expects($this->once()) ->method('getUrl') ->with('contact/index/post', ['_secure' => true]); $this->contactForm->getFormAction(); } }