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