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

Improve code coverage #125

Merged
merged 10 commits into from
Dec 21, 2023
Merged

Improve code coverage #125

merged 10 commits into from
Dec 21, 2023

Conversation

dbhynds
Copy link
Member

@dbhynds dbhynds commented Dec 20, 2023

Summary of Changes

Gets us to like 99% code coverage. Also, testing found a legit bug FTW!

Testing

  • I have added automated tests for my changes
  • I ran composer test before opening this PR
  • I ran composer lint-fix before opening this PR

@dbhynds dbhynds changed the title V6 code coverage Improve code coverage Dec 20, 2023
@dbhynds dbhynds requested a review from JesseBarron December 20, 2023 21:46
$this->connector->shouldReceive('getAll')
->once()->andReturn([]);

$result = $service->findLineItem($lineItem);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a totally unrelated question but why dont we compare lineitem id in LtiAssignmentsGradeService::isMatchingLineitem?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great question. For background, here's the discussion about it on the PR that introduced it: #35 (comment)

Ok, it took me a while to figure out, but I think I remember now finally. It's because when we're syncing grades, our app doesn't necessarily know if the line item exists in the LMS yet. As such the ID could be empty.

Both the getGrades() and putGrade() methods call ensureLineItemExists() which calls findOrCreateLineItem() which calls findLineItem() which calls isMatchingLineItem().

In the case where we call get|putGrade[s]() and we need to create the line item still, we won't have an ID. (We will, however, have the tag, resource ID, and resource link ID.) Hence why we don't match on ID.

Tho I suppose we could add a $newLineItem->getId() == ($lineitem['id'] ?? null) || to the beginning of isMatchingLineitem()

@dbhynds dbhynds requested a review from JesseBarron December 21, 2023 17:53
Base automatically changed from v6-deep-link to v6.0-beta December 21, 2023 19:22

$expected = new LtiLineitem($ltiLineitemData);

$result = $service->createLineItem(new LtiLineItem());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistancy, shouldn't this and other methods that make a service request validate scopes before making the request?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good suggestion, but probably requires a more holistic refactor. Are you ok with me addressing that in a separate PR?

@@ -76,6 +119,131 @@ public function testItGetsSingleLineItemWithReadonlyScope()
$this->assertEquals($expected, $result);
}

public function testItPutsAGrade()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you test that tis throws an exception if the wrong scope is set?


$this->assertEquals($expected, $this->key->getSecret());
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a tests for Lti1p1Key::sign()?

@dbhynds dbhynds requested a review from JesseBarron December 21, 2023 20:37
@dbhynds dbhynds merged commit 284d9a8 into v6.0-beta Dec 21, 2023
4 checks passed
@dbhynds dbhynds deleted the v6-code-coverage branch December 21, 2023 21:44
@dbhynds dbhynds mentioned this pull request Dec 21, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants