magento2-docker/dev/tests/integration/testsuite/Magento/UrlRewrite/Model/UrlFinderInterfaceTest.php

72 lines
2.2 KiB
PHP
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\UrlRewrite\Model;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
/**
* @magentoDataFixture Magento/UrlRewrite/_files/url_rewrites.php
*/
class UrlFinderInterfaceTest extends \PHPUnit\Framework\TestCase
{
/**
* @var UrlFinderInterface
*/
private $urlFinder;
/**
* @inheritdoc
*/
protected function setUp(): void
{
$this->urlFinder = Bootstrap::getObjectManager()->create(UrlFinderInterface::class);
}
/**
* @dataProvider findOneDataProvider
* @param string $requestPath
* @param string $targetPath
* @param int $redirectType
*/
public function testFindOneByData(string $requestPath, string $targetPath, int $redirectType)
{
$data = [
UrlRewrite::REQUEST_PATH => $requestPath,
];
$urlRewrite = $this->urlFinder->findOneByData($data);
$this->assertEquals($targetPath, $urlRewrite->getTargetPath());
$this->assertEquals($redirectType, $urlRewrite->getRedirectType());
}
/**
* @return array
*/
public function findOneDataProvider(): array
{
return [
['string', 'test_page1', 0],
['string/', 'string', 301],
['string_permanent', 'test_page1', 301],
['string_permanent/', 'test_page1', 301],
['string_temporary', 'test_page1', 302],
['string_temporary/', 'test_page1', 302],
['строка', 'test_page1', 0],
['строка/', 'строка', 301],
[urlencode('строка'), 'test_page2', 0],
[urlencode('строка') . '/', urlencode('строка'), 301],
[ругая_строка', 'test_page1', 302],
[ругая_строка/', 'test_page1', 302],
[urlencode(ругая_строка'), 'test_page1', 302],
[urlencode(ругая_строка') . '/', 'test_page1', 302],
['السلسلة', 'test_page1', 0],
[urlencode('السلسلة'), 'test_page1', 0],
];
}
}