Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ContactFormTest.php
Go to the documentation of this file.
1 <?php
8 
10 
11 class ContactFormTest extends \PHPUnit\Framework\TestCase
12 {
16  protected $contactForm;
17 
21  protected $contextMock;
22 
26  protected $urlBuilderMock;
27 
31  protected function setUp()
32  {
33  $this->contextMock = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class)
34  ->disableOriginalConstructor()
35  ->setMethods(['getUrlBuilder'])
36  ->getMock();
37 
38  $this->urlBuilderMock = $this->getMockBuilder(\Magento\Framework\UrlInterface::class)
39  ->disableOriginalConstructor()
40  ->getMock();
41 
42  $this->contextMock->expects($this->any())
43  ->method('getUrlBuilder')
44  ->willReturn($this->urlBuilderMock);
45 
46  $this->contactForm = new ContactForm(
47  $this->contextMock
48  );
49  }
50 
54  public function testScope()
55  {
56  $this->assertTrue($this->contactForm->isScopePrivate());
57  }
58 
62  public function testGetFormAction()
63  {
64  $this->urlBuilderMock->expects($this->once())
65  ->method('getUrl')
66  ->with('contact/index/post', ['_secure' => true]);
67  $this->contactForm->getFormAction();
68  }
69 }