[TASK] Re-work/simplify copyright header in PHP files - Part 9
[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 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Update from TER controller test
19 *
20 */
21 class UpdateFromTerControllerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
22
23 /**
24 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
25 */
26 protected $mockObjectManager;
27
28 /**
29 * @var \TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository
30 */
31 protected $repositoryRepositoryMock;
32
33 /**
34 * @var \TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository
35 */
36 protected $extensionRepositoryMock;
37
38 /**
39 * @var \TYPO3\CMS\Extensionmanager\Utility\Repository\Helper
40 */
41 protected $repositoryHelperMock;
42
43 public function setUp() {
44 $this->mockObjectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
45 $this->repositoryRepositoryMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository', array('findByUid'), array($this->mockObjectManager));
46 $this->extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository', array(), array($this->mockObjectManager));
47 $this->repositoryHelperMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\Repository\\Helper', array('updateExtList'), array(), '', FALSE);
48 }
49
50 /**
51 * @test
52 * @return void
53 */
54 public function updateExtensionListFromTerCallsUpdateExtListIfExtensionListIsEmpty() {
55 $controllerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Controller\\UpdateFromTerController', array('dummy'));
56 $repositoryModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository', array('getLastUpdate'));
57
58 $viewMock = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\View\\TemplateView', array('assign'), array(), '', FALSE);
59 $requestMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Request', array('hasArgument', 'getArgument'));
60 $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
61 $this->repositoryRepositoryMock->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($repositoryModelMock));
62 $this->repositoryHelperMock->expects($this->once())->method('updateExtList');
63 $this->extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(0));
64 $controllerMock->_set('extensionRepository', $this->extensionRepositoryMock);
65 $controllerMock->_set('repositoryRepository', $this->repositoryRepositoryMock);
66 $controllerMock->_set('repositoryHelper', $this->repositoryHelperMock);
67 $controllerMock->_set('settings', array('repositoryUid' => 1));
68 $controllerMock->_set('view', $viewMock);
69 $controllerMock->_set('request', $requestMock);
70 $controllerMock->updateExtensionListFromTerAction();
71 }
72
73 /**
74 * @test
75 * @return void
76 */
77 public function updateExtensionListFromTerDoesNotCallsUpdateExtListIfExtensionListIsNotEmpty() {
78 $controllerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Controller\\UpdateFromTerController', array('dummy'));
79 $repositoryModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository', array('getLastUpdate'));
80 $viewMock = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\View\\TemplateView', array('assign'), array(), '', FALSE);
81 $requestMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Request', array('hasArgument', 'getArgument'));
82 $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
83 $this->repositoryRepositoryMock->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($repositoryModelMock));
84 $this->repositoryHelperMock->expects($this->never())->method('updateExtList');
85 $this->extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(100));
86 $controllerMock->_set('extensionRepository', $this->extensionRepositoryMock);
87 $controllerMock->_set('repositoryRepository', $this->repositoryRepositoryMock);
88 $controllerMock->_set('repositoryHelper', $this->repositoryHelperMock);
89 $controllerMock->_set('settings', array('repositoryUid' => 1));
90 $controllerMock->_set('view', $viewMock);
91 $controllerMock->_set('request', $requestMock);
92 $controllerMock->updateExtensionListFromTerAction();
93 }
94
95 /**
96 * @test
97 * @return void
98 */
99 public function updateExtensionListFromTerCallsUpdateExtListIfForceUpdateCheckIsSet() {
100 $controllerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Controller\\UpdateFromTerController', array('dummy'));
101 $repositoryModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository', array('getLastUpdate'));
102 $viewMock = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\View\\TemplateView', array('assign'), array(), '', FALSE);
103 $requestMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Request', array('hasArgument', 'getArgument'));
104 $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
105 $this->repositoryRepositoryMock->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($repositoryModelMock));
106 $this->repositoryHelperMock->expects($this->once())->method('updateExtList');
107 $this->extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(100));
108 $controllerMock->_set('extensionRepository', $this->extensionRepositoryMock);
109 $controllerMock->_set('repositoryRepository', $this->repositoryRepositoryMock);
110 $controllerMock->_set('repositoryHelper', $this->repositoryHelperMock);
111 $controllerMock->_set('settings', array('repositoryUid' => 1));
112 $controllerMock->_set('view', $viewMock);
113 $controllerMock->_set('request', $requestMock);
114 $controllerMock->updateExtensionListFromTerAction(TRUE);
115 }
116 }