2 declare(strict_types = 1);
28 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
35 'URL with scheme and domain' => [
'https://www.typo3.org',
'https://www.typo3.org'],
36 'URL with scheme and domain and path' => [
'https://www.typo3.org/howdy',
'https://www.typo3.org/howdy'],
37 'URL with scheme and domain and path with trailing slash' => [
'https://www.typo3.org/howdy/',
'https://www.typo3.org/howdy/'],
38 'URL without scheme, but with domain' => [
'www.typo3.org',
'//www.typo3.org'],
39 'URL without scheme, but with domain and path' => [
'www.typo3.org/partner',
'//www.typo3.org/partner'],
40 'URL without scheme, but with domain and path and trailing slash' => [
'www.typo3.org/partner/',
'//www.typo3.org/partner/'],
41 'URL without scheme and domain but with absolute path' => [
'/partner',
'/partner'],
42 'URL without scheme and domain but with absolute path and trailing slash' => [
'/partner/',
'/partner/'],
43 'URL without scheme, domain but with random path receives a scheme divider' => [
'partner/',
'/partner/'],
44 'URL with ID query parameter' => [
'/partner/?id=nice-to-see-you',
'/partner/?id=nice-to-see-you'],
45 'URL with unknown query parameter' => [
'/partner/?in-crime=nice-to-see-you',
'/partner/?in-crime=nice-to-see-you'],
55 $subject =
new Site(
'all-your-base-belongs-to-us', 13, [
59 $this->assertEquals(
new Uri($expected), $subject->getBase());
71 'Language as a regular path segment' => [
72 'https://www.typo3.org',
74 'https://www.typo3.org/en',
76 'Language with two path segments' => [
77 'https://www.typo3.org',
79 'https://www.typo3.org/us/en',
81 'Site base is added to absolute path segment' => [
82 'https://www.typo3.com/microsites/',
84 'https://www.typo3.com/microsites/onboarding/',
86 'Site base is prefixed to absolute path segment' => [
87 'https://www.typo3.com/microsites/',
89 'https://www.typo3.com/microsites/onboarding/',
91 'Language with domain and scheme, do not care about site base' => [
92 'https://www.typo3.org',
93 'https://www.typo3.it',
94 'https://www.typo3.it',
96 'Language with domain but no scheme, do not care about site base' => [
113 $subject =
new Site(
'all-of-base', 13, [
118 'base' => $languageBase,
119 'locale' =>
'it_IT.UTF-8',
123 $this->assertEquals(
new Uri($expected), $subject->getLanguageById(0)->getBase());
131 $subject =
new Site(
'aint-misbehaving', 13, [
136 'errorHandler' =>
'Fluid',
140 'errorContentSource' => 123,
141 'errorHandler' =>
'Page'
145 'errorHandler' =>
'PHP',
146 'errorContentSource' => 123,
147 'errorPhpClassFQCN' => PageContentErrorHandler::class
152 $fluidProphecy = $this->prophesize(FluidPageErrorHandler::class);
153 GeneralUtility::addInstance(FluidPageErrorHandler::class, $fluidProphecy->reveal());
165 $this->expectException(InvalidPageErrorHandlerException::class);
166 $this->expectExceptionCode(1527432330);
167 $this->expectExceptionMessage(
'The configured error handler "' . Random::class .
'" for status code 404 must implement the PageErrorHandlerInterface.');
168 $subject =
new Site(
'aint-misbehaving', 13, [
173 'errorHandler' =>
'PHP',
174 'errorPhpClassFQCN' => Random::class
178 $subject->getErrorHandler(404);
186 $this->expectException(PageErrorHandlerNotConfiguredException::class);
187 $this->expectExceptionCode(1522495914);
188 $this->expectExceptionMessage(
'No error handler given for the status code "404".');
189 $subject =
new Site(
'aint-misbehaving', 13, [
'languages' => []]);
190 $subject->getErrorHandler(404);
198 $this->expectException(PageErrorHandlerNotConfiguredException::class);
199 $this->expectExceptionCode(1522495914);
200 $this->expectExceptionMessage(
'No error handler given for the status code "404".');
201 $subject =
new Site(
'aint-misbehaving', 13, [
206 'errorHandler' =>
'Does it really matter?'
210 $subject->getErrorHandler(404);