AcControllerResourceTest::testShouldLoadResourceThroughTheCustomAssociationName PHP Метод

testShouldLoadResourceThroughTheCustomAssociationName() публичный Метод

Should load resource through the custom association name
    public function testShouldLoadResourceThroughTheCustomAssociationName()
    {
        $this->params = array_merge($this->params, array_merge(['action' => 'show', 'id' => '123']));
        $category = $this->mock('Category');
        $this->setProperty($this->controller, 'category', $category);
        $project = $this->mock('Project');
        $category->shouldReceive('customProjects->getModel')->once()->andReturn($project);
        $project->shouldReceive('where')->with('id', '123')->once()->andReturn($queryBuilder = m::mock());
        $queryBuilder->shouldReceive('firstOrFail')->once()->andReturn('some_project');
        $resource = new Efficiently\AuthorityController\ControllerResource($this->controller, ['through' => 'category', 'throughAssociation' => 'customProjects']);
        $resource->loadResource();
        $this->assertEquals($this->getProperty($this->controller, 'project'), 'some_project');
    }
AcControllerResourceTest