‪TYPO3CMS  10.4
ExtensionServiceTest.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 
20 use Prophecy\Argument;
27 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
28 
29 class ‪ExtensionServiceTest extends FunctionalTestCase
30 {
34  protected ‪$testExtensionsToLoad = ['typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example'];
35 
39  protected ‪$coreExtensionsToLoad = ['extbase', 'fluid'];
40 
44  protected ‪$extensionService;
45 
50 
54  protected ‪$objectManager;
55 
59  protected ‪$environmentService;
60 
61  protected function ‪setUp(): void
62  {
63  parent::setUp();
64 
65  $this->environmentService = $this->prophesize(EnvironmentService::class);
66  $this->environmentService->isEnvironmentInFrontendMode()->willReturn(true);
67  $this->environmentService->isEnvironmentInBackendMode()->willReturn(false);
68 
69  $this->frontendConfigurationManager = $this->prophesize(FrontendConfigurationManager::class);
70 
71  $this->objectManager = $this->prophesize(ObjectManagerInterface::class);
72 
73  $this->extensionService = new ‪ExtensionService();
74  }
75 
80  {
81  $this->frontendConfigurationManager->getConfiguration(Argument::cetera())->willReturn([]);
82  $this->objectManager->get(Argument::any())->willReturn($this->frontendConfigurationManager->reveal());
83  $configurationManager = new ‪ConfigurationManager(
84  $this->objectManager->reveal(),
85  $this->environmentService->reveal()
86  );
87  $this->extensionService->injectConfigurationManager($configurationManager);
88 
89  $pluginName = $this->extensionService->getPluginNameByAction('BlogExample', 'Blog', 'testForm');
90 
91  self::assertSame('Blogs', $pluginName);
92  }
93 
98  {
99  $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Service/Fixtures/tt_content_with_single_plugin.xml');
100 
101  $this->frontendConfigurationManager->getConfiguration(Argument::cetera())->willReturn(['view' => ['defaultPid' => 'auto']]);
102  $this->objectManager->get(Argument::any())->willReturn($this->frontendConfigurationManager->reveal());
103  $configurationManager = new ‪ConfigurationManager(
104  $this->objectManager->reveal(),
105  $this->environmentService->reveal()
106  );
107  $this->extensionService->injectConfigurationManager($configurationManager);
108 
109  $expectedResult = 321;
110  $result = $this->extensionService->getTargetPidByPlugin('ExtensionName', 'SomePlugin');
111  self::assertEquals($expectedResult, $result);
112  }
113 
118  {
119  $this->frontendConfigurationManager->getConfiguration(Argument::cetera())->willReturn(['view' => ['defaultPid' => 'auto']]);
120  $this->objectManager->get(Argument::any())->willReturn($this->frontendConfigurationManager->reveal());
121  $configurationManager = new ‪ConfigurationManager(
122  $this->objectManager->reveal(),
123  $this->environmentService->reveal()
124  );
125  $this->extensionService->injectConfigurationManager($configurationManager);
126 
127  $result = $this->extensionService->getTargetPidByPlugin('ExtensionName', 'SomePlugin');
128  self::assertNull($result);
129  }
130 
135  {
136  $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Service/Fixtures/tt_content_with_two_plugins.xml');
137  $this->frontendConfigurationManager->getConfiguration(Argument::cetera())->willReturn(['view' => ['defaultPid' => 'auto']]);
138  $this->objectManager->get(Argument::any())->willReturn($this->frontendConfigurationManager->reveal());
139  $configurationManager = new ‪ConfigurationManager(
140  $this->objectManager->reveal(),
141  $this->environmentService->reveal()
142  );
143  $this->extensionService->injectConfigurationManager($configurationManager);
144 
145  $this->expectException(Exception::class);
146  $this->expectExceptionCode(1280773643);
147  $this->extensionService->getTargetPidByPlugin('ExtensionName', 'SomePlugin');
148  }
149 }
‪TYPO3\CMS\Extbase\Tests\Functional\Service\ExtensionServiceTest
Definition: ExtensionServiceTest.php:30
‪TYPO3\CMS\Extbase\Tests\Functional\Service\ExtensionServiceTest\$objectManager
‪Prophecy Prophecy ObjectProphecy ObjectManagerInterface $objectManager
Definition: ExtensionServiceTest.php:49
‪TYPO3\CMS\Extbase\Tests\Functional\Service\ExtensionServiceTest\getTargetPidByPluginSignatureDeterminesTheTargetPidIfDefaultPidIsAuto
‪getTargetPidByPluginSignatureDeterminesTheTargetPidIfDefaultPidIsAuto()
Definition: ExtensionServiceTest.php:91
‪TYPO3\CMS\Extbase\Tests\Functional\Service
Definition: ExtensionServiceTest.php:18
‪TYPO3\CMS\Extbase\Tests\Functional\Service\ExtensionServiceTest\$extensionService
‪ExtensionService $extensionService
Definition: ExtensionServiceTest.php:41
‪TYPO3\CMS\Extbase\Tests\Functional\Service\ExtensionServiceTest\getTargetPidByPluginSignatureThrowsExceptionIfMoreThanOneTargetPidsWereFound
‪getTargetPidByPluginSignatureThrowsExceptionIfMoreThanOneTargetPidsWereFound()
Definition: ExtensionServiceTest.php:128
‪TYPO3\CMS\Extbase\Tests\Functional\Service\ExtensionServiceTest\$environmentService
‪Prophecy Prophecy ObjectProphecy EnvironmentService $environmentService
Definition: ExtensionServiceTest.php:53
‪TYPO3\CMS\Extbase\Object\ObjectManagerInterface
Definition: ObjectManagerInterface.php:26
‪TYPO3\CMS\Extbase\Tests\Functional\Service\ExtensionServiceTest\setUp
‪setUp()
Definition: ExtensionServiceTest.php:55
‪TYPO3\CMS\Extbase\Exception
Definition: Exception.php:26
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager
Definition: ConfigurationManager.php:33
‪TYPO3\CMS\Extbase\Configuration\FrontendConfigurationManager
Definition: FrontendConfigurationManager.php:35
‪TYPO3\CMS\Extbase\Tests\Functional\Service\ExtensionServiceTest\$testExtensionsToLoad
‪array $testExtensionsToLoad
Definition: ExtensionServiceTest.php:33
‪TYPO3\CMS\Extbase\Tests\Functional\Service\ExtensionServiceTest\getTargetPidByPluginSignatureReturnsNullIfTargetPidCouldNotBeDetermined
‪getTargetPidByPluginSignatureReturnsNullIfTargetPidCouldNotBeDetermined()
Definition: ExtensionServiceTest.php:111
‪TYPO3\CMS\Extbase\Service\EnvironmentService
Definition: EnvironmentService.php:27
‪TYPO3\CMS\Extbase\Tests\Functional\Service\ExtensionServiceTest\getPluginNameByActionDetectsPluginNameFromGlobalExtensionConfigurationArray
‪getPluginNameByActionDetectsPluginNameFromGlobalExtensionConfigurationArray()
Definition: ExtensionServiceTest.php:73
‪TYPO3\CMS\Extbase\Service\ExtensionService
Definition: ExtensionService.php:33
‪TYPO3\CMS\Extbase\Tests\Functional\Service\ExtensionServiceTest\$frontendConfigurationManager
‪Prophecy Prophecy ObjectProphecy FrontendConfigurationManager $frontendConfigurationManager
Definition: ExtensionServiceTest.php:45
‪TYPO3\CMS\Extbase\Tests\Functional\Service\ExtensionServiceTest\$coreExtensionsToLoad
‪array $coreExtensionsToLoad
Definition: ExtensionServiceTest.php:37