Update website
This commit is contained in:
parent
4413528994
commit
1d90fbf296
6865 changed files with 1091082 additions and 0 deletions
91
vendor/doctrine/rst-parser/tests/UrlGeneratorTest.php
vendored
Normal file
91
vendor/doctrine/rst-parser/tests/UrlGeneratorTest.php
vendored
Normal file
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Tests\RST;
|
||||
|
||||
use Doctrine\RST\Configuration;
|
||||
use Doctrine\RST\UrlGenerator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class UrlGeneratorTest extends TestCase
|
||||
{
|
||||
public function testGenerateUrlRelative(): void
|
||||
{
|
||||
$configuration = $this->createMock(Configuration::class);
|
||||
|
||||
$urlGenerator = new UrlGenerator($configuration);
|
||||
|
||||
self::assertSame('../index', $urlGenerator->generateUrl('/index', 'subdir/index', ''));
|
||||
self::assertSame('index', $urlGenerator->generateUrl('/subdir/index', 'subdir/index', ''));
|
||||
self::assertSame('subdir/index', $urlGenerator->generateUrl('/subdir/index', 'index', ''));
|
||||
}
|
||||
|
||||
public function testGenerateUrlAbsoluteBaseUrl(): void
|
||||
{
|
||||
$configuration = $this->createMock(Configuration::class);
|
||||
|
||||
$configuration->expects(self::once())
|
||||
->method('isBaseUrlEnabled')
|
||||
->with('path')
|
||||
->willReturn(true);
|
||||
|
||||
$configuration->expects(self::once())
|
||||
->method('getBaseUrl')
|
||||
->willReturn('https://www.domain.com/directory/');
|
||||
|
||||
$urlGenerator = new UrlGenerator($configuration);
|
||||
|
||||
self::assertSame(
|
||||
'https://www.domain.com/directory/path',
|
||||
$urlGenerator->generateUrl('/path', 'path', '')
|
||||
);
|
||||
}
|
||||
|
||||
public function testAbsoluteUrl(): void
|
||||
{
|
||||
$configuration = $this->createMock(Configuration::class);
|
||||
|
||||
$urlGenerator = new UrlGenerator($configuration);
|
||||
|
||||
self::assertSame('/test', $urlGenerator->absoluteUrl('/', '/test'));
|
||||
|
||||
self::assertSame('/test', $urlGenerator->absoluteUrl('/subdir', '/test'));
|
||||
|
||||
self::assertSame('/test', $urlGenerator->absoluteUrl('/', 'test'));
|
||||
|
||||
self::assertSame('/subdir/test', $urlGenerator->absoluteUrl('/subdir', 'test'));
|
||||
}
|
||||
|
||||
public function testRelativeUrl(): void
|
||||
{
|
||||
$configuration = $this->createMock(Configuration::class);
|
||||
|
||||
$urlGenerator = new UrlGenerator($configuration);
|
||||
|
||||
self::assertNull($urlGenerator->relativeUrl(null, ''));
|
||||
|
||||
self::assertSame('://test', $urlGenerator->relativeUrl('://test', ''));
|
||||
|
||||
self::assertSame('test', $urlGenerator->relativeUrl('test', '/'));
|
||||
|
||||
self::assertSame('../../test', $urlGenerator->relativeUrl('/test', '/subdir1/subdir2'));
|
||||
|
||||
self::assertSame('../../subdir1/subdir2/test', $urlGenerator->relativeUrl('/subdir1/subdir2/test', '/subdir1/subdir2'));
|
||||
}
|
||||
|
||||
public function testCanonicalUrl(): void
|
||||
{
|
||||
$configuration = $this->createMock(Configuration::class);
|
||||
|
||||
$urlGenerator = new UrlGenerator($configuration);
|
||||
|
||||
self::assertSame('dir/file', $urlGenerator->canonicalUrl('dir', 'file'));
|
||||
|
||||
self::assertSame('file', $urlGenerator->canonicalUrl('dir', '../file'));
|
||||
|
||||
self::assertSame('dir/file', $urlGenerator->canonicalUrl('dir/subdir', '../file'));
|
||||
|
||||
self::assertSame('file', $urlGenerator->canonicalUrl('dir/subdir', '../../file'));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue