|
|
@@ -15,19 +15,15 @@ class SelectedSiteControllerTest extends UnitTestCase
|
|
|
$this->controller = new SelectedSiteController();
|
|
|
}
|
|
|
|
|
|
- private function injectBeUserWithMountpoints(array $mountpoints) {
|
|
|
- $be_user = $this->prophesize(\TYPO3\CMS\Core\Authentication\BackendUserAuthentication::class);
|
|
|
- $be_user->returnWebmounts()->shouldBeCalled()->willReturn($mountpoints);
|
|
|
- $GLOBALS['BE_USER'] = $be_user->reveal();
|
|
|
- }
|
|
|
-
|
|
|
- private function injectPageRepositoryWithSelectedUid(?int $selectedUid) {
|
|
|
+ private function injectPageRepositoryWithSelectedUidAndMountpoints(?int $selectedUid, array $mountpoints = []) {
|
|
|
$otPageRepository = $this->prophesize(OtPageRepository::class);
|
|
|
+
|
|
|
if ($selectedUid != null) {
|
|
|
- $otPageRepository->getCurrentRootUid()->shouldBeCalled()->willReturn($selectedUid);
|
|
|
+ $otPageRepository->getCurrentRootUid()->willReturn($selectedUid);
|
|
|
} else {
|
|
|
- $otPageRepository->getCurrentRootUid()->shouldBeCalled()->willThrow(new NoSiteSelected());
|
|
|
+ $otPageRepository->getCurrentRootUid()->willThrow(new NoSiteSelected());
|
|
|
}
|
|
|
+ $otPageRepository->getCurrentBeUserMountpoints()->shouldBeCalled()->willReturn($mountpoints);
|
|
|
$this->controller->injectOtPageRepository($otPageRepository->reveal());
|
|
|
}
|
|
|
|
|
|
@@ -58,7 +54,7 @@ class SelectedSiteControllerTest extends UnitTestCase
|
|
|
*/
|
|
|
public function callActionMethodForSingleSite() {
|
|
|
|
|
|
- $this->injectBeUserWithMountpoints([1]);
|
|
|
+ $this->injectPageRepositoryWithSelectedUidAndMountpoints(null, [1]);
|
|
|
|
|
|
$currentRootUid = $this->callActionMethodProxy();
|
|
|
|
|
|
@@ -73,9 +69,7 @@ class SelectedSiteControllerTest extends UnitTestCase
|
|
|
*/
|
|
|
public function callActionMethodForMultiSite() {
|
|
|
|
|
|
- $this->injectBeUserWithMountpoints([1, 2]);
|
|
|
-
|
|
|
- $this->injectPageRepositoryWithSelectedUid(2);
|
|
|
+ $this->injectPageRepositoryWithSelectedUidAndMountpoints(2, [1, 2]);
|
|
|
|
|
|
$currentRootUid = $this->callActionMethodProxy();
|
|
|
|
|
|
@@ -90,9 +84,7 @@ class SelectedSiteControllerTest extends UnitTestCase
|
|
|
*/
|
|
|
public function callActionMethodForNoSite() {
|
|
|
|
|
|
- $this->injectBeUserWithMountpoints([1, 2]);
|
|
|
-
|
|
|
- $this->injectPageRepositoryWithSelectedUid(null);
|
|
|
+ $this->injectPageRepositoryWithSelectedUidAndMountpoints(null, [1, 2]);
|
|
|
|
|
|
$currentRootUid = $this->callActionMethodProxy();
|
|
|
|