TYPO3 CMS  TYPO3_6-2
UpdateFromTerControllerTest.php
Go to the documentation of this file.
1 <?php
3 
22 
26  protected $mockObjectManager;
27 
32 
37 
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 
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 
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 
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 }
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)