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
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/Interfaces/ILtiServiceConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function getAll(
ILtiRegistration $registration,
array $scopes,
IServiceRequest $request,
string $key
?string $key
): array;

public function setDebuggingMode(bool $enable): ILtiServiceConnector;
Expand Down
53 changes: 52 additions & 1 deletion tests/DeepLinkResources/ResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function testItGetsIframe()
{
$result = $this->resource->getIframe();

$this->assertEquals(null, $result);
$this->assertNull($result);
}

public function testItSetsIframe()
Expand All @@ -186,6 +186,57 @@ public function testItSetsIframe()
$this->assertEquals($expected, $this->resource->getIframe());
}

public function testItGetsWindow()
{
$result = $this->resource->getWindow();

$this->assertNull($result);
}

public function testItSetsWindow()
{
$expected = new Window();

$result = $this->resource->setWindow($expected);

$this->assertSame($this->resource, $result);
$this->assertEquals($expected, $this->resource->getWindow());
}

public function testItGetsAvailabilityInterval()
{
$result = $this->resource->getAvailabilityInterval();

$this->assertNull($result);
}

public function testItSetsAvailabilityInterval()
{
$expected = new DateTimeInterval();

$result = $this->resource->setAvailabilityInterval($expected);

$this->assertSame($this->resource, $result);
$this->assertEquals($expected, $this->resource->getAvailabilityInterval());
}

public function testItGetsSubmissionInterval()
{
$result = $this->resource->getSubmissionInterval();

$this->assertNull($result);
}

public function testItSetsSubmissionInterval()
{
$expected = new DateTimeInterval();

$result = $this->resource->setSubmissionInterval($expected);

$this->assertSame($this->resource, $result);
$this->assertEquals($expected, $this->resource->getSubmissionInterval());
}

public function testItCreatesArrayWithoutOptionalProperties()
{
$expected = [
Expand Down
62 changes: 62 additions & 0 deletions tests/Lti1p1KeyTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace Tests;

use Packback\Lti1p3\Lti1p1Key;

class Lti1p1KeyTest extends TestCase
{
public function setUp(): void
{
$this->key = new Lti1p1Key();
}

public function testItInstantiates()
{
$this->assertInstanceOf(Lti1p1Key::class, $this->key);
}

public function testItGetsKey()
{
$result = $this->key->getKey();

$this->assertNull($result);
}

public function testItSetsKey()
{
$expected = 'expected';

$this->key->setKey($expected);

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

public function testItGetsSecret()
{
$result = $this->key->getSecret();

$this->assertNull($result);
}

public function testItSetsSecret()
{
$expected = 'expected';

$this->key->setSecret($expected);

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

public function testItSigns()
{
$key = new Lti1p1Key([
'key' => 'foo',
'secret' => 'bar',
]);

$actual = $key->sign('deploymentId', 'iss', 'clientId', 'exp', 'nonce');

$this->assertEquals('1Ze6akG0koOVeizCVBIyQHJ78Eo3vGUXyqOM0iDqS0k=', $actual);
}
}

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()?

Loading