private function runGeneratedModelTest($modelName, $modelFile)
 {
     $expected = file_get_contents(__DIR__ . '/model_data/' . $modelFile);
     $parsed = ParsedResult::getSampleParsedObject();
     $models = $parsed['modelList']->all();
     $model = $models[$modelName];
     if (is_null($this->modelGenerator)) {
         $this->modelGenerator = new ModelGenerator();
     }
     $this->assertEquals($expected, $this->modelGenerator->generate($model));
 }
 private function runGeneratedMigrationForTable($modelName, $migrationFile)
 {
     $expected = file_get_contents(__DIR__ . '/data/' . $migrationFile);
     // $parsed = $this->getSampleParsedObject();
     $parsed = ParsedResult::getSampleParsedObject();
     $migrations = $parsed['migrationList']->all();
     $table = $migrations[$modelName];
     if (is_null($this->migrationGenerator)) {
         $this->migrationGenerator = new MigrationGenerator();
     }
     $this->assertEquals($expected, $this->migrationGenerator->generate($table));
 }
Ejemplo n.º 3
0
 public function testPolymorphicRelation()
 {
     $parsed = ParsedResult::getSampleParsedObject();
     $models = $parsed['modelList']->all();
     $user = $models['User'];
     $post = $models['Post'];
     $image = $models['Image'];
     $this->assertTrue($user->hasFunction('images', 'Image', 'mm', 'imageable'));
     $this->assertTrue($post->hasFunction('images', 'Image', 'mm', 'imageable'));
     $this->assertTrue($image->hasFunction('imageable', null, 'mt', 'imageable'));
 }
 private function assertErrorOutput($input, $expectedError)
 {
     try {
         ParsedResult::getParsedOutput($input);
         $this->fail("Error not thrown: " . $expectedError);
     } catch (ParseError $e) {
         $this->assertEquals($expectedError, $e->getMessage());
     }
 }