public function testScan() { $scanner = new Target($this->testDir . DIRECTORY_SEPARATOR . 'Assets'); foreach ($scanner->scan() as $result) { if (!isset($this->expectingScanResult[$result['Name']])) { $this->fail('Incomplete scan result'); return; } $this->assertTrue(static::arrayEquals($this->expectingScanResult[$result['Name']], $result), 'testing: ' . $result['Name']); } }
public function testTags() { $tests = array(); $scanner = new ModuleScanner(__DIR__ . DIRECTORY_SEPARATOR . 'Formated'); $formated = new Formated(array('Analyzer' => array('TolerateInvalid' => true, 'MaxNestingLevel' => 9))); foreach ($scanner->scan() as $file) { $tests[$file['Name']][$file['Prefix']] = $file['Path']; } foreach ($tests as $test) { $data = array(); $render = $formated->parse(file_get_contents($test['Raw'])); foreach (json_decode(file_get_contents($test['Data']), true) as $dataKey => $dataVal) { $render->assign($dataKey, $dataVal); } $this->assertSame(file_get_contents($test['Result']), $render->render()->content()); } }
/** * Run template_import_files hook to get map data * * @return array Return the array of File map */ protected function getMapDataFromHook() { $files = $errors = array(); // Get files from hooks foreach (Framework::summonHook('template_import_paths', array(), $errors) as $hook => $importedPaths) { if (!is_array($importedPaths)) { continue; } foreach ($importedPaths as $path) { $pathScanner = new ModuleScanner($path); foreach ($pathScanner->scan() as $file) { $files[] = $file; } } } return $files; }
/** * Discover components, and import them into Framework * * @param array $paths Path for component scan * @param array $pickedComponents Path for component scan * * @return void */ protected static function pickComponents(array $paths, array &$pickedComponents = array()) { foreach ($paths as $path) { $scanner = new Base\Tool\File\ModuleScanner(Base\Tool\File\PathParser::get($path), static::$cfg['CompMaxSeekDepth']); foreach ($scanner->scan() as $module) { switch ($module['Prefix']) { case 'include': static::$includes[] = $module['Path']; $pickedComponents['Includes'][] = $module['Path']; break; case 'initialize': static::$initializers[] = $module['Path']; $pickedComponents['Initialize'][] = $module['Path']; break; case 'routine': static::$components['Routine'][] = $module['Path']; $pickedComponents['Routine'][] = $module['Path']; break; case 'plugin': static::initPlugin($module['Path']); $pickedComponents['Plugin'][] = $module['Path']; break; case 'class': static::registerScope(ucfirst($module['Name']), $module['Path']); $pickedComponents['Class'][ucfirst($module['Name'])] = $module['Path']; break; default: static::registerScope($module['Name'], $module['Path']); $pickedComponents['Class'][$module['Name']] = $module['Path']; break; } } } }