public function testShouldNotBuildRecordThroughHasOneAssociationWithSingletonOptionBecauseItCanCauseItToDeleteItInTheDatabase()
{
$this->params = array_merge($this->params, array_merge(['action' => 'store', 'project' => ['name' => 'foobar']]));
$category = $this->mock('Category');
$this->setProperty($this->controller, 'category', $category);
$project = $this->buildModel('Project');
$project->shouldReceive('category->associate')->with($category)->once()->andReturnUsing(function () use($category, $project) {
$project->category = $category;
return $project;
});
$resource = new Efficiently\AuthorityController\ControllerResource($this->controller, ['through' => 'category', 'singleton' => true]);
$resource->loadResource();
$this->assertEquals($this->getProperty($this->controller, 'project')->name, 'foobar');
$this->assertEquals($this->getProperty($this->controller, 'project')->category, $category);
}