Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial changes for v6 #117

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/LtiAssignmentsGradesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function getScope(): array
public function getResourceLaunchLineItem(): ?LtiLineitem
{
$serviceData = $this->getServiceData();
if (empty($serviceData['lineitem'])) {
if (!isset($serviceData['lineitem'])) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/LtiLineitem.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function getGradesReleased(): ?bool
return $this->grades_released;
}

public function setGradesReleased(?bool $value): self
public function setGradesReleased(?bool $value): LtiLineitem
{
$this->grades_released = $value;

Expand Down
8 changes: 4 additions & 4 deletions src/MessageValidators/DeepLinkMessageValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ public static function validate(array $jwtBody): void
{
static::validateGenericMessage($jwtBody);

if (empty($jwtBody[LtiConstants::DL_DEEP_LINK_SETTINGS])) {
if (!isset($jwtBody[LtiConstants::DL_DEEP_LINK_SETTINGS])) {
throw new LtiException('Missing Deep Linking Settings');
}
$deep_link_settings = $jwtBody[LtiConstants::DL_DEEP_LINK_SETTINGS];
if (empty($deep_link_settings['deep_link_return_url'])) {
if (!isset($deep_link_settings['deep_link_return_url'])) {
throw new LtiException('Missing Deep Linking Return URL');
}
if (empty($deep_link_settings['accept_types']) || !in_array('ltiResourceLink', $deep_link_settings['accept_types'])) {
if (!isset($deep_link_settings['accept_types']) || !in_array('ltiResourceLink', $deep_link_settings['accept_types'])) {
throw new LtiException('Must support resource link placement types');
}
if (empty($deep_link_settings['accept_presentation_document_targets'])) {
if (!isset($deep_link_settings['accept_presentation_document_targets'])) {
throw new LtiException('Must support a presentation type');
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/MessageValidators/ResourceMessageValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static function validate(array $jwtBody): void
{
static::validateGenericMessage($jwtBody);

if (empty($jwtBody[LtiConstants::RESOURCE_LINK]['id'])) {
if (!isset($jwtBody[LtiConstants::RESOURCE_LINK]['id'])) {
throw new LtiException('Missing Resource Link Id');
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/MessageValidators/SubmissionReviewMessageValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public static function validate(array $jwtBody): void
{
static::validateGenericMessage($jwtBody);

if (empty($jwtBody[LtiConstants::RESOURCE_LINK]['id'])) {
if (!isset($jwtBody[LtiConstants::RESOURCE_LINK]['id'])) {
throw new LtiException('Missing Resource Link Id');
}
if (empty($jwtBody[LtiConstants::FOR_USER])) {
if (!isset($jwtBody[LtiConstants::FOR_USER])) {
throw new LtiException('Missing For User');
}
}
Expand Down
8 changes: 6 additions & 2 deletions tests/LtiMessageLaunchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ public function testItGetsALaunchFromTheCache()
$this->registration->shouldReceive('getClientId')
->once()->andReturn($this->issuer['client_id']);

$actual = $this->messageLaunch::fromCache('id_token', $this->database, $this->cache,
$actual = LtiMessageLaunch::fromCache('id_token',
$this->database,
$this->cache,
$this->cookie,
$this->serviceConnector);

Expand Down Expand Up @@ -320,6 +322,8 @@ public function testALaunchFailsIfMissingRegistration()
$this->database->shouldReceive('findRegistrationByIssuer')
->once()->andReturn();

$this->messageLaunch->setRequest($payload);

$this->expectException(LtiException::class);
$expectedMsg = $this->messageLaunch->getMissingRegistrationErrorMsg($this->issuer['issuer'], $this->issuer['client_id']);
$this->expectExceptionMessage($expectedMsg);
Expand Down Expand Up @@ -866,7 +870,7 @@ private function fakeLaunch($payload, $launchId = 'id_token')
$this->registration->shouldReceive('getClientId')
->once()->andReturn($this->issuer['client_id']);

return $this->messageLaunch::fromCache($launchId, $this->database, $this->cache, $this->cookie, $this->serviceConnector);
return LtiMessageLaunch::fromCache($launchId, $this->database, $this->cache, $this->cookie, $this->serviceConnector);
}

private function buildJWT($data, $header)
Expand Down