TYPO3 CMS  TYPO3_7-6
UpdateFromTerControllerTest.php
Go to the documentation of this file.
1 <?php
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 
22 {
26  protected $mockObjectManager;
27 
32 
37 
42 
43  protected function setUp()
44  {
45  $this->mockObjectManager = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class);
46  $this->repositoryRepositoryMock = $this->getMock(\TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository::class, ['findByUid'], [$this->mockObjectManager]);
47  $this->extensionRepositoryMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository::class, [], [$this->mockObjectManager]);
48  $this->repositoryHelperMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Utility\Repository\Helper::class, ['updateExtList'], [], '', false);
49  }
50 
56  {
57  $controllerMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Controller\UpdateFromTerController::class, ['dummy']);
58  $repositoryModelMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Model\Repository::class, ['getLastUpdate']);
59 
60  $viewMock = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, ['assign'], [], '', false);
61  $requestMock = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Request::class, ['hasArgument', 'getArgument']);
62  $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
63  $this->repositoryRepositoryMock->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($repositoryModelMock));
64  $this->repositoryHelperMock->expects($this->once())->method('updateExtList');
65  $this->extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(0));
66  $controllerMock->_set('extensionRepository', $this->extensionRepositoryMock);
67  $controllerMock->_set('repositoryRepository', $this->repositoryRepositoryMock);
68  $controllerMock->_set('repositoryHelper', $this->repositoryHelperMock);
69  $controllerMock->_set('settings', ['repositoryUid' => 1]);
70  $controllerMock->_set('view', $viewMock);
71  $controllerMock->_set('request', $requestMock);
72  $controllerMock->updateExtensionListFromTerAction();
73  }
74 
80  {
81  $controllerMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Controller\UpdateFromTerController::class, ['dummy']);
82  $repositoryModelMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Model\Repository::class, ['getLastUpdate']);
83  $viewMock = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, ['assign'], [], '', false);
84  $requestMock = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Request::class, ['hasArgument', 'getArgument']);
85  $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
86  $this->repositoryRepositoryMock->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($repositoryModelMock));
87  $this->repositoryHelperMock->expects($this->never())->method('updateExtList');
88  $this->extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(100));
89  $controllerMock->_set('extensionRepository', $this->extensionRepositoryMock);
90  $controllerMock->_set('repositoryRepository', $this->repositoryRepositoryMock);
91  $controllerMock->_set('repositoryHelper', $this->repositoryHelperMock);
92  $controllerMock->_set('settings', ['repositoryUid' => 1]);
93  $controllerMock->_set('view', $viewMock);
94  $controllerMock->_set('request', $requestMock);
95  $controllerMock->updateExtensionListFromTerAction();
96  }
97 
103  {
104  $controllerMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Controller\UpdateFromTerController::class, ['dummy']);
105  $repositoryModelMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Model\Repository::class, ['getLastUpdate']);
106  $viewMock = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, ['assign'], [], '', false);
107  $requestMock = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Request::class, ['hasArgument', 'getArgument']);
108  $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
109  $this->repositoryRepositoryMock->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($repositoryModelMock));
110  $this->repositoryHelperMock->expects($this->once())->method('updateExtList');
111  $this->extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(100));
112  $controllerMock->_set('extensionRepository', $this->extensionRepositoryMock);
113  $controllerMock->_set('repositoryRepository', $this->repositoryRepositoryMock);
114  $controllerMock->_set('repositoryHelper', $this->repositoryHelperMock);
115  $controllerMock->_set('settings', ['repositoryUid' => 1]);
116  $controllerMock->_set('view', $viewMock);
117  $controllerMock->_set('request', $requestMock);
118  $controllerMock->updateExtensionListFromTerAction(true);
119  }
120 }
getAccessibleMock( $originalClassName, $methods=[], array $arguments=[], $mockClassName='', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true)