Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PathValidatorTest.php
Go to the documentation of this file.
1 <?php
8 
11 use PHPUnit_Framework_MockObject_MockObject as Mock;
12 
18 class PathValidatorTest extends \PHPUnit\Framework\TestCase
19 {
23  private $model;
24 
28  private $structureMock;
29 
33  protected function setUp()
34  {
35  $this->structureMock = $this->getMockBuilder(Structure::class)
36  ->disableOriginalConstructor()
37  ->getMock();
38 
39  $this->model = new PathValidator(
40  $this->structureMock
41  );
42  }
43 
44  public function testValidate()
45  {
46  $this->structureMock->expects($this->once())
47  ->method('getFieldPaths')
48  ->willReturn([
49  'test/test/test' => [
50  'test/test/test'
51  ]
52  ]);
53 
54  $this->assertTrue($this->model->validate('test/test/test'));
55  }
56 
61  public function testValidateWithException()
62  {
63  $this->structureMock->expects($this->once())
64  ->method('getFieldPaths')
65  ->willReturn([]);
66 
67  $this->assertTrue($this->model->validate('test/test/test'));
68  }
69 }