TYPO3 CMS  TYPO3_6-2
UpdateExtensionListTaskTest.php
Go to the documentation of this file.
1 <?php
3 
22 
26  protected $singletonInstances = array();
27 
31  protected $repositoryHelper;
32 
36  public function setUp() {
37  if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('scheduler')) {
38  $this->markTestSkipped('Tests need EXT:scheduler loaded.');
39  }
41  $this->repositoryHelper = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper', array(), array(), '', FALSE);
42  }
43 
47  public function tearDown() {
49  parent::tearDown();
50  }
51 
56  $taskMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Task\\UpdateExtensionListTask');
57  $this->assertInstanceOf('TYPO3\\CMS\\Scheduler\\Task\\AbstractTask', $taskMock);
58  }
59 
64  $this->repositoryHelper
65  ->expects($this->once())
66  ->method('updateExtList');
67 
68  $objectManagerMock = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
69  $objectManagerMock
70  ->expects($this->at(0))
71  ->method('get')
72  ->with('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper')
73  ->will($this->returnValue($this->repositoryHelper));
74 
75  $persistenceManagerMock = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
76  $objectManagerMock
77  ->expects($this->at(1))
78  ->method('get')
79  ->will($this->returnValue($persistenceManagerMock));
80 
81  \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', $objectManagerMock);
82 
83  $task = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Task\\UpdateExtensionListTask', array('dummy'), array(), '', FALSE);
84  $task->execute();
85  }
86 
91  $objectManagerMock = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
92  $objectManagerMock
93  ->expects($this->at(0))
94  ->method('get')
95  ->with('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper')
96  ->will($this->returnValue($this->repositoryHelper));
97 
98  $persistenceManagerMock = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
99  $persistenceManagerMock
100  ->expects($this->once())
101  ->method('persistAll');
102 
103  $objectManagerMock
104  ->expects($this->at(1))
105  ->method('get')
106  ->will($this->returnValue($persistenceManagerMock));
107 
108  \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', $objectManagerMock);
109 
110  $task = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Task\\UpdateExtensionListTask', array('dummy'), array(), '', FALSE);
111  $task->execute();
112  }
113 }
static setSingletonInstance($className, \TYPO3\CMS\Core\SingletonInterface $instance)
static resetSingletonInstances(array $newSingletonInstances)