-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle empty mail address in webmentions #60
- Loading branch information
1 parent
b00d9aa
commit 8c5b3e8
Showing
2 changed files
with
60 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
|
||
use mauricerenck\Komments\KommentReceiver; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
|
@@ -55,8 +56,7 @@ public function testSetEmailAddressDisabled() | |
|
||
public function testSetConvertToWebmention() | ||
{ | ||
$commentMock = Array | ||
( | ||
$commentMock = [ | ||
'komment' => 'This is my comment', | ||
'url' => '', | ||
'email' => '[email protected]', | ||
|
@@ -69,7 +69,7 @@ public function testSetConvertToWebmention() | |
'replyTo' => '', | ||
'replyHandle' => '', | ||
'cts' => 10, | ||
); | ||
]; | ||
|
||
$expectedResult = [ | ||
'type' => 'KOMMENT', | ||
|
@@ -90,7 +90,48 @@ public function testSetConvertToWebmention() | |
|
||
$kommentReceiver = new KommentReceiver(); | ||
$webmention = $kommentReceiver->convertToWebmention($commentMock, page('phpunit')); | ||
|
||
$this->assertEquals($expectedResult, $webmention); | ||
} | ||
|
||
public function testGetAuthorData() | ||
{ | ||
$kommentReceiver = new KommentReceiver(); | ||
|
||
$expectedResult = [ | ||
'name' => 'John Doe', | ||
'avatar' => 'https://web.site/avatar.jpg', | ||
'url' => 'https://web.site', | ||
'email' => '[email protected]' | ||
]; | ||
|
||
$author = $kommentReceiver->getAuthorData([ | ||
'name' => 'John Doe', | ||
'avatar' => 'https://web.site/avatar.jpg', | ||
'url' => 'https://web.site', | ||
'email' => '[email protected]' | ||
]); | ||
|
||
$this->assertEquals($expectedResult, $author); | ||
} | ||
|
||
public function testGetAuthorDataHandlesMissingData() | ||
{ | ||
$kommentReceiver = new KommentReceiver(); | ||
|
||
$expectedResult = [ | ||
'name' => 'John Doe', | ||
'avatar' => 'https://web.site/avatar.jpg', | ||
'url' => null, | ||
'email' => null | ||
]; | ||
|
||
$author = $kommentReceiver->getAuthorData([ | ||
'name' => 'John Doe', | ||
'avatar' => 'https://web.site/avatar.jpg', | ||
'email' => '' | ||
]); | ||
|
||
$this->assertEquals($expectedResult, $author); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters