public function testSetAlias() { $path = '/fake/path'; Autoload::setAlias('FakePath1', $path); Autoload::setAlias('FakePath2', []); static::assertEquals(Autoload::getAlias('FakePath1'), $path); static::assertEquals(Autoload::getAlias('FakePath2'), false); }
/** * Get view file * * @access private * * @param string $view view file name * * @return string * @throws Exception */ private function getViewFile($view) { $calledClass = $this->path; // Calculate path to view if (0 === strpos($calledClass, 'App')) { $path = (new KernelInjector())->build()->getAppDir(); } else { $path = Autoload::getAlias('Micro'); } $cl = strtolower(dirname(str_replace('\\', '/', $calledClass))); $cl = substr($cl, strpos($cl, '/')); if ($this->asWidget) { $path .= $cl . '/views/' . $view . '.php'; } else { $className = str_replace('controller', '', strtolower(basename(str_replace('\\', '/', '/' . $this->path)))); $path .= dirname($cl) . '/views/' . $className . '/' . $view . '.php'; } $path = str_replace('//', '/', $path); if (!file_exists($path)) { throw new Exception('View path `' . $path . '` not exists.'); } return $path; }