/** * @param array $models * @param string $message * @return bool */ private function writeModelFiles(array $models, $message) { $targetDirectory = $this->getParam('target-dir'); $numberOfMissingModels = count($models); if ($numberOfMissingModels > 0) { $this->modelGenerator->writeMissingModelFiles($this->schema, $targetDirectory); $this->outputWriter->writeLine($message . $numberOfMissingModels, OutputWriterInterface::LEVEL_LESS_INFO); return true; } return false; }
/** * @param string[] $expectedNotExistingModels * @dataProvider provideIteration */ public function testCreateNeededModels(array $expectedNotExistingModels) { $schema = $this->getSchema(); $missingModels = $this->modelGenerator->getMissingModels($schema, self::$targetDirectory); $formatter = $this->getFormatter(); $this->assertEquals($expectedNotExistingModels, $missingModels, '', 0, 10, true); $fileNames = array(); $modelFileNames = array(); foreach ($missingModels as $missingModel) { $fileName = $formatter->getTargetFileName($missingModel, self::$targetDirectory); $this->assertFileNotExists($fileName); $fileNames[] = $fileName; $modelFileNames[$fileName] = $missingModel; } // create files $this->modelGenerator->writeMissingModelFiles($schema, self::$targetDirectory); // check created foreach ($fileNames as $fileName) { $this->assertFileExists($fileName); $classContent = $this->modelGenerator->getContent($modelFileNames[$fileName], $schema); $this->assertStringEqualsFile($fileName, $classContent); } }