Skip to content

Commit

Permalink
[TASK] Fix test failures on TYPO3 12.2
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessCoder committed Feb 16, 2023
1 parent 767eb22 commit 1392242
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Tests/Unit/ViewHelpers/LViewHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* LICENSE.md file that was distributed with this source code.
*/

use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Localization\LocalizationFactory;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
Expand All @@ -21,12 +23,24 @@ class LViewHelperTest extends AbstractViewHelperTestCase
{
protected function setUp(): void
{
$languageService = $this->getMockBuilder(LanguageService::class)->disableOriginalConstructor()->getMock();

$cache = $this->getMockBuilder(FrontendInterface::class)->getMockForAbstractClass();
$cache->method('has')->willReturn(true);
$cache->method('get')->willReturn($languageService);

$this->singletonInstances[ConfigurationManagerInterface::class] = $this->getMockBuilder(ConfigurationManagerInterface::class)->getMockForAbstractClass();
$this->singletonInstances[LocalizationFactory::class] = $this->getMockBuilder(LocalizationFactory::class)
->setMethods(['getParsedData'])
->disableOriginalConstructor()
->getMock();
$this->singletonInstances[LocalizationFactory::class]->method('getParsedData')->willReturn([]);
$this->singletonInstances[CacheManager::class] = $this->getMockBuilder(CacheManager::class)
->setMethods(['getCache'])
->disableOriginalConstructor()
->getMock();
$this->singletonInstances[CacheManager::class]->method('getCache')->willReturn($cache);

if (class_exists(ObjectManager::class)) {
$this->singletonInstances[ObjectManager::class] = $this->getMockBuilder(ObjectManager::class)
->setMethods(['get'])
Expand Down
13 changes: 13 additions & 0 deletions Tests/Unit/ViewHelpers/OrViewHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* LICENSE.md file that was distributed with this source code.
*/

use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Localization\LocalizationFactory;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
Expand All @@ -21,11 +23,22 @@ class OrViewHelperTest extends AbstractViewHelperTestCase
{
protected function setUp(): void
{
$languageService = $this->getMockBuilder(LanguageService::class)->disableOriginalConstructor()->getMock();

$cache = $this->getMockBuilder(FrontendInterface::class)->getMockForAbstractClass();
$cache->method('has')->willReturn(true);
$cache->method('get')->willReturn($languageService);

$this->singletonInstances[LocalizationFactory::class] = $this->getMockBuilder(LocalizationFactory::class)
->disableOriginalConstructor()
->getMock();
$this->singletonInstances[LocalizationFactory::class]->method('getParsedData')->willReturn([]);
$this->singletonInstances[ConfigurationManagerInterface::class] = $this->getMockBuilder(ConfigurationManagerInterface::class)->getMockForAbstractClass();
$this->singletonInstances[CacheManager::class] = $this->getMockBuilder(CacheManager::class)
->setMethods(['getCache'])
->disableOriginalConstructor()
->getMock();
$this->singletonInstances[CacheManager::class]->method('getCache')->willReturn($cache);
if (class_exists(ObjectManager::class)) {
$this->singletonInstances[ObjectManager::class] = $this->getMockBuilder(ObjectManager::class)
->setMethods(['get'])
Expand Down

0 comments on commit 1392242

Please sign in to comment.