2 declare(strict_types = 1);
24 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
49 protected function setUp():
void
51 $this->environmentService = $this->createMock(EnvironmentService::class);
52 $resourceFactory = $this->createMock(ResourceFactory::class);
53 $this->subject =
new ImageService($this->environmentService, $resourceFactory);
54 $_SERVER[
'HTTP_HOST'] =
'foo.bar';
62 $reference = $this->getAccessibleMock(FileReference::class, [], [],
'',
false);
63 $file = $this->createMock(File::class);
64 $file->expects($this->once())->method(
'process')->willReturn($this->createMock(ProcessedFile::class));
65 $reference->expects($this->once())->method(
'getOriginalFile')->willReturn($file);
66 $reference->_set(
'file', $file);
68 $this->subject->applyProcessingInstructions($reference, []);
77 'with scheme' => [
'http://foo.bar/img.jpg',
'http://foo.bar/img.jpg'],
78 'scheme relative' => [
'//foo.bar/img.jpg',
'//foo.bar/img.jpg'],
79 'without scheme' => [
'foo.bar/img.jpg',
'/prefix/foo.bar/img.jpg'],
89 $this->environmentService->expects($this->any())->method(
'isEnvironmentInFrontendMode')->willReturn(
true);
91 $GLOBALS[
'TSFE']->absRefPrefix =
'/prefix/';
93 $file = $this->createMock(File::class);
94 $file->expects($this->once())->method(
'getPublicUrl')->willReturn($imageUri);
96 $this->assertSame($expected, $this->subject->getImageUri($file));
105 'with scheme' => [
'http://foo.bar/img.jpg',
'http://foo.bar/img.jpg'],
106 'scheme relative' => [
'//foo.bar/img.jpg',
'http://foo.bar/img.jpg'],
107 'without scheme' => [
'foo.bar/img.jpg',
'http://foo.bar/prefix/foo.bar/img.jpg'],
117 $this->environmentService->expects($this->any())->method(
'isEnvironmentInFrontendMode')->willReturn(
true);
119 $GLOBALS[
'TSFE']->absRefPrefix =
'/prefix/';
121 $file = $this->createMock(File::class);
122 $file->expects($this->once())->method(
'getPublicUrl')->willReturn($imageUri);
124 $this->assertSame($expected, $this->subject->getImageUri($file,
true));