Skip to content

Commit

Permalink
Merge pull request #120 from oat-sa/fix/issue-119
Browse files Browse the repository at this point in the history
Fix/issue 119
  • Loading branch information
ekkinox authored Jul 27, 2021
2 parents 2db2540 + 1a282a3 commit 303722a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

6.0.1
-----

* Fixed issue [#119](https://github.com/oat-sa/lib-lti1p3-core/issues/119)

6.0.0
-----

Expand Down
5 changes: 5 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
<file name="src/Security/Jwt/Decoder/AssociativeDecoder.php"/>
</errorLevel>
</UndefinedConstant>
<RedundantCondition>
<errorLevel type="suppress">
<file name="src/Message/LtiMessage.php"/>
</errorLevel>
</RedundantCondition>
</issueHandlers>
<mockClasses>
<class name="PHPUnit\Framework\MockObject\MockObject"/>
Expand Down
6 changes: 5 additions & 1 deletion src/Message/LtiMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ public static function fromServerRequest(ServerRequestInterface $request): LtiMe

public function toUrl(): string
{
return sprintf('%s?%s', $this->url, http_build_query(array_filter($this->getParameters()->all())));
$separator = false !== strpos($this->url, '?')
? '&'
: '?';

return sprintf('%s%s%s', $this->url, $separator, http_build_query(array_filter($this->getParameters()->all())));
}

public function toHtmlLink(string $title, array $attributes = []): string
Expand Down
12 changes: 12 additions & 0 deletions tests/Unit/Message/LtiMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ public function testToUrl(): void
$this->assertEquals('http://example.com?parameter=value', $this->subject->toUrl());
}

public function testToUrlWithExistingQueryParameters(): void
{
$subject = new LtiMessage(
'http://example.com?existingParameter=existingValue',
[
'newParameter' => 'newValue',
]
);

$this->assertEquals('http://example.com?existingParameter=existingValue&newParameter=newValue', $subject->toUrl());
}

public function testToHtmlLink(): void
{
$this->assertEquals(
Expand Down

0 comments on commit 303722a

Please sign in to comment.