[TASK] Fix CGL violations against ClassDocComment
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Tests / Unit / Controller / UpdateFromTerControllerTest.php
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Controller;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2012 Susanne Moog, <typo3@susannemoog.de>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * Update from TER controller test
29 *
30 * @package Extension Manager
31 * @subpackage Tests
32 */
33 class UpdateFromTerControllerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
34
35 /**
36 * Enable backup of global and system variables
37 *
38 * @var boolean
39 */
40 protected $backupGlobals = TRUE;
41
42 /**
43 * Exclude TYPO3_DB from backup/ restore of $GLOBALS
44 * because resource types cannot be handled during serializing
45 *
46 * @var array
47 */
48 protected $backupGlobalsBlacklist = array('TYPO3_DB');
49
50 /**
51 * @test
52 * @return void
53 */
54 public function updateExtensionListFromTerCallsUpdateExtListIfLastUpdateIsMoreThan24HoursAgo() {
55 $controllerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Controller\\UpdateFromTerController', array('dummy'));
56 $repositoryRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository', array('findOneByUid'));
57 $repositoryModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository', array('getLastUpdate'));
58 $repositoryHelperMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper', array('updateExtList'));
59 $viewMock = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\View\\TemplateView', array('assign'));
60 $requestMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Request', array('hasArgument', 'getArgument'));
61 $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
62 $lastUpdateDate = new \DateTime();
63 // Wed Jul 25 18:40:02 CEST 2012
64 $lastUpdateDate->setTimestamp(1343234402);
65 $repositoryModelMock->expects($this->once())->method('getLastUpdate')->will($this->returnValue($lastUpdateDate));
66 $repositoryRepositoryMock->expects($this->once())->method('findOneByUid')->with(1)->will($this->returnValue($repositoryModelMock));
67 $repositoryHelperMock->expects($this->once())->method('updateExtList');
68 // Sat Jul 28 18:40:02 CEST 2012
69 $GLOBALS['EXEC_TIME'] = 1343493602;
70 $controllerMock->_set('repositoryRepository', $repositoryRepositoryMock);
71 $controllerMock->_set('repositoryHelper', $repositoryHelperMock);
72 $controllerMock->_set('settings', array('repositoryUid' => 1));
73 $controllerMock->_set('view', $viewMock);
74 $controllerMock->_set('request', $requestMock);
75 $controllerMock->updateExtensionListFromTerAction();
76 }
77
78 /**
79 * @test
80 * @return void
81 */
82 public function updateExtensionListFromTerDoesNotCallUpdateExtListIfLastUpdateIsLessThan24HoursAgo() {
83 $controllerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Controller\\UpdateFromTerController', array('dummy'));
84 $repositoryRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository', array('findOneByUid'));
85 $repositoryModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository', array('getLastUpdate'));
86 $repositoryHelperMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper', array('updateExtList'));
87 $viewMock = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\View\\TemplateView', array('assign'));
88 $requestMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Request', array('hasArgument', 'getArgument'));
89 $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
90 $lastUpdateDate = new \DateTime();
91 // Wed Jul 25 18:40:02 CEST 2012
92 $lastUpdateDate->setTimestamp(1343493602);
93 $repositoryModelMock->expects($this->once())->method('getLastUpdate')->will($this->returnValue($lastUpdateDate));
94 $repositoryRepositoryMock->expects($this->once())->method('findOneByUid')->with(1)->will($this->returnValue($repositoryModelMock));
95 $repositoryHelperMock->expects($this->never())->method('updateExtList');
96 // Sat Jul 28 18:40:02 CEST 2012
97 $GLOBALS['EXEC_TIME'] = 1343493602;
98 $controllerMock->_set('repositoryRepository', $repositoryRepositoryMock);
99 $controllerMock->_set('repositoryHelper', $repositoryHelperMock);
100 $controllerMock->_set('settings', array('repositoryUid' => 1));
101 $controllerMock->_set('view', $viewMock);
102 $controllerMock->_set('request', $requestMock);
103 $controllerMock->updateExtensionListFromTerAction();
104 }
105
106 /**
107 * @test
108 * @return void
109 */
110 public function updateExtensionListFromTerCallsUpdateExtListIfForceUpdateCheckIsSet() {
111 $controllerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Controller\\UpdateFromTerController', array('dummy'));
112 $repositoryRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository', array('findOneByUid'));
113 $repositoryModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository', array('getLastUpdate'));
114 $repositoryHelperMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper', array('updateExtList'));
115 $viewMock = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\View\\TemplateView', array('assign'));
116 $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
117 $lastUpdateDate = new \DateTime();
118 // Wed Jul 25 18:40:02 CEST 2012
119 $lastUpdateDate->setTimestamp(1343234402);
120 $repositoryModelMock->expects($this->once())->method('getLastUpdate')->will($this->returnValue($lastUpdateDate));
121 $repositoryRepositoryMock->expects($this->once())->method('findOneByUid')->with(1)->will($this->returnValue($repositoryModelMock));
122 $repositoryHelperMock->expects($this->once())->method('updateExtList');
123 // Sat Jul 28 18:40:02 CEST 2012
124 $GLOBALS['EXEC_TIME'] = 1343493602;
125 $controllerMock->_set('repositoryRepository', $repositoryRepositoryMock);
126 $controllerMock->_set('repositoryHelper', $repositoryHelperMock);
127 $controllerMock->_set('settings', array('repositoryUid' => 1));
128 $controllerMock->_set('view', $viewMock);
129 $controllerMock->_set('request', $requestMock);
130 $controllerMock->updateExtensionListFromTerAction(TRUE);
131 }
132
133 }
134
135
136 ?>