subject = new LTIDeliveryTool(); } public function testGetFinishUrlNotLtiSessionThrowsException(): void { self::expectException(LtiException::class); $ltiNavigationServiceMock = $this->createMock(LtiNavigationService::class); $sessionServiceMock = $this->createMock(SessionService::class); $sessionServiceMock->method('getCurrentSession') ->willReturn($this->createMock(common_session_Session::class)); $serviceLocatorMock = $this->getServiceLocatorMock([ LtiNavigationService::SERVICE_ID => $ltiNavigationServiceMock, SessionService::SERVICE_ID => $sessionServiceMock ]); $this->subject->setServiceLocator($serviceLocatorMock); $deliveryExecutionMock = $this->createMock(DeliveryExecution::class); $this->subject->getFinishUrl($deliveryExecutionMock); } public function testGetFnishUrlReturnsCorrectUrl(): void { $expectedUrl = 'http://www.FAKE_RETURN_URL.com/'; $ltiNavigationServiceMock = $this->createMock(LtiNavigationService::class); $ltiNavigationServiceMock->method('getReturnUrl') ->willReturn($expectedUrl); // Mock LtiLaunchData $ltiSessionMock = $this->createMock(TaoLtiSession::class); $ltiSessionMock->method('getLaunchData') ->willReturn($this->createMock(LtiLaunchData::class)); $sessionServiceMock = $this->createMock(SessionService::class); $sessionServiceMock->method('getCurrentSession') ->willReturn($ltiSessionMock); $serviceLocatorMock = $this->getServiceLocatorMock([ LtiNavigationService::SERVICE_ID => $ltiNavigationServiceMock, SessionService::SERVICE_ID => $sessionServiceMock ]); $this->subject->setServiceLocator($serviceLocatorMock); $deliveryExecutionMock = $this->createMock(DeliveryExecution::class); $finishUrl = $this->subject->getFinishUrl($deliveryExecutionMock); self::assertSame($expectedUrl, $finishUrl, "Method must return correct finish url"); } }