diff --git a/README.md b/README.md index 3ab7145..49cf6eb 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Full documentation available [here](http://diffbot-php-client-docs.readthedocs.o ## Requirements -Minimum PHP 5.6 is required. +Minimum PHP 5.6 is required. PHP 7.0 is recommended. This package uses some non-stable packages, so you must set your project's minimum stability to something like beta or dev in `composer.json`: diff --git a/puli.json b/puli.json index 6398c43..db1fdc1 100644 --- a/puli.json +++ b/puli.json @@ -73,6 +73,10 @@ "installer": "composer", "env": "dev" }, + "paragonie/random_compat": { + "install-path": "vendor/paragonie/random_compat", + "installer": "composer" + }, "php-http/client-common": { "install-path": "vendor/php-http/client-common", "installer": "composer" @@ -220,6 +224,11 @@ "installer": "composer", "env": "dev" }, + "sebastian/object-enumerator": { + "install-path": "vendor/sebastian/object-enumerator", + "installer": "composer", + "env": "dev" + }, "sebastian/recursion-context": { "install-path": "vendor/sebastian/recursion-context", "installer": "composer", @@ -249,6 +258,10 @@ "installer": "composer", "env": "dev" }, + "symfony/filesystem": { + "install-path": "vendor/symfony/filesystem", + "installer": "composer" + }, "symfony/polyfill-mbstring": { "install-path": "vendor/symfony/polyfill-mbstring", "installer": "composer", diff --git a/src/Abstracts/Api.php b/src/Abstracts/Api.php index 45977ba..9281818 100644 --- a/src/Abstracts/Api.php +++ b/src/Abstracts/Api.php @@ -105,6 +105,8 @@ public function buildUrl() $url .= '&url=' . urlencode($this->url); } + $url .= '&timeout='.$this->timeout; + // Add Custom Fields $fields = $this->fieldSettings; $fieldString = ''; diff --git a/tests/Api/AnalyzeApiTest.php b/tests/Api/AnalyzeApiTest.php index 78778bc..a2132b1 100644 --- a/tests/Api/AnalyzeApiTest.php +++ b/tests/Api/AnalyzeApiTest.php @@ -40,7 +40,7 @@ public function testBuildUrlNoCustomFields() $url = $this ->apiWithMock ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/analyze?token=demo&url=https%3A%2F%2Farticle-mock.com'; + $expectedUrl = 'https://api.diffbot.com/v3/analyze?token=demo&url=https%3A%2F%2Farticle-mock.com&timeout=30000'; $this->assertEquals($expectedUrl, $url); } @@ -50,7 +50,7 @@ public function testBuildUrlOneCustomField() ->apiWithMock ->setMeta(true) ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/analyze?token=demo&url=https%3A%2F%2Farticle-mock.com&fields=meta'; + $expectedUrl = 'https://api.diffbot.com/v3/analyze?token=demo&url=https%3A%2F%2Farticle-mock.com&timeout=30000&fields=meta'; $this->assertEquals($expectedUrl, $url); } @@ -61,7 +61,7 @@ public function testBuildUrlTwoCustomFields() ->setMeta(true) ->setLinks(true) ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/analyze?token=demo&url=https%3A%2F%2Farticle-mock.com&fields=meta,links'; + $expectedUrl = 'https://api.diffbot.com/v3/analyze?token=demo&url=https%3A%2F%2Farticle-mock.com&timeout=30000&fields=meta,links'; $this->assertEquals($expectedUrl, $url); } @@ -74,7 +74,7 @@ public function testBuildUrlFourCustomFields() ->setBreadcrumb(true) ->setQuerystring(true) ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/analyze?token=demo&url=https%3A%2F%2Farticle-mock.com&fields=meta,links,breadcrumb,querystring'; + $expectedUrl = 'https://api.diffbot.com/v3/analyze?token=demo&url=https%3A%2F%2Farticle-mock.com&timeout=30000&fields=meta,links,breadcrumb,querystring'; $this->assertEquals($expectedUrl, $url); } @@ -85,7 +85,7 @@ public function testBuildUrlOtherOptionsOnly() ->setMode('article') ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/analyze?token=demo&url=https%3A%2F%2Farticle-mock.com&discussion=false&mode=article'; + $expectedUrl = 'https://api.diffbot.com/v3/analyze?token=demo&url=https%3A%2F%2Farticle-mock.com&timeout=30000&discussion=false&mode=article'; $this->assertEquals($expectedUrl, $url); } @@ -100,7 +100,7 @@ public function testBuildUrlOtherOptionsAndCustomFields() ->setDiscussion(false) ->setMode('product') ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/analyze?token=demo&url=https%3A%2F%2Farticle-mock.com&fields=meta,links,breadcrumb,querystring&discussion=false&mode=product'; + $expectedUrl = 'https://api.diffbot.com/v3/analyze?token=demo&url=https%3A%2F%2Farticle-mock.com&timeout=30000&fields=meta,links,breadcrumb,querystring&discussion=false&mode=product'; $this->assertEquals($expectedUrl, $url); } diff --git a/tests/Api/ArticleApiTest.php b/tests/Api/ArticleApiTest.php index 6f042d0..4b1946b 100644 --- a/tests/Api/ArticleApiTest.php +++ b/tests/Api/ArticleApiTest.php @@ -47,7 +47,7 @@ public function testBuildUrlNoCustomFields() $url = $this ->apiWithMock ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/article?token=demo&url=https%3A%2F%2Farticle-mock.com'; + $expectedUrl = 'https://api.diffbot.com/v3/article?token=demo&url=https%3A%2F%2Farticle-mock.com&timeout=30000'; $this->assertEquals($expectedUrl, $url); } @@ -57,7 +57,7 @@ public function testBuildUrlOneCustomField() ->apiWithMock ->setMeta(true) ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/article?token=demo&url=https%3A%2F%2Farticle-mock.com&fields=meta'; + $expectedUrl = 'https://api.diffbot.com/v3/article?token=demo&url=https%3A%2F%2Farticle-mock.com&timeout=30000&fields=meta'; $this->assertEquals($expectedUrl, $url); } @@ -68,7 +68,7 @@ public function testBuildUrlTwoCustomFields() ->setMeta(true) ->setLinks(true) ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/article?token=demo&url=https%3A%2F%2Farticle-mock.com&fields=meta,links'; + $expectedUrl = 'https://api.diffbot.com/v3/article?token=demo&url=https%3A%2F%2Farticle-mock.com&timeout=30000&fields=meta,links'; $this->assertEquals($expectedUrl, $url); } @@ -82,7 +82,7 @@ public function testBuildUrlFourCustomFields() ->setQuerystring(true) ->setSentiment(true) ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/article?token=demo&url=https%3A%2F%2Farticle-mock.com&fields=meta,links,breadcrumb,querystring,sentiment'; + $expectedUrl = 'https://api.diffbot.com/v3/article?token=demo&url=https%3A%2F%2Farticle-mock.com&timeout=30000&fields=meta,links,breadcrumb,querystring,sentiment'; $this->assertEquals($expectedUrl, $url); } @@ -94,7 +94,7 @@ public function testBuildUrlOtherOptionsOnly() ->setDiscussion(false) ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/article?token=demo&url=https%3A%2F%2Farticle-mock.com&paging=false&maxTags=10&discussion=false'; + $expectedUrl = 'https://api.diffbot.com/v3/article?token=demo&url=https%3A%2F%2Farticle-mock.com&timeout=30000&paging=false&maxTags=10&discussion=false'; $this->assertEquals($expectedUrl, $url); } @@ -109,7 +109,7 @@ public function testBuildUrlOtherOptionsAndCustomFields() ->setQuerystring(true) ->setMaxTags(10) ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/article?token=demo&url=https%3A%2F%2Farticle-mock.com&fields=meta,links,breadcrumb,querystring&paging=false&maxTags=10'; + $expectedUrl = 'https://api.diffbot.com/v3/article?token=demo&url=https%3A%2F%2Farticle-mock.com&timeout=30000&fields=meta,links,breadcrumb,querystring&paging=false&maxTags=10'; $this->assertEquals($expectedUrl, $url); } diff --git a/tests/Api/CrawlTest.php b/tests/Api/CrawlTest.php index da44460..3aec1c6 100644 --- a/tests/Api/CrawlTest.php +++ b/tests/Api/CrawlTest.php @@ -43,7 +43,7 @@ public function testBuildUrlArticleApi() { $api = $this->diffbot->createArticleAPI('crawl')->setDiscussion(false); - $expected = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Farticle%3F%26discussion%3Dfalse'; + $expected = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Farticle%3F%26timeout%3D30000%26discussion%3Dfalse'; $c = $this->diffbot->crawl('sitepoint_01', $api); $c->setSeeds(['http://sitepoint.com']); $this->assertEquals($expected, $c->buildUrl()); @@ -51,7 +51,7 @@ public function testBuildUrlArticleApi() public function testBuildUrlDefaultApi() { - $expected = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26mode%3Dauto'; + $expected = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26timeout%3D30000%26mode%3Dauto'; $c = $this->diffbot->crawl('sitepoint_01'); $c->setSeeds(['http://sitepoint.com']); $this->assertEquals($expected, $c->buildUrl()); @@ -67,7 +67,7 @@ public function testInvalidSeeds() public function testPatternSetters() { - $expected = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&pageProcessPattern=class%3DarticleBody&urlCrawlPattern=%2Fcategory%2Fshoes||%21%2Fauthor%2F||%5Ehttp%3A%2F%2Fwww.diffbot.com||type%3Dproduct%24&urlProcessPattern=%2Fproduct%2Fdetail||%21%3Fcurrency%3Deuro&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26mode%3Dauto'; + $expected = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&pageProcessPattern=class%3DarticleBody&urlCrawlPattern=%2Fcategory%2Fshoes||%21%2Fauthor%2F||%5Ehttp%3A%2F%2Fwww.diffbot.com||type%3Dproduct%24&urlProcessPattern=%2Fproduct%2Fdetail||%21%3Fcurrency%3Deuro&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26timeout%3D30000%26mode%3Dauto'; $c = $this->diffbot->crawl('sitepoint_01'); $c->setSeeds(['http://sitepoint.com']); @@ -85,7 +85,7 @@ public function testPatternSetters() public function testRegexSetters() { - $expected = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&urlCrawlRegEx=/^[a-z0-9_-]{3,16}$/&urlProcessRegEx=/^#?([a-f0-9]{6}|[a-f0-9]{3})$/&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26mode%3Dauto'; + $expected = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&urlCrawlRegEx=/^[a-z0-9_-]{3,16}$/&urlProcessRegEx=/^#?([a-f0-9]{6}|[a-f0-9]{3})$/&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26timeout%3D30000%26mode%3Dauto'; $c = $this->diffbot->crawl('sitepoint_01'); $c->setSeeds(['http://sitepoint.com']); @@ -114,7 +114,7 @@ public function maxHopsProvider() */ public function testMaxHops($input, $urlFragment) { - $expected = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&maxHops=' . $urlFragment . '&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26mode%3Dauto'; + $expected = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&maxHops=' . $urlFragment . '&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26timeout%3D30000%26mode%3Dauto'; $c = $this->diffbot->crawl('sitepoint_01'); $c->setSeeds(['http://sitepoint.com']); @@ -142,7 +142,7 @@ public function maxProvider() */ public function testMax($input, $urlFragment) { - $expected = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&maxToCrawl=' . $urlFragment . '&maxToProcess=' . $urlFragment . '&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26mode%3Dauto'; + $expected = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&maxToCrawl=' . $urlFragment . '&maxToProcess=' . $urlFragment . '&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26timeout%3D30000%26mode%3Dauto'; $c = $this->diffbot->crawl('sitepoint_01'); $c->setSeeds(['http://sitepoint.com']); @@ -177,7 +177,7 @@ public function notifyProviderOk() */ public function testNotify($input, $urlFragment) { - $expected = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&' . $urlFragment . '&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26mode%3Dauto'; + $expected = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&' . $urlFragment . '&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26timeout%3D30000%26mode%3Dauto'; $c = $this->diffbot->crawl('sitepoint_01'); $c->setSeeds(['http://sitepoint.com']); @@ -230,7 +230,7 @@ public function crawlDelayProviderOk() */ public function testCrawlOk($input, $urlFragment) { - $expected = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&crawlDelay=' . $urlFragment . '&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26mode%3Dauto'; + $expected = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&crawlDelay=' . $urlFragment . '&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26timeout%3D30000%26mode%3Dauto'; $c = $this->diffbot->crawl('sitepoint_01'); $c->setSeeds(['http://sitepoint.com']); @@ -280,7 +280,7 @@ public function repeatProviderOk() */ public function testRepeatOk($input, $urlFragment) { - $expected = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&repeat=' . $urlFragment . '&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26mode%3Dauto'; + $expected = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&repeat=' . $urlFragment . '&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26timeout%3D30000%26mode%3Dauto'; $c = $this->diffbot->crawl('sitepoint_01'); $c->setSeeds(['http://sitepoint.com']); @@ -314,8 +314,8 @@ public function testRepeatNotOk($input) public function testOnlyProcessIfNew() { - $expected1 = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&onlyProcessIfNew=1&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26mode%3Dauto'; - $expected2 = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&onlyProcessIfNew=0&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26mode%3Dauto'; + $expected1 = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&onlyProcessIfNew=1&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26timeout%3D30000%26mode%3Dauto'; + $expected2 = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&onlyProcessIfNew=0&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26timeout%3D30000%26mode%3Dauto'; $c = $this->diffbot->crawl('sitepoint_01'); $c->setSeeds(['http://sitepoint.com']); @@ -345,7 +345,7 @@ public function maxRoundsProvider() */ public function testMaxRounds($input, $urlFragment) { - $expected = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&maxRounds=' . $urlFragment . '&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26mode%3Dauto'; + $expected = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&maxRounds=' . $urlFragment . '&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26timeout%3D30000%26mode%3Dauto'; $c = $this->diffbot->crawl('sitepoint_01'); $c->setSeeds(['http://sitepoint.com']); @@ -356,8 +356,8 @@ public function testMaxRounds($input, $urlFragment) public function testObeyRobots() { - $expected1 = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&obeyRobots=1&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26mode%3Dauto'; - $expected2 = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&obeyRobots=0&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26mode%3Dauto'; + $expected1 = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&obeyRobots=1&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26timeout%3D30000%26mode%3Dauto'; + $expected2 = 'https://api.diffbot.com/v3/crawl?token=demo&name=sitepoint_01&seeds=http%3A%2F%2Fsitepoint.com&obeyRobots=0&apiUrl=https%3A%2F%2Fapi.diffbot.com%2Fv3%2Fanalyze%3F%26timeout%3D30000%26mode%3Dauto'; $c = $this->diffbot->crawl('sitepoint_01'); $c->setSeeds(['http://sitepoint.com']); diff --git a/tests/Api/CustomApiTest.php b/tests/Api/CustomApiTest.php index 8814a36..2948f33 100644 --- a/tests/Api/CustomApiTest.php +++ b/tests/Api/CustomApiTest.php @@ -37,23 +37,23 @@ public function apiNameProvider() return [ [ 'custom', - 'https://api.diffbot.com/v3/custom?token=demo&url=http%3A%2F%2Fsample-url.com' + 'https://api.diffbot.com/v3/custom?token=demo&url=http%3A%2F%2Fsample-url.com&timeout=30000' ], [ 'authorFolioNew', - 'https://api.diffbot.com/v3/authorFolioNew?token=demo&url=http%3A%2F%2Fsample-url.com' + 'https://api.diffbot.com/v3/authorFolioNew?token=demo&url=http%3A%2F%2Fsample-url.com&timeout=30000' ], [ 'authorFolioNew/something', - 'https://api.diffbot.com/v3/authorFolioNew/something?token=demo&url=http%3A%2F%2Fsample-url.com' + 'https://api.diffbot.com/v3/authorFolioNew/something?token=demo&url=http%3A%2F%2Fsample-url.com&timeout=30000' ], [ 'my-api', - 'https://api.diffbot.com/v3/my-api?token=demo&url=http%3A%2F%2Fsample-url.com' + 'https://api.diffbot.com/v3/my-api?token=demo&url=http%3A%2F%2Fsample-url.com&timeout=30000' ], [ 'my-api?param=value', - 'https://api.diffbot.com/v3/my-api?param=value?token=demo&url=http%3A%2F%2Fsample-url.com' + 'https://api.diffbot.com/v3/my-api?param=value?token=demo&url=http%3A%2F%2Fsample-url.com&timeout=30000' ] ]; } diff --git a/tests/Api/DiscussionApiTest.php b/tests/Api/DiscussionApiTest.php index 3b84371..e43f2e7 100644 --- a/tests/Api/DiscussionApiTest.php +++ b/tests/Api/DiscussionApiTest.php @@ -45,7 +45,7 @@ public function testBuildUrlNoCustomFields() $url = $this ->apiWithMock ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/discussion?token=demo&url=https%3A%2F%2Fdiscussion-mock.com'; + $expectedUrl = 'https://api.diffbot.com/v3/discussion?token=demo&url=https%3A%2F%2Fdiscussion-mock.com&timeout=30000'; $this->assertEquals($expectedUrl, $url); } @@ -55,7 +55,7 @@ public function testBuildUrlOneCustomField() ->apiWithMock ->setMeta(true) ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/discussion?token=demo&url=https%3A%2F%2Fdiscussion-mock.com&fields=meta'; + $expectedUrl = 'https://api.diffbot.com/v3/discussion?token=demo&url=https%3A%2F%2Fdiscussion-mock.com&timeout=30000&fields=meta'; $this->assertEquals($expectedUrl, $url); } @@ -66,7 +66,7 @@ public function testBuildUrlTwoCustomFields() ->setMeta(true) ->setLinks(true) ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/discussion?token=demo&url=https%3A%2F%2Fdiscussion-mock.com&fields=meta,links'; + $expectedUrl = 'https://api.diffbot.com/v3/discussion?token=demo&url=https%3A%2F%2Fdiscussion-mock.com&timeout=30000&fields=meta,links'; $this->assertEquals($expectedUrl, $url); } @@ -80,7 +80,7 @@ public function testBuildUrlFourCustomFields() ->setQuerystring(true) ->setSentiment(true) ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/discussion?token=demo&url=https%3A%2F%2Fdiscussion-mock.com&fields=meta,links,breadcrumb,querystring,sentiment'; + $expectedUrl = 'https://api.diffbot.com/v3/discussion?token=demo&url=https%3A%2F%2Fdiscussion-mock.com&timeout=30000&fields=meta,links,breadcrumb,querystring,sentiment'; $this->assertEquals($expectedUrl, $url); } @@ -90,7 +90,7 @@ public function testBuildUrlOtherOptionsOnly() ->setMaxPages(10) ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/discussion?token=demo&url=https%3A%2F%2Fdiscussion-mock.com&maxPages=10'; + $expectedUrl = 'https://api.diffbot.com/v3/discussion?token=demo&url=https%3A%2F%2Fdiscussion-mock.com&timeout=30000&maxPages=10'; $this->assertEquals($expectedUrl, $url); } @@ -104,7 +104,7 @@ public function testBuildUrlOtherOptionsAndCustomFields() ->setQuerystring(true) ->setMaxPages('all') ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/discussion?token=demo&url=https%3A%2F%2Fdiscussion-mock.com&fields=meta,links,breadcrumb,querystring&maxPages=all'; + $expectedUrl = 'https://api.diffbot.com/v3/discussion?token=demo&url=https%3A%2F%2Fdiscussion-mock.com&timeout=30000&fields=meta,links,breadcrumb,querystring&maxPages=all'; $this->assertEquals($expectedUrl, $url); } diff --git a/tests/Api/ImageApiTest.php b/tests/Api/ImageApiTest.php index 90c8bbc..5d44348 100644 --- a/tests/Api/ImageApiTest.php +++ b/tests/Api/ImageApiTest.php @@ -45,7 +45,7 @@ public function testBuildUrlNoCustomFields() $url = $this ->apiWithMock ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/image?token=demo&url=https%3A%2F%2Farticle-mock.com'; + $expectedUrl = 'https://api.diffbot.com/v3/image?token=demo&url=https%3A%2F%2Farticle-mock.com&timeout=30000'; $this->assertEquals($expectedUrl, $url); } @@ -55,7 +55,7 @@ public function testBuildUrlOneCustomField() ->apiWithMock ->setMeta(true) ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/image?token=demo&url=https%3A%2F%2Farticle-mock.com&fields=meta'; + $expectedUrl = 'https://api.diffbot.com/v3/image?token=demo&url=https%3A%2F%2Farticle-mock.com&timeout=30000&fields=meta'; $this->assertEquals($expectedUrl, $url); } @@ -66,7 +66,7 @@ public function testBuildUrlTwoCustomFields() ->setMeta(true) ->setLinks(true) ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/image?token=demo&url=https%3A%2F%2Farticle-mock.com&fields=meta,links'; + $expectedUrl = 'https://api.diffbot.com/v3/image?token=demo&url=https%3A%2F%2Farticle-mock.com&timeout=30000&fields=meta,links'; $this->assertEquals($expectedUrl, $url); } @@ -82,7 +82,7 @@ public function testBuildUrlFourCustomFields() ->setFaces(true) ->setMentions(true) ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/image?token=demo&url=https%3A%2F%2Farticle-mock.com&fields=meta,links,breadcrumb,querystring,ocr,faces,mentions'; + $expectedUrl = 'https://api.diffbot.com/v3/image?token=demo&url=https%3A%2F%2Farticle-mock.com&timeout=30000&fields=meta,links,breadcrumb,querystring,ocr,faces,mentions'; $this->assertEquals($expectedUrl, $url); } diff --git a/tests/Api/ProductApiTest.php b/tests/Api/ProductApiTest.php index 8f857ca..7c5c0d1 100644 --- a/tests/Api/ProductApiTest.php +++ b/tests/Api/ProductApiTest.php @@ -49,7 +49,7 @@ public function testBuildUrlNoCustomFields() $url = $this ->apiWithMock ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/product?token=demo&url=https%3A%2F%2Fdogbrush-mock.com'; + $expectedUrl = 'https://api.diffbot.com/v3/product?token=demo&url=https%3A%2F%2Fdogbrush-mock.com&timeout=30000'; $this->assertEquals($expectedUrl, $url); } @@ -61,7 +61,7 @@ public function testBuildUrlMultipleCustomFields() ->setSize(true) ->setAvailability(true) ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/product?token=demo&url=https%3A%2F%2Fdogbrush-mock.com&fields=colors,size,availability'; + $expectedUrl = 'https://api.diffbot.com/v3/product?token=demo&url=https%3A%2F%2Fdogbrush-mock.com&timeout=30000&fields=colors,size,availability'; $this->assertEquals($expectedUrl, $url); } @@ -74,7 +74,7 @@ public function testBuildUrlMultipleCustomFieldsAndOtherOptions() ->setAvailability(true) ->setDiscussion(false) ->buildUrl(); - $expectedUrl = 'https://api.diffbot.com/v3/product?token=demo&url=https%3A%2F%2Fdogbrush-mock.com&fields=colors,size,availability&discussion=false'; + $expectedUrl = 'https://api.diffbot.com/v3/product?token=demo&url=https%3A%2F%2Fdogbrush-mock.com&timeout=30000&fields=colors,size,availability&discussion=false'; $this->assertEquals($expectedUrl, $url); } } diff --git a/tests/Api/SearchCustomMocksTest.php b/tests/Api/SearchCustomMocksTest.php index 810b185..5c11157 100644 --- a/tests/Api/SearchCustomMocksTest.php +++ b/tests/Api/SearchCustomMocksTest.php @@ -108,7 +108,7 @@ public function searchInfoProvider() */ public function testSearchInfo($case, $expectations) { - $this->markTestSkipped('Bugged due to JSONC: https://github.com/Swader/diffbot-php-client/issues/12'); +// $this->markTestSkipped('Bugged due to JSONC: https://github.com/Swader/diffbot-php-client/issues/12'); $this->diffbot->setHttpClient($this->getCustomMockFakeClient($this->mockPrefix . $case['file'])); $searchInfo = $this->diffbot->search($case['q'])->call(true);