$jsonc = JSONConverter::create(); $root = Dir::factoryTS(__DIR__)->sub('../'); $json = $root->getFile($input->getArgument('file'))->getContents(); $json = '[' . str_replace('}{', '},{', $json) . ']'; try { $report = $jsonc->parse($json); } catch (\Webforge\Common\JS\JSONParsingException $e) { $parser = new JsonParser(); $parsingException = $parser->lint($root->getFile('output.json')->getContents()); throw $parsingException; } $toRun = array(); foreach ($report as $event) { if ($event->event === 'test' && ($event->status === 'fail' || $event->status === 'error')) { $testFQN = $event->suite; $file = Code::mapClassToFile($testFQN, $root->sub('tests/')); $file->getDirectory()->resolvePath(); $toRun[(string) $file] = (string) $file; } } $toRun = array_filter($toRun); $output->writeln(count($toRun) . ' tests have failed'); $root->getFile('to-run.json')->writeContents($jsonc->stringify($toRun)); }); $createCommand('tests:to-run', array(), function ($input, $output, $command) { $jsonc = JSONConverter::create(); $root = Dir::factoryTS(__DIR__)->sub('../'); $toRun = (array) $jsonc->parseFile($root->getFile('to-run.json')); $leftToRun = array(); foreach ($toRun as $filename) { $leftToRun[] = $filename;
/** * @return Webforge\Common\System\File */ public function getTestFile() { /* zuerst setzen wir den ns in einen relativen pfad um */ $file = Code::mapClassToFile($this->class->getName(), NULL); /* entfernt das erste und zweite verzeichnis (das erste ist der .)*/ $file->getDirectory()->slice(2); /* wir fügen den rest des relativen Verzeichnisses an das tests-Verzeichnis an */ $dir = clone $this->dir; $dir->append($file->getDirectory()); $file = new File($dir, $this->class->getClassName() . 'Test'); $file->setExtension('.php'); return $file; }
/** * @return File */ public function getClassFile($className) { if ($className instanceof GClass) { $className = $className->getFQN(); } return Code::mapClassToFile($className, $this->getClassPath()->up()); }
/** * @return File */ public function writeRepository(File $file = NULL, $overwrite = NULL) { $gClass = $this->getRepositoryGClass(); $this->classWriter->setClass($gClass); if (!isset($file)) { $autoLoadRoot = $this->module->getEntitiesPath()->sub(str_repeat('../', count(explode('\\', $this->module->getEntitiesNamespace()))))->resolvePath(); $file = Code::mapClassToFile($gClass->getFQN(), $autoLoadRoot); } $this->classWriter->write($file, array(), $overwrite); $this->classWriter->syntaxCheck($file); return $file; }
/** * @depends testNamespaceToPath_withoutDirParam */ public function testMapClassToFile_withoutDirParam() { $ds = DIRECTORY_SEPARATOR; $this->assertEquals(getcwd() . $ds . 'Psc' . $ds . 'Code' . $ds . 'Generate' . $ds . 'myClass.php', (string) Code::mapClassToFile('\\Psc\\Code\\Generate\\myClass')->resolvePath()); }