Bolt\Tests\Controller\FrontendTest::testCanonicalUrlForNumericRecord PHP Method

testCanonicalUrlForNumericRecord() public method

    public function testCanonicalUrlForNumericRecord()
    {
        /** @var \Silex\Application $app */
        $app = $this->getApp();
        $this->setRequest(Request::create('/pages/5'));
        $app['request_context']->fromRequest($this->getRequest());
        $contentType = $app['storage']->getContentType('pages');
        $content1 = new Content($app, $contentType);
        $content1->id = 5;
        $content1['slug'] = 'foo';
        $storage = $this->getMockStorage(['getContent']);
        $app['storage'] = $storage;
        $storage->expects($this->at(0))->method('getContent')->will($this->returnValue(false));
        $storage->expects($this->at(1))->method('getContent')->will($this->returnValue($content1));
        // Route for /page/5 instead of /page/foo
        $this->controller()->record($this->getRequest(), 'pages', 5);
        $this->assertEquals('http://localhost/page/foo', $app['canonical']->getUrl(), 'Canonical url should use record slug instead of record ID');
    }