Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PdfConfigFilesTest.php
Go to the documentation of this file.
1 <?php
7 
8 class PdfConfigFilesTest extends \PHPUnit\Framework\TestCase
9 {
14  public function testFileFormat($file)
15  {
18  \Magento\Sales\Model\Order\Pdf\Config\SchemaLocator::class
19  );
20  $schemaFile = $schemaLocator->getPerFileSchema();
21 
22  $validationStateMock = $this->createMock(\Magento\Framework\Config\ValidationStateInterface::class);
23  $validationStateMock->method('isValidationRequired')
24  ->willReturn(true);
25  $dom = new \Magento\Framework\Config\Dom(file_get_contents($file), $validationStateMock);
26  $result = $dom->validate($schemaFile, $errors);
27  $this->assertTrue($result, print_r($errors, true));
28  }
29 
33  public function fileFormatDataProvider()
34  {
35  return \Magento\Framework\App\Utility\Files::init()->getConfigFiles('pdf.xml');
36  }
37 
38  public function testMergedFormat()
39  {
40  $validationState = $this->createMock(\Magento\Framework\Config\ValidationStateInterface::class);
41  $validationState->expects($this->any())->method('isValidationRequired')->will($this->returnValue(true));
42 
45  \Magento\Sales\Model\Order\Pdf\Config\Reader::class,
46  ['validationState' => $validationState]
47  );
48  try {
49  $reader->read();
50  } catch (\Exception $e) {
51  $this->fail('Merged pdf.xml files do not pass XSD validation: ' . $e->getMessage());
52  }
53  }
54 }
$errors
Definition: overview.phtml:9