Пример #1
0
 /**
  * @test
  */
 public function it_returns_merged_array_according_array_priorities()
 {
     $defaults = array('k_1' => 'd1', 'k_2' => 'd2', 'k_3' => function () {
         return 'd3';
     });
     $mandatory = array('k_2' => new RawParam('m2'));
     $params = array('k_1' => 'p1', 'k_2' => 'p2');
     $expected = array('k_1' => 'p1', 'k_2' => 'm2', 'k_3' => 'd3');
     $this->resolver->setDefaults($defaults);
     $this->resolver->setMandatory($mandatory);
     $this->assertSame($expected, $this->resolver->resolve($params));
 }
 /** @internal */
 private function findCachedFile($uri, $evaluate)
 {
     // TODO: find better way then this hack.
     // This is required if we keep assets on separate [sub]domain or we use base non-root URL for them.
     $cachedPath = $uri;
     $prefix = preg_quote($this->params->getCachePrefix(), '#');
     $pattern = sprintf('#^((?:[a-z]+:)?//.*?)?(?:/\\w+[.]php)?(/%s.*?)$#i', $prefix);
     if (preg_match($pattern, $uri, $m)) {
         $cachedPath = $m[2];
     }
     $cached = $this->params->getWebRoot() . $cachedPath;
     if (!$evaluate) {
         return $cached;
     }
     return $this->normalizeFilePath($cached);
 }