Example #1
0
 public function test_get_form_with_instance()
 {
     $this->generatorMock->shouldReceive('setModelFields', 'setRelatedModelFields')->atLeast()->once();
     $this->generatorMock->shouldReceive('getForm')->atLeast()->once()->andReturn($this->mock('FormManager\\ElementInterface'));
     $this->dbalMock->shouldReceive('getTableColumns')->once()->andReturn(['id' => $this->columnMock, 'username' => $this->columnMock, 'password' => $this->columnMock, 'image' => $this->columnMock]);
     $this->dbalMock->shouldReceive('getTableForeignKeys')->andReturn([]);
     $this->dbalMock->shouldReceive('getModel')->andReturn($this->dbalMock);
     $this->dbalMock->shouldReceive('getKeyName')->andReturn(LaravelModel::CREATED_AT, LaravelModel::UPDATED_AT);
     $this->relationFactoryMock->shouldReceive('setModel')->andReturn($this->relationFactoryMock);
     $this->relationFactoryMock->shouldReceive('setConfig')->andReturn($this->relationFactoryMock);
     $this->relationFactoryMock->shouldReceive('get')->andReturn($relationMock = $this->mock('\\Anavel\\Crud\\Abstractor\\Eloquent\\Relation\\Relation'));
     $relationMock->shouldReceive('getSecondaryRelations')->andReturn(collect());
     $this->fieldFactoryMock->shouldReceive('setColumn', 'setConfig')->andReturn($this->fieldFactoryMock);
     $this->fieldFactoryMock->shouldReceive('get')->andReturn($this->mock('Anavel\\Crud\\Abstractor\\Eloquent\\Field'));
     $modelMock = $this->mock('Illuminate\\Database\\Eloquent\\Model');
     $modelMock->shouldReceive('getAttribute');
     $this->sut->setInstance($modelMock);
     $form = $this->sut->getForm('crudoado.model.store', 'users');
     $this->assertInstanceOf('FormManager\\ElementInterface', $form);
 }