‪TYPO3CMS  10.4
ProcessorRegistryTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
28 class ‪ProcessorRegistryTest extends UnitTestCase
29 {
30  protected ‪$resetSingletonInstances = true;
31 
36  {
37  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['processors'] = [
38  [
39  'className' => LocalImageProcessor::class,
40  ]
41  ];
42  $subject = new ‪ProcessorRegistry();
43  $taskMock = $this->prophesize(AbstractTask::class);
44  $taskMock->getType()->willReturn('Image');
45  $taskMock->getName()->willReturn('CropScaleMask');
46 
47  $processor = $subject->getProcessorByTask($taskMock->reveal());
48 
49  self::assertInstanceOf(LocalImageProcessor::class, $processor);
50  }
51 
55  public function ‪getProcessorWhenNoneIsRegistered(): void
56  {
57  $this->expectExceptionCode(1560876294);
58 
59  $subject = new ‪ProcessorRegistry();
60  $taskMock = $this->prophesize(AbstractTask::class)->reveal();
61  $subject->getProcessorByTask($taskMock);
62  }
63 
68  {
69  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['processors'] = [
70  'LocalImageProcessor' => [
71  'className' => LocalImageProcessor::class,
72  ],
73  'AnotherLocalImageProcessor' => [
74  'className' => LocalImageProcessor::class,
75  'after' => 'LocalImageProcessor',
76  ],
77  ];
78  $subject = new ‪ProcessorRegistry();
79  $taskMock = $this->prophesize(AbstractTask::class);
80  $taskMock->getType()->willReturn('Image');
81  $taskMock->getName()->willReturn('CropScaleMask');
82 
83  $processor = $subject->getProcessorByTask($taskMock->reveal());
84 
85  self::assertInstanceOf(LocalImageProcessor::class, $processor);
86  }
87 }
‪TYPO3\CMS\Core\Tests\Unit\Resource\Processing\ProcessorRegistryTest\getProcessorWhenNoneIsRegistered
‪getProcessorWhenNoneIsRegistered()
Definition: ProcessorRegistryTest.php:55
‪TYPO3\CMS\Core\Resource\Processing\LocalImageProcessor
Definition: LocalImageProcessor.php:25
‪TYPO3\CMS\Core\Tests\Unit\Resource\Processing\ProcessorRegistryTest\$resetSingletonInstances
‪$resetSingletonInstances
Definition: ProcessorRegistryTest.php:30
‪TYPO3\CMS\Core\Tests\Unit\Resource\Processing
Definition: LocalPreviewHelperTest.php:16
‪TYPO3\CMS\Core\Tests\Unit\Resource\Processing\ProcessorRegistryTest
Definition: ProcessorRegistryTest.php:29
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask
Definition: AbstractTask.php:31
‪TYPO3\CMS\Core\Tests\Unit\Resource\Processing\ProcessorRegistryTest\getProcessorWhenSameProcessorIsRegisteredTwice
‪getProcessorWhenSameProcessorIsRegisteredTwice()
Definition: ProcessorRegistryTest.php:67
‪TYPO3\CMS\Core\Resource\Processing\ProcessorRegistry
Definition: ProcessorRegistry.php:28
‪TYPO3\CMS\Core\Tests\Unit\Resource\Processing\ProcessorRegistryTest\getProcessorWhenOnlyOneIsRegistered
‪getProcessorWhenOnlyOneIsRegistered()
Definition: ProcessorRegistryTest.php:35