Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UrnResolverTest.php
Go to the documentation of this file.
1 <?php
7 
10 
11 class UrnResolverTest extends \PHPUnit\Framework\TestCase
12 {
16  protected $urnResolver;
17 
22 
23  protected function setUp()
24  {
25  $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
26  $this->urnResolver = $this->objectManagerHelper->getObject(\Magento\Framework\Config\Dom\UrnResolver::class);
27  }
28 
29  public function testGetRealPathNoUrn()
30  {
31  $xsdPath = '../../testPath/test.xsd';
32  $result = $this->urnResolver->getRealPath($xsdPath);
33  $this->assertSame($xsdPath, $result, 'XSD paths does not match.');
34  }
35 
37  {
38  $xsdUrn = 'urn:magento:framework:Config/Test/Unit/_files/sample.xsd';
39  $xsdPath = str_replace('\\', '/', realpath(dirname(__DIR__)) . '/_files/sample.xsd');
40  $result = $this->urnResolver->getRealPath($xsdUrn);
41  $this->assertSame($xsdPath, $result, 'XSD paths does not match.');
42  }
43 
44  public function testGetRealPathWithModuleUrn()
45  {
46  $xsdUrn = 'urn:magento:module:Magento_Customer:etc/address_formats.xsd';
48  $xsdPath = $componentRegistrar->getPath(ComponentRegistrar::MODULE, 'Magento_Customer')
49  . '/etc/address_formats.xsd';
50 
51  $result = $this->urnResolver->getRealPath($xsdUrn);
52  $this->assertSame($xsdPath, $result, 'XSD paths does not match.');
53  }
54 
55  public function testGetRealPathWithSetupUrn()
56  {
57  $xsdUrn = 'urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd';
59  $xsdPath = $componentRegistrar->getPath(ComponentRegistrar::LIBRARY, 'magento/framework')
60  . '/Setup/Declaration/Schema/etc/schema.xsd';
61 
62  $result = $this->urnResolver->getRealPath($xsdUrn);
63  $this->assertSame($xsdPath, $result, 'XSD paths does not match.');
64  }
65 
70  public function testGetRealPathWrongSection()
71  {
72  $xsdUrn = 'urn:magento:test:test:etc/test_test.xsd';
73  $this->urnResolver->getRealPath($xsdUrn);
74  }
75 
80  public function testGetRealPathWrongModule()
81  {
82  $xsdUrn = 'urn:magento:module:Magento_Test:test.xsd';
83  $this->urnResolver->getRealPath($xsdUrn);
84  }
85 }
$componentRegistrar
Definition: bootstrap.php:23
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60