‪TYPO3CMS  10.4
UpdateExtensionListTaskTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
24 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
25 
29 class ‪UpdateExtensionListTaskTest extends UnitTestCase
30 {
34  protected ‪$resetSingletonInstances = true;
35 
40  {
41  $taskMock = $this->getMockBuilder(UpdateExtensionListTask::class)->disableOriginalConstructor()->getMock();
42  self::assertInstanceOf(AbstractTask::class, $taskMock);
43  }
44 
49  {
50  $repositoryHelper = $this->createMock(Helper::class);
51  $repositoryHelper
52  ->expects(self::once())
53  ->method('updateExtList');
54 
55  $objectManagerMock = $this->createMock(ObjectManager::class);
56  $objectManagerMock
57  ->expects(self::at(0))
58  ->method('get')
59  ->with(Helper::class)
60  ->willReturn($repositoryHelper);
61 
62  $persistenceManagerMock = $this->getMockBuilder(PersistenceManager::class)->disableOriginalConstructor()->getMock();
63  $objectManagerMock
64  ->expects(self::at(1))
65  ->method('get')
66  ->willReturn($persistenceManagerMock);
67 
68  GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerMock);
69 
70  $task = $this->getMockBuilder(UpdateExtensionListTask::class)
71  ->setMethods(['dummy'])
72  ->disableOriginalConstructor()
73  ->getMock();
74  $task->execute();
75  }
76 
81  {
82  $repositoryHelper = $this->createMock(Helper::class);
83  $objectManagerMock = $this->createMock(ObjectManager::class);
84  $objectManagerMock
85  ->expects(self::at(0))
86  ->method('get')
87  ->with(Helper::class)
88  ->willReturn($repositoryHelper);
89 
90  $persistenceManagerMock = $this->getMockBuilder(PersistenceManager::class)->disableOriginalConstructor()->getMock();
91  $persistenceManagerMock
92  ->expects(self::once())
93  ->method('persistAll');
94 
95  $objectManagerMock
96  ->expects(self::at(1))
97  ->method('get')
98  ->willReturn($persistenceManagerMock);
99 
100  GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerMock);
101 
103  $task = $this->getMockBuilder(UpdateExtensionListTask::class)
104  ->setMethods(['dummy'])
105  ->disableOriginalConstructor()
106  ->getMock();
107  $task->execute();
108  }
109 }
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Task\UpdateExtensionListTaskTest\executeCallsPersistAllOnPersistenceManager
‪executeCallsPersistAllOnPersistenceManager()
Definition: UpdateExtensionListTaskTest.php:79
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Task\UpdateExtensionListTaskTest\executeCallsUpdateExtListOfRepositoryHelper
‪executeCallsUpdateExtListOfRepositoryHelper()
Definition: UpdateExtensionListTaskTest.php:47
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Task\UpdateExtensionListTaskTest\updateExtensionListTaskIsInstanceOfAbstractTask
‪updateExtensionListTaskIsInstanceOfAbstractTask()
Definition: UpdateExtensionListTaskTest.php:38
‪TYPO3\CMS\Extensionmanager\Task\UpdateExtensionListTask
Definition: UpdateExtensionListTask.php:29
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Task
Definition: UpdateExtensionListTaskTest.php:16
‪TYPO3\CMS\Scheduler\Task\AbstractTask
Definition: AbstractTask.php:35
‪TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager
Definition: PersistenceManager.php:29
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Task\UpdateExtensionListTaskTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: UpdateExtensionListTaskTest.php:33
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Task\UpdateExtensionListTaskTest
Definition: UpdateExtensionListTaskTest.php:30
‪TYPO3\CMS\Extensionmanager\Utility\Repository\Helper
Definition: Helper.php:37
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Extbase\Object\ObjectManager
Definition: ObjectManager.php:28