Illuminate\Routing\AcParametersTest::testExtractResourceAndParentResourceIdsFromRequest PHP Метод

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

    public function testExtractResourceAndParentResourceIdsFromRequest()
    {
        $parameters = $this->parameters;
        Route::get('users/{id}', ['as' => 'users.show', 'uses' => 'UsersController@show']);
        // user show action
        $controllerName = "PostsController";
        Route::get('users/{user_id}/posts/{id}', ['as' => 'users.posts.show', 'uses' => 'PostsController@show']);
        // post show action
        $controller = $this->mockController($controllerName);
        $this->call('GET', '/users/7/posts/3');
        // show action of post resource
        $this->assertArrayHasKey('user_id', $this->getProperty($parameters, 'params'));
        $this->assertEquals($this->getProperty($parameters, 'params')['user_id'], '7');
        $this->assertArrayHasKey('user_id', $this->getProperty($controller, 'params'));
        $this->assertEquals($this->getProperty($controller, 'params')['user_id'], '7');
        $this->assertArrayHasKey('id', $this->getProperty($parameters, 'params'));
        $this->assertEquals($this->getProperty($parameters, 'params')['id'], '3');
        $this->assertArrayHasKey('id', $this->getProperty($controller, 'params'));
        $this->assertEquals($this->getProperty($controller, 'params')['id'], '3');
    }