Skip to content

Commit cb48bfc

Browse files
committed
Fixed #29
1 parent 01eedf0 commit cb48bfc

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

src/Entity/Article.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ public function getAuthor()
6969
return (isset($this->data['author'])) ? $this->data['author'] : null;
7070
}
7171

72+
/**
73+
* Returns the URL of the author's profile, if available. Otherwise, null.
74+
* @return string | null
75+
*/
76+
public function getAuthorUrl()
77+
{
78+
return (isset($this->data['authorUrl'])) ? $this->data['authorUrl'] : null;
79+
}
80+
7281
/**
7382
* The array returned will contain all tags that Diffbot's AI concluded match the content
7483
*

tests/Entity/ArticleTest.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,25 +138,28 @@ public function testDate($file, $articles)
138138
public function authorProvider()
139139
{
140140
return [
141-
['Articles/diffbot-sitepoint-basic.json', "Bruno Skvorc"],
142-
['Articles/diffbot-sitepoint-extended.json', "Bruno Skvorc"],
143-
['Articles/apple-watch-verge-basic.json', null],
141+
['Articles/diffbot-sitepoint-basic.json', "Bruno Skvorc", "http://www.sitepoint.com/author/bskvorc/"],
142+
['Articles/diffbot-sitepoint-extended.json', "Bruno Skvorc", "http://www.sitepoint.com/author/bskvorc/"],
143+
['Articles/apple-watch-verge-basic.json', null, null],
144144
// Diffbot failed to detect this on April 12th
145-
['Articles/apple-watch-verge-extended.json', null]
145+
['Articles/apple-watch-verge-extended.json', null, null]
146146
];
147147
}
148148

149149
/**
150150
* @param $file
151151
* @param $articles
152+
* @param $url
152153
* @dataProvider authorProvider
153154
*/
154-
public function testAuthor($file, $articles)
155+
public function testAuthor($file, $articles, $url)
155156
{
156157
$articles = (is_array($articles)) ? $articles : [$articles];
158+
$url = (is_array($url)) ? $url : [$url];
157159
/** @var Article $entity */
158160
foreach ($this->ei($file) as $i => $entity) {
159161
$this->assertEquals($articles[$i], $entity->getAuthor());
162+
$this->assertEquals($url[$i], $entity->getAuthorUrl());
160163
}
161164
}
162165

tests/Mocks/Articles/diffbot-sitepoint-basic.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tests/Mocks/Articles/diffbot-sitepoint-extended.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)