[BUGFIX] EM: Scheduler task does not persist to database 93/21793/2
authorAlexander Opitz <opitz.alexander@googlemail.com>
Mon, 1 Jul 2013 11:47:42 +0000 (13:47 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Tue, 2 Jul 2013 11:33:12 +0000 (13:33 +0200)
The scheduler task for updating extension list of the extension
manager does not persist his data to database. As Scheduler is no
extbase extension and the task is no extbase task this peristence
isn't called at end of script.

Change-Id: I75629874f698f45f1b7dab47636857b5865e8d24
Resolves: #49528
Releases: 6.2, 6.1, 6.0
Reviewed-on: https://review.typo3.org/21793
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/extensionmanager/Classes/Task/UpdateExtensionListTask.php
typo3/sysext/extensionmanager/Tests/Unit/Task/UpdateExtensionListTaskTest.php

index 2614220..8e734ee 100644 (file)
@@ -52,9 +52,14 @@ class UpdateExtensionListTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
        protected function updateExtensionlist() {
                /** @var $objectManager \TYPO3\CMS\Extbase\Object\ObjectManager */
                $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
+
                /** @var $repositoryHelper \TYPO3\CMS\Extensionmanager\Utility\Repository\Helper */
                $repositoryHelper = $objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper');
                $repositoryHelper->updateExtList();
+
+               /** @var $persistenceManager \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager */
+               $persistenceManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
+               $persistenceManager->persistAll();
        }
 }
 ?>
\ No newline at end of file
index 6074b2f..33f07fd 100644 (file)
@@ -69,11 +69,46 @@ class UpdateExtensionListTaskTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTest
 
                $objectManagerMock = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
                $objectManagerMock
-                               ->expects($this->once())
+                               ->expects($this->at(0))
                                ->method('get')
                                ->with('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper')
                                ->will($this->returnValue($repositoryHelperMock));
 
+               $persistenceManagerMock = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
+               $objectManagerMock
+                               ->expects($this->at(1))
+                               ->method('get')
+                               ->will($this->returnValue($persistenceManagerMock));
+
+               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', $objectManagerMock);
+
+               $task = new \TYPO3\CMS\Extensionmanager\Task\UpdateExtensionListTask();
+               $task->execute();
+       }
+
+       /**
+        * @test
+        */
+       public function executeCallsPersistAllOnPersistenceManager() {
+               $repositoryHelperMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper');
+
+               $objectManagerMock = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
+               $objectManagerMock
+                       ->expects($this->at(0))
+                       ->method('get')
+                       ->with('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper')
+                       ->will($this->returnValue($repositoryHelperMock));
+
+               $persistenceManagerMock = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
+               $persistenceManagerMock
+                       ->expects($this->once())
+                       ->method('persistAll');
+
+               $objectManagerMock
+                               ->expects($this->at(1))
+                               ->method('get')
+                               ->will($this->returnValue($persistenceManagerMock));
+
                \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', $objectManagerMock);
 
                $task = new \TYPO3\CMS\Extensionmanager\Task\UpdateExtensionListTask();