'thing' ]; /** @var LtiLauncherInterface|MockObject */ private $lti1p1Launcher; /** @var LtiLauncherInterface|MockObject */ private $lti1p3Launcher; /** @var Lti1p3Launcher */ private $subject; public function setUp(): void { $this->lti1p1Launcher = $this->createMock(Lti1p3Launcher::class); $this->lti1p3Launcher = $this->createMock(Lti1p1Launcher::class); $this->subject = new LtiLauncherProxy(); $this->subject->setServiceLocator( $this->getServiceLocatorMock( [ Lti1p3Launcher::class => $this->lti1p3Launcher, Lti1p1Launcher::class => $this->lti1p1Launcher ] ) ); } public function testLti1p1Launch(): void { $command = $this->createCommand('1.1'); $launch = new LtiLaunch(self::LAUNCH_URL, self::LAUNCH_PARAMS); $this->lti1p1Launcher ->method('launch') ->willReturn($launch); $this->assertEquals($launch, $this->subject->launch($command)); } public function testLti1p3Launch(): void { $command = $this->createCommand('1.3'); $launch = new LtiLaunch(self::LAUNCH_URL, self::LAUNCH_PARAMS); $this->lti1p3Launcher ->method('launch') ->willReturn($launch); $this->assertEquals($launch, $this->subject->launch($command)); } public function testLtiInvalidLaunchWillThrowException(): void { $this->expectException(LogicException::class); $this->expectExceptionMessage('LTI version 1.4 is not supported'); $this->subject->launch($this->createCommand('1.4')); } private function createCommand(string $ltiVersion): LtiLaunchCommandInterface { $command = $this->createMock(LtiLaunchCommand::class); $ltiProvider = $this->createMock(LtiProvider::class); $command->method('getLtiProvider') ->willReturn($ltiProvider); $ltiProvider->method('getLtiVersion') ->willReturn($ltiVersion); return $command; } }