Merge branch 'master' into burnafterreading-fix, regression in expired paste error
This commit is contained in:
@@ -16,13 +16,13 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
/* Setup Routine */
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
$this->_model = Filesystem::getInstance(array('dir' => $this->_path));
|
||||
ServerSalt::setPath($this->_path);
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
/* Tear Down Routine */
|
||||
unlink(CONF);
|
||||
Helper::confRestore();
|
||||
Helper::rmDir($this->_path);
|
||||
}
|
||||
@@ -35,13 +35,12 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
if ($this->_model->exists(Helper::getPasteId())) {
|
||||
$this->_model->delete(Helper::getPasteId());
|
||||
}
|
||||
Helper::confRestore();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF_SAMPLE, true);
|
||||
$options['purge']['dir'] = $this->_path;
|
||||
$options['traffic']['dir'] = $this->_path;
|
||||
$options['model_options']['dir'] = $this->_path;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
ServerSalt::setPath($this->_path);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,7 +48,6 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testView()
|
||||
{
|
||||
$this->reset();
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
@@ -71,10 +69,8 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testViewLanguageSelection()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['main']['languageselection'] = true;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_COOKIE['lang'] = 'de';
|
||||
ob_start();
|
||||
@@ -93,11 +89,9 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testViewForceLanguageDefault()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['main']['languageselection'] = false;
|
||||
$options['main']['languagedefault'] = 'fr';
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_COOKIE['lang'] = 'de';
|
||||
ob_start();
|
||||
@@ -116,11 +110,9 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testViewUrlShortener()
|
||||
{
|
||||
$shortener = 'https://shortener.example.com/api?link=';
|
||||
$this->reset();
|
||||
$shortener = 'https://shortener.example.com/api?link=';
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['main']['urlshortener'] = $shortener;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_COOKIE['lang'] = 'de';
|
||||
ob_start();
|
||||
@@ -139,7 +131,6 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testHtaccess()
|
||||
{
|
||||
$this->reset();
|
||||
$file = $this->_path . DIRECTORY_SEPARATOR . '.htaccess';
|
||||
@unlink($file);
|
||||
|
||||
@@ -160,8 +151,6 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testConf()
|
||||
{
|
||||
$this->reset();
|
||||
Helper::confBackup();
|
||||
file_put_contents(CONF, '');
|
||||
new PrivateBin;
|
||||
}
|
||||
@@ -171,10 +160,8 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPaste();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
@@ -200,10 +187,8 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCreateInvalidTimelimit()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPaste(array('expire' => 25));
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
@@ -230,11 +215,9 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCreateInvalidSize()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['main']['sizelimit'] = 10;
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPaste();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
@@ -254,10 +237,8 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCreateProxyHeader()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['header'] = 'X_FORWARDED_FOR';
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPaste();
|
||||
$_SERVER['HTTP_X_FORWARDED_FOR'] = '::2';
|
||||
@@ -284,10 +265,8 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCreateDuplicateId()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$this->_model->create(Helper::getPasteId(), Helper::getPaste());
|
||||
$_POST = Helper::getPaste();
|
||||
@@ -308,10 +287,8 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCreateValidExpire()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST['expire'] = '5min';
|
||||
@@ -341,10 +318,8 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCreateValidExpireWithDiscussion()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST['expire'] = '5min';
|
||||
@@ -375,10 +350,8 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCreateInvalidExpire()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST['expire'] = 'foo';
|
||||
@@ -405,10 +378,8 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCreateInvalidBurn()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST['burnafterreading'] = 'neither 1 nor 0';
|
||||
@@ -429,10 +400,8 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCreateInvalidOpenDiscussion()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST['opendiscussion'] = 'neither 1 nor 0';
|
||||
@@ -453,11 +422,9 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCreateAttachment()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
$options['main']['fileupload'] = true;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPasteWithAttachment();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
@@ -491,11 +458,9 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCreateBrokenAttachmentUpload()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
$options['main']['fileupload'] = true;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPasteWithAttachment();
|
||||
unset($_POST['attachment']);
|
||||
@@ -517,7 +482,6 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCreateTooSoon()
|
||||
{
|
||||
$this->reset();
|
||||
$_POST = Helper::getPaste();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
@@ -540,10 +504,8 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCreateValidNick()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST['nickname'] = Helper::getComment()['meta']['nickname'];
|
||||
@@ -570,10 +532,8 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCreateInvalidNick()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getCommentPost();
|
||||
$_POST['pasteid'] = Helper::getPasteId();
|
||||
@@ -597,10 +557,8 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCreateComment()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getCommentPost();
|
||||
$_POST['pasteid'] = Helper::getPasteId();
|
||||
@@ -623,10 +581,8 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCreateInvalidComment()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getCommentPost();
|
||||
$_POST['pasteid'] = Helper::getPasteId();
|
||||
@@ -649,10 +605,8 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCreateCommentDiscussionDisabled()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getCommentPost();
|
||||
$_POST['pasteid'] = Helper::getPasteId();
|
||||
@@ -676,10 +630,8 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCreateCommentInvalidPaste()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getCommentPost();
|
||||
$_POST['pasteid'] = Helper::getPasteId();
|
||||
@@ -701,10 +653,8 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCreateDuplicateComment()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$this->_model->create(Helper::getPasteId(), Helper::getPaste());
|
||||
$this->_model->createComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId(), Helper::getComment());
|
||||
@@ -724,33 +674,11 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertTrue($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'paste exists after posting data');
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testRead()
|
||||
{
|
||||
$this->reset();
|
||||
$this->_model->create(Helper::getPasteId(), Helper::getPaste());
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertRegExp(
|
||||
'#<div id="cipherdata"[^>]*>' .
|
||||
preg_quote(htmlspecialchars(Helper::getPasteAsJson(), ENT_NOQUOTES)) .
|
||||
'</div>#',
|
||||
$content,
|
||||
'outputs data correctly'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testReadInvalidId()
|
||||
{
|
||||
$this->reset();
|
||||
$_SERVER['QUERY_STRING'] = 'foo';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
@@ -768,7 +696,6 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testReadNonexisting()
|
||||
{
|
||||
$this->reset();
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
@@ -786,7 +713,6 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testReadExpired()
|
||||
{
|
||||
$this->reset();
|
||||
$expiredPaste = Helper::getPaste(array('expire_date' => 1344803344));
|
||||
$this->_model->create(Helper::getPasteId(), $expiredPaste);
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
@@ -806,22 +732,27 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testReadBurn()
|
||||
{
|
||||
$this->reset();
|
||||
$burnPaste = Helper::getPaste(array('burnafterreading' => true));
|
||||
$this->_model->create(Helper::getPasteId(), $burnPaste);
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
$paste = Helper::getPaste(array('burnafterreading' => true));
|
||||
$this->_model->create(Helper::getPasteId(), $paste);
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
unset($burnPaste['meta']['salt']);
|
||||
$this->assertRegExp(
|
||||
'#<div id="cipherdata"[^>]*>' .
|
||||
preg_quote(htmlspecialchars(Helper::getPasteAsJson($burnPaste['meta']), ENT_NOQUOTES)) .
|
||||
'</div>#',
|
||||
$content,
|
||||
'outputs data correctly'
|
||||
);
|
||||
$response = json_decode($content, true);
|
||||
$this->assertEquals(0, $response['status'], 'outputs success status');
|
||||
$this->assertEquals(Helper::getPasteId(), $response['id'], 'outputs data correctly');
|
||||
$this->assertStringEndsWith('?' . $response['id'], $response['url'], 'returned URL points to new paste');
|
||||
$this->assertEquals($paste['data'], $response['data'], 'outputs data correctly');
|
||||
$this->assertEquals($paste['meta']['formatter'], $response['meta']['formatter'], 'outputs format correctly');
|
||||
$this->assertEquals($paste['meta']['postdate'], $response['meta']['postdate'], 'outputs postdate correctly');
|
||||
$this->assertEquals($paste['meta']['opendiscussion'], $response['meta']['opendiscussion'], 'outputs opendiscussion correctly');
|
||||
$this->assertEquals(1, $response['meta']['burnafterreading'], 'outputs burnafterreading correctly');
|
||||
$this->assertEquals(0, $response['comment_count'], 'outputs comment_count correctly');
|
||||
$this->assertEquals(0, $response['comment_offset'], 'outputs comment_offset correctly');
|
||||
// by default it will be deleted instantly after it is read
|
||||
$this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste exists after reading');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -829,7 +760,6 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testReadJson()
|
||||
{
|
||||
$this->reset();
|
||||
$paste = Helper::getPaste();
|
||||
$this->_model->create(Helper::getPasteId(), $paste);
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
@@ -855,7 +785,6 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testReadInvalidJson()
|
||||
{
|
||||
$this->reset();
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
ob_start();
|
||||
@@ -871,53 +800,29 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testReadOldSyntax()
|
||||
{
|
||||
$this->reset();
|
||||
$oldPaste = Helper::getPaste();
|
||||
$meta = array(
|
||||
$paste = Helper::getPaste();
|
||||
$paste['meta'] = array(
|
||||
'syntaxcoloring' => true,
|
||||
'postdate' => $oldPaste['meta']['postdate'],
|
||||
'opendiscussion' => $oldPaste['meta']['opendiscussion'],
|
||||
'postdate' => $paste['meta']['postdate'],
|
||||
'opendiscussion' => $paste['meta']['opendiscussion'],
|
||||
);
|
||||
$oldPaste['meta'] = $meta;
|
||||
$this->_model->create(Helper::getPasteId(), $oldPaste);
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
$this->_model->create(Helper::getPasteId(), $paste);
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$meta['formatter'] = 'syntaxhighlighting';
|
||||
$this->assertRegExp(
|
||||
'#<div id="cipherdata"[^>]*>' .
|
||||
preg_quote(htmlspecialchars(Helper::getPasteAsJson($meta), ENT_NOQUOTES)) .
|
||||
'</div>#',
|
||||
$content,
|
||||
'outputs data correctly'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testReadOldFormat()
|
||||
{
|
||||
$this->reset();
|
||||
$oldPaste = Helper::getPaste();
|
||||
unset($oldPaste['meta']['formatter']);
|
||||
$this->_model->create(Helper::getPasteId(), $oldPaste);
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$oldPaste['meta']['formatter'] = 'plaintext';
|
||||
unset($oldPaste['meta']['salt']);
|
||||
$this->assertRegExp(
|
||||
'#<div id="cipherdata"[^>]*>' .
|
||||
preg_quote(htmlspecialchars(Helper::getPasteAsJson($oldPaste['meta']), ENT_NOQUOTES)) .
|
||||
'</div>#',
|
||||
$content,
|
||||
'outputs data correctly'
|
||||
);
|
||||
$response = json_decode($content, true);
|
||||
$this->assertEquals(0, $response['status'], 'outputs success status');
|
||||
$this->assertEquals(Helper::getPasteId(), $response['id'], 'outputs data correctly');
|
||||
$this->assertStringEndsWith('?' . $response['id'], $response['url'], 'returned URL points to new paste');
|
||||
$this->assertEquals($paste['data'], $response['data'], 'outputs data correctly');
|
||||
$this->assertEquals('syntaxhighlighting', $response['meta']['formatter'], 'outputs format correctly');
|
||||
$this->assertEquals($paste['meta']['postdate'], $response['meta']['postdate'], 'outputs postdate correctly');
|
||||
$this->assertEquals($paste['meta']['opendiscussion'], $response['meta']['opendiscussion'], 'outputs opendiscussion correctly');
|
||||
$this->assertEquals(0, $response['comment_count'], 'outputs comment_count correctly');
|
||||
$this->assertEquals(0, $response['comment_offset'], 'outputs comment_offset correctly');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -925,7 +830,6 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testDelete()
|
||||
{
|
||||
$this->reset();
|
||||
$this->_model->create(Helper::getPasteId(), Helper::getPaste());
|
||||
$this->assertTrue($this->_model->exists(Helper::getPasteId()), 'paste exists before deleting data');
|
||||
$paste = $this->_model->read(Helper::getPasteId());
|
||||
@@ -948,7 +852,6 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testDeleteInvalidId()
|
||||
{
|
||||
$this->reset();
|
||||
$this->_model->create(Helper::getPasteId(), Helper::getPaste());
|
||||
$_GET['pasteid'] = 'foo';
|
||||
$_GET['deletetoken'] = 'bar';
|
||||
@@ -969,7 +872,6 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testDeleteInexistantId()
|
||||
{
|
||||
$this->reset();
|
||||
$_GET['pasteid'] = Helper::getPasteId();
|
||||
$_GET['deletetoken'] = 'bar';
|
||||
ob_start();
|
||||
@@ -988,7 +890,6 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testDeleteInvalidToken()
|
||||
{
|
||||
$this->reset();
|
||||
$this->_model->create(Helper::getPasteId(), Helper::getPaste());
|
||||
$_GET['pasteid'] = Helper::getPasteId();
|
||||
$_GET['deletetoken'] = 'bar';
|
||||
@@ -1009,7 +910,6 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testDeleteBurnAfterReading()
|
||||
{
|
||||
$this->reset();
|
||||
$burnPaste = Helper::getPaste(array('burnafterreading' => true));
|
||||
$this->_model->create(Helper::getPasteId(), $burnPaste);
|
||||
$this->assertTrue($this->_model->exists(Helper::getPasteId()), 'paste exists before deleting data');
|
||||
@@ -1031,7 +931,6 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testDeleteInvalidBurnAfterReading()
|
||||
{
|
||||
$this->reset();
|
||||
$this->_model->create(Helper::getPasteId(), Helper::getPaste());
|
||||
$this->assertTrue($this->_model->exists(Helper::getPasteId()), 'paste exists before deleting data');
|
||||
$_POST['deletetoken'] = 'burnafterreading';
|
||||
@@ -1052,7 +951,6 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testDeleteExpired()
|
||||
{
|
||||
$this->reset();
|
||||
$expiredPaste = Helper::getPaste(array('expire_date' => 1000));
|
||||
$this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does not exist before being created');
|
||||
$this->_model->create(Helper::getPasteId(), $expiredPaste);
|
||||
@@ -1076,7 +974,6 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testDeleteMissingPerPasteSalt()
|
||||
{
|
||||
$this->reset();
|
||||
$paste = Helper::getPaste();
|
||||
unset($paste['meta']['salt']);
|
||||
$this->_model->create(Helper::getPasteId(), $paste);
|
||||
|
||||
Reference in New Issue
Block a user