Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PathPatternTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class PathPatternTest extends \PHPUnit\Framework\TestCase
11 {
15  protected $pathPatternHelper;
16 
21 
22  protected function setUp()
23  {
24  $this->objectManagerHelper = new ObjectManagerHelper($this);
25  $this->pathPatternHelper = $this->objectManagerHelper->getObject(
26  \Magento\Framework\View\Helper\PathPattern::class
27  );
28  }
29 
36  public function testTranslatePatternFromGlob($path, $expectedPattern)
37  {
38  $this->assertEquals($expectedPattern, $this->pathPatternHelper->translatePatternFromGlob($path));
39  }
40 
45  {
46  return [
47  [
48  'path' => '*.xml',
49  'expectedPattern' => '[^/]*\\.xml'
50  ],
51  [
52  'path' => 'd??.*',
53  'expectedPattern' => 'd[^/][^/]\\.[^/]*'
54  ],
55  [
56  'path' => '[!0-9]?-[a-fA-F0-9].php',
57  'expectedPattern' => '[^0-9][^/]\\-[a-fA-F0-9]\\.php'
58  ],
59  [
60  'path' => 'config.{php,json,xml}',
61  'expectedPattern' => 'config\\.(?:php|json|xml)'
62  ],
63  [
64  'path' => 'c?nf[aio]g{-,}[!0-9/]*.{p,}html',
65  'expectedPattern' => 'c[^/]nf[aio]g(?:\\-|)[^0-9/][^/]*\\.(?:p|)html'
66  ]
67  ];
68  }
69 }