cf983da2592aba3d2c16698528f4e90bded97547
[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-2013 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 */
31 class UpdateFromTerControllerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
32
33 /**
34 * @test
35 * @return void
36 */
37 public function updateExtensionListFromTerCallsUpdateExtListIfExtensionListIsEmpty() {
38 $controllerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Controller\\UpdateFromTerController', array('dummy'));
39 $repositoryRepositoryMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository', array('findByUid'));
40 $repositoryModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository', array('getLastUpdate'));
41 $repositoryHelperMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper', array('updateExtList'));
42 $viewMock = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\View\\TemplateView', array('assign'));
43 $requestMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Request', array('hasArgument', 'getArgument'));
44 $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
45 $repositoryRepositoryMock->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($repositoryModelMock));
46 $repositoryHelperMock->expects($this->once())->method('updateExtList');
47 $extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository');
48 $extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(0));
49 $controllerMock->_set('extensionRepository', $extensionRepositoryMock);
50
51 $controllerMock->_set('repositoryRepository', $repositoryRepositoryMock);
52 $controllerMock->_set('repositoryHelper', $repositoryHelperMock);
53 $controllerMock->_set('settings', array('repositoryUid' => 1));
54 $controllerMock->_set('view', $viewMock);
55 $controllerMock->_set('request', $requestMock);
56 $controllerMock->updateExtensionListFromTerAction();
57 }
58
59 /**
60 * @test
61 * @return void
62 */
63 public function updateExtensionListFromTerDoesNotCallsUpdateExtListIfExtensionListIsNotEmpty() {
64 $controllerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Controller\\UpdateFromTerController', array('dummy'));
65 $repositoryRepositoryMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository', array('findByUid'));
66 $repositoryModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository', array('getLastUpdate'));
67 $repositoryHelperMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper', array('updateExtList'));
68 $viewMock = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\View\\TemplateView', array('assign'));
69 $requestMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Request', array('hasArgument', 'getArgument'));
70 $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
71 $repositoryRepositoryMock->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($repositoryModelMock));
72 $repositoryHelperMock->expects($this->never())->method('updateExtList');
73 $extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository');
74 $extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(100));
75 $controllerMock->_set('extensionRepository', $extensionRepositoryMock);
76
77 $controllerMock->_set('repositoryRepository', $repositoryRepositoryMock);
78 $controllerMock->_set('repositoryHelper', $repositoryHelperMock);
79 $controllerMock->_set('settings', array('repositoryUid' => 1));
80 $controllerMock->_set('view', $viewMock);
81 $controllerMock->_set('request', $requestMock);
82 $controllerMock->updateExtensionListFromTerAction();
83 }
84
85 /**
86 * @test
87 * @return void
88 */
89 public function updateExtensionListFromTerCallsUpdateExtListIfForceUpdateCheckIsSet() {
90 $controllerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Controller\\UpdateFromTerController', array('dummy'));
91 $repositoryRepositoryMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository', array('findByUid'));
92 $repositoryModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository', array('getLastUpdate'));
93 $repositoryHelperMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper', array('updateExtList'));
94 $viewMock = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\View\\TemplateView', array('assign'));
95 $requestMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Request', array('hasArgument', 'getArgument'));
96 $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
97 $repositoryRepositoryMock->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($repositoryModelMock));
98 $repositoryHelperMock->expects($this->once())->method('updateExtList');
99 $extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository');
100 $extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(100));
101 $controllerMock->_set('extensionRepository', $extensionRepositoryMock);
102
103 $controllerMock->_set('repositoryRepository', $repositoryRepositoryMock);
104 $controllerMock->_set('repositoryHelper', $repositoryHelperMock);
105 $controllerMock->_set('settings', array('repositoryUid' => 1));
106 $controllerMock->_set('view', $viewMock);
107 $controllerMock->_set('request', $requestMock);
108 $controllerMock->updateExtensionListFromTerAction(TRUE);
109 }
110
111 }
112
113
114 ?>