mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-03-22 13:10:41 +08:00
fixing deletion issue in request refactoring, starting work on API read
refactoring
This commit is contained in:
parent
5d61b90d6b
commit
2e3bacb699
|
@ -6,6 +6,23 @@
|
||||||
"url: {
|
"url: {
|
||||||
"@id": "http://schema.org/url",
|
"@id": "http://schema.org/url",
|
||||||
"@type": "@id"
|
"@type": "@id"
|
||||||
}
|
},
|
||||||
|
"data": "http://schema.org/Text",
|
||||||
|
"attachment": "http://schema.org/Text",
|
||||||
|
"attachmentname": "http://schema.org/Text",
|
||||||
|
"meta": {
|
||||||
|
"formatter": "http://schema.org/Text",
|
||||||
|
"postdate": "http://schema.org/Integer",
|
||||||
|
"opendiscussion": "http://schema.org/True",
|
||||||
|
"burnafterreading": "http://schema.org/True",
|
||||||
|
"expire_date": "http://schema.org/Integer",
|
||||||
|
"remaining_time": "http://schema.org/Integer"
|
||||||
|
},
|
||||||
|
"comments": {
|
||||||
|
"@id": "comment.jsonld",
|
||||||
|
"@container": "@list"
|
||||||
|
},
|
||||||
|
"comment_count": "http://schema.org/Integer",
|
||||||
|
"comment_offset": "http://schema.org/Integer"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -89,7 +89,11 @@ class request
|
||||||
default:
|
default:
|
||||||
$this->_params = $_GET;
|
$this->_params = $_GET;
|
||||||
}
|
}
|
||||||
if (array_key_exists('QUERY_STRING', $_SERVER) && !empty($_SERVER['QUERY_STRING']))
|
if (
|
||||||
|
!array_key_exists('pasteid', $this->_params) &&
|
||||||
|
array_key_exists('QUERY_STRING', $_SERVER) &&
|
||||||
|
!empty($_SERVER['QUERY_STRING'])
|
||||||
|
)
|
||||||
{
|
{
|
||||||
$this->_params['pasteid'] = $_SERVER['QUERY_STRING'];
|
$this->_params['pasteid'] = $_SERVER['QUERY_STRING'];
|
||||||
}
|
}
|
||||||
|
@ -112,7 +116,6 @@ class request
|
||||||
{
|
{
|
||||||
$this->_operation = 'read';
|
$this->_operation = 'read';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,4 +136,21 @@ class jsonApiTest extends PHPUnit_Framework_TestCase
|
||||||
$this->assertFalse($this->_model->exists(helper::getPasteId()), 'paste successfully deleted');
|
$this->assertFalse($this->_model->exists(helper::getPasteId()), 'paste successfully deleted');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testRead()
|
||||||
|
{
|
||||||
|
$this->reset();
|
||||||
|
$this->_model->create(helper::getPasteId(), helper::getPaste());
|
||||||
|
$_SERVER['QUERY_STRING'] = helper::getPasteId();
|
||||||
|
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||||
|
ob_start();
|
||||||
|
new zerobin;
|
||||||
|
$content = ob_get_contents();
|
||||||
|
$response = json_decode($content, true);
|
||||||
|
$this->assertEquals(0, $response['status'], 'outputs success status');
|
||||||
|
$this->assertEquals(array(helper::getPaste()), $response['messages'], 'outputs data correctly');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user