improving code coverage and unit testing

This commit is contained in:
El RIDO
2016-07-18 14:47:32 +02:00
parent ff0c55c0d6
commit b53efda635
8 changed files with 139 additions and 15 deletions

View File

@@ -7,7 +7,6 @@ class privatebinTest extends PHPUnit_Framework_TestCase
{
/* Setup Routine */
$this->_model = privatebin_data::getInstance(array('dir' => PATH . 'data'));
serversalt::setPath(PATH . 'data');
$this->reset();
}
@@ -456,6 +455,28 @@ class privatebinTest extends PHPUnit_Framework_TestCase
);
}
/**
* @runInSeparateProcess
*/
public function testCreateTooSoon()
{
$this->reset();
$_POST = helper::getPaste();
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
$_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REMOTE_ADDR'] = '::1';
ob_start();
new privatebin;
ob_end_clean();
$this->_model->delete(helper::getPasteId());
ob_start();
new privatebin;
$content = ob_get_contents();
$response = json_decode($content, true);
$this->assertEquals(1, $response['status'], 'outputs error status');
$this->assertFalse($this->_model->exists(helper::getPasteId()), 'paste exists after posting data');
}
/**
* @runInSeparateProcess
*/