From de060f110f250b5932fb839555af1183e10cc216 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Mon, 16 Jan 2017 13:04:17 -0800 Subject: [PATCH] return url and code with no link when target URL provided --- controllers/Parse.php | 4 +++- tests/ParseTest.php | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/controllers/Parse.php b/controllers/Parse.php index 1dc5322..eebe12a 100644 --- a/controllers/Parse.php +++ b/controllers/Parse.php @@ -221,7 +221,9 @@ class Parse { if(!$found) { return $this->respond($response, 200, [ 'error' => 'no_link_found', - 'error_description' => 'The source document does not have a link to the target URL' + 'error_description' => 'The source document does not have a link to the target URL', + 'url' => $result['url'], + 'code' => $result['code'], ]); } } diff --git a/tests/ParseTest.php b/tests/ParseTest.php index 534f328..8dead17 100644 --- a/tests/ParseTest.php +++ b/tests/ParseTest.php @@ -48,6 +48,8 @@ class ParseTest extends PHPUnit_Framework_TestCase { $data = json_decode($body); $this->assertObjectHasAttribute('error', $data); $this->assertEquals('no_link_found', $data->error); + $this->assertEquals('200', $data->code); + $this->assertEquals($url, $data->url); } public function testTargetFound() { @@ -58,7 +60,6 @@ class ParseTest extends PHPUnit_Framework_TestCase { $this->assertEquals(200, $response->getStatusCode()); $data = json_decode($body); $this->assertObjectNotHasAttribute('error', $data); - $this->assertObjectNotHasAttribute('error', $data); } public function testHTMLContent() {