eZ\Publish\Core\Persistence\Legacy\Tests\Content\UrlAliasHandlerTest::testPublishUrlAliasReuseNopCleanupCustomAliasIsDestroyed PHP Метод

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

Test for the publishUrlAliasForLocation() method.
    public function testPublishUrlAliasReuseNopCleanupCustomAliasIsDestroyed()
    {
        $handler = $this->getHandler();
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_cleanup_nop.php');
        $handler->lookup('nop-element/search');
        $handler->publishUrlAliasForLocation(314, 2, 'nop-element', 'cro-HR', false);
        $urlAlias = $handler->lookup('jedan');
        $this->assertEquals(new UrlAlias(array('id' => '0-' . md5('jedan'), 'type' => UrlAlias::LOCATION, 'destination' => 314, 'pathData' => array(array('always-available' => false, 'translations' => array('cro-HR' => 'jedan'))), 'languageCodes' => array('cro-HR'), 'alwaysAvailable' => false, 'isHistory' => true, 'isCustom' => false, 'forward' => false)), $urlAlias);
        $urlAlias = $handler->lookup('nop-element');
        $this->assertEquals(new UrlAlias(array('id' => '0-' . md5('nop-element'), 'type' => UrlAlias::LOCATION, 'destination' => 314, 'pathData' => array(array('always-available' => false, 'translations' => array('cro-HR' => 'nop-element', 'eng-GB' => 'dva'))), 'languageCodes' => array('cro-HR'), 'alwaysAvailable' => false, 'isHistory' => false, 'isCustom' => false, 'forward' => false)), $urlAlias);
        try {
            $handler->lookup('nop-element/search');
            $this->fail('Custom alias is not destroyed');
        } catch (NotFoundException $e) {
            // Custom alias is destroyed by reusing NOP entry with existing autogenerated alias
            // on the same level (that means link and ID are updated to the existing alias ID,
            // so custom alias children entries are no longer properly linked (parent-link))
        }
    }
UrlAliasHandlerTest