Commit e4f4bcee authored by Tino Goratsch's avatar Tino Goratsch

reworked and extended the unit tests of the Aliases class

parent 76bfced0
Pipeline #19450973 passed with stages
in 8 minutes and 45 seconds
......@@ -34,12 +34,57 @@ class AliasesTest extends \PHPUnit_Framework_TestCase
$this->aliases = new Aliases($this->modulesMock, $this->seoCacheMock);
}
public function testGetUriAliasNoAliasFound()
/**
* @dataProvider uriAliasDataProvider()
*
* @param string $path
* @param string $uriAlias
* @param bool $emptyOnNoResult
* @param array $expectedAliasCache
*/
public function testGetUriAlias(string $path, string $uriAlias, bool $emptyOnNoResult, array $expectedAliasCache)
{
$this->setUpSeoCacheExpectations([]);
$this->setUpSeoCacheExpectations($expectedAliasCache);
$path = 'foo/bar/baz';
$this->assertEquals('foo/bar/baz/', $this->aliases->getUriAlias($path));
$this->assertEquals($uriAlias, $this->aliases->getUriAlias($path, $emptyOnNoResult));
}
public function uriAliasDataProvider(): array
{
return [
'empty_aliases_cache' => [
'foo/bar/baz',
'foo/bar/baz/',
false,
[],
],
'empty_alias' => [
'foo/bar/baz',
'foo/bar/baz/',
false,
[
'foo/bar/baz/' => [
'alias' => '',
],
],
],
'empty_aliases_cache_empty_on_no_result' => [
'foo/bar/baz',
'',
true,
[],
],
'found_uri_alias' => [
'foo/bar/baz',
'lorem-ipsum-dolor',
true,
[
'foo/bar/baz/' => [
'alias' => 'lorem-ipsum-dolor',
],
],
],
];
}
/**
......@@ -53,26 +98,6 @@ class AliasesTest extends \PHPUnit_Framework_TestCase
->willReturn($expectedReturn);
}
public function testGetUriAliasNoAliasFoundReturnEmpty()
{
$this->setUpSeoCacheExpectations([]);
$path = 'foo/bar/baz';
$this->assertEquals('', $this->aliases->getUriAlias($path, true));
}
public function testGetUriAliasAliasExists()
{
$this->setUpSeoCacheExpectations([
'foo/bar/baz/' => [
'alias' => 'lorem-ipsum-dolor',
],
]);
$path = 'foo/bar/baz';
$this->assertEquals('lorem-ipsum-dolor', $this->aliases->getUriAlias($path));
}
public function testUriAliasExistsNoAliasExists()
{
$this->setUpSeoCacheExpectations([]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment