Browse Source

return url and code with no link when target URL provided

pull/39/head
Aaron Parecki 8 years ago
parent
commit
de060f110f
No known key found for this signature in database GPG Key ID: 276C2817346D6056
2 changed files with 5 additions and 2 deletions
  1. +3
    -1
      controllers/Parse.php
  2. +2
    -1
      tests/ParseTest.php

+ 3
- 1
controllers/Parse.php View File

@ -221,7 +221,9 @@ class Parse {
if(!$found) { if(!$found) {
return $this->respond($response, 200, [ return $this->respond($response, 200, [
'error' => 'no_link_found', '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'],
]); ]);
} }
} }

+ 2
- 1
tests/ParseTest.php View File

@ -48,6 +48,8 @@ class ParseTest extends PHPUnit_Framework_TestCase {
$data = json_decode($body); $data = json_decode($body);
$this->assertObjectHasAttribute('error', $data); $this->assertObjectHasAttribute('error', $data);
$this->assertEquals('no_link_found', $data->error); $this->assertEquals('no_link_found', $data->error);
$this->assertEquals('200', $data->code);
$this->assertEquals($url, $data->url);
} }
public function testTargetFound() { public function testTargetFound() {
@ -58,7 +60,6 @@ class ParseTest extends PHPUnit_Framework_TestCase {
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
$data = json_decode($body); $data = json_decode($body);
$this->assertObjectNotHasAttribute('error', $data); $this->assertObjectNotHasAttribute('error', $data);
$this->assertObjectNotHasAttribute('error', $data);
} }
public function testHTMLContent() { public function testHTMLContent() {

Loading…
Cancel
Save