예제 #1
0
 /** @test */
 function it_destroys_a_field_from_a_source_table()
 {
     $model = $this->prophesize('Nuclear\\Hierarchy\\Contract\\NodeTypeContract');
     $collection = new Collection();
     $model->getFields()->willReturn($collection)->shouldBeCalled();
     $modelBuilder = $this->prophesize('Nuclear\\Hierarchy\\Contract\\Builders\\ModelBuilderContract');
     $modelBuilder->build('project', $collection)->willReturn(null)->shouldBeCalled();
     $model->getFields()->willReturn($collection)->shouldBeCalled();
     $formBuilder = $this->prophesize('Nuclear\\Hierarchy\\Contract\\Builders\\FormBuilderContract');
     $formBuilder->build('project', $collection)->willReturn(null)->shouldBeCalled();
     $migrationBuilder = $this->prophesize('Nuclear\\Hierarchy\\Contract\\Builders\\MigrationBuilderContract');
     $migrationBuilder->getMigrationClassPathByKey('project', 'description')->willReturn('TestMigration')->shouldBeCalled();
     $migrationBuilder->destroyFieldMigrationForTable('description', 'project')->shouldBeCalled();
     $service = new BuilderService($modelBuilder->reveal(), $migrationBuilder->reveal(), $formBuilder->reveal());
     // At this time it is kind of impossible
     // to test if the migration did run like we do
     // in the build tests since it quits before reaching
     // the destroyFieldMigrationForTable method
     // We assume if the destroyFieldMigrationForTable is
     // called, the method reached to the end without any problem
     $service->destroyField('description', 'project', $model->reveal());
 }