Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
GenericSchemaLocatorTest.php
Go to the documentation of this file.
1 <?php
8 
11 use Magento\Framework\Module\Dir\Reader as ModuleDirReader;
12 
16 class GenericSchemaLocatorTest extends \PHPUnit\Framework\TestCase
17 {
21  private $testSchemaFileName = 'test-example.xsd';
22 
26  private $schemaLocator;
27 
31  private $moduleReaderMock;
32 
40  private function createNewSchemaLocatorInstance(ModuleDirReader $reader, $moduleName, $mergeSchema, $perFileSchema)
41  {
42  return new GenericSchemaLocator($reader, $moduleName, $mergeSchema, $perFileSchema);
43  }
44 
45  protected function setUp()
46  {
47  $this->moduleReaderMock = $this->createMock(ModuleDirReader::class);
48  $this->schemaLocator = $this->createNewSchemaLocatorInstance(
49  $this->moduleReaderMock,
50  'Test_ModuleName',
51  $this->testSchemaFileName,
52  null
53  );
54  }
55 
57  {
58  $this->assertInstanceOf(SchemaLocatorInterface::class, $this->schemaLocator);
59  }
60 
62  {
63  $this->moduleReaderMock->expects($this->any())->method('getModuleDir')->willReturn('....');
64  $this->assertSame('..../' . $this->testSchemaFileName, $this->schemaLocator->getSchema());
65  }
66 
68  {
69  $this->assertNull($this->schemaLocator->getPerFileSchema());
70  }
71 
73  {
74  $this->moduleReaderMock->expects($this->any())->method('getModuleDir')->willReturn('....');
75  $schemaLocator = $this->createNewSchemaLocatorInstance(
76  $this->moduleReaderMock,
77  'Test_ModuleName',
78  'some other file name',
79  $this->testSchemaFileName
80  );
81  $this->assertSame('..../' . $this->testSchemaFileName, $schemaLocator->getPerFileSchema());
82  }
83 }