applying patch based on StyleCI ruleset

This commit is contained in:
El RIDO
2016-10-29 10:24:08 +02:00
parent c8b1296929
commit 1f46823942
33 changed files with 430 additions and 452 deletions

View File

@@ -1,5 +1,6 @@
<?php
use Identicon\Identicon;
use PrivateBin\Configuration;
use PrivateBin\Data\Database;
use PrivateBin\Model;
@@ -7,7 +8,6 @@ use PrivateBin\Model\Paste;
use PrivateBin\Persistence\ServerSalt;
use PrivateBin\Persistence\TrafficLimiter;
use PrivateBin\Vizhash16x16;
use Identicon\Identicon;
class ModelTest extends PHPUnit_Framework_TestCase
{
@@ -22,11 +22,13 @@ class ModelTest extends PHPUnit_Framework_TestCase
/* Setup Routine */
Helper::confRestore();
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
if (!is_dir($this->_path)) mkdir($this->_path);
if (!is_dir($this->_path)) {
mkdir($this->_path);
}
ServerSalt::setPath($this->_path);
$options = parse_ini_file(CONF, true);
$options = parse_ini_file(CONF, true);
$options['purge']['limit'] = 0;
$options['model'] = array(
$options['model'] = array(
'class' => 'Database',
);
$options['model_options'] = array(
@@ -37,8 +39,8 @@ class ModelTest extends PHPUnit_Framework_TestCase
);
Helper::confBackup();
Helper::createIniFile(CONF, $options);
$this->_conf = new Configuration;
$this->_model = new Model($this->_conf);
$this->_conf = new Configuration;
$this->_model = new Model($this->_conf);
$_SERVER['REMOTE_ADDR'] = '::1';
}
@@ -73,8 +75,8 @@ class ModelTest extends PHPUnit_Framework_TestCase
// storing comments
$commentData = Helper::getComment();
$paste = $this->_model->getPaste(Helper::getPasteId());
$comment = $paste->getComment(Helper::getPasteId(), Helper::getCommentId());
$paste = $this->_model->getPaste(Helper::getPasteId());
$comment = $paste->getComment(Helper::getPasteId(), Helper::getCommentId());
$this->assertFalse($comment->exists(), 'comment does not yet exist');
$comment = $paste->getComment(Helper::getPasteId());
@@ -123,7 +125,7 @@ class ModelTest extends PHPUnit_Framework_TestCase
*/
public function testCommentDuplicate()
{
$pasteData = Helper::getPaste();
$pasteData = Helper::getPaste();
$commentData = Helper::getComment();
$this->_model->getPaste(Helper::getPasteId())->delete();
@@ -146,7 +148,7 @@ class ModelTest extends PHPUnit_Framework_TestCase
public function testImplicitDefaults()
{
$pasteData = Helper::getPaste();
$pasteData = Helper::getPaste();
$commentData = Helper::getComment();
$this->_model->getPaste(Helper::getPasteId())->delete();
@@ -175,8 +177,8 @@ class ModelTest extends PHPUnit_Framework_TestCase
$comment->store();
$identicon = new Identicon();
$pngdata = $identicon->getImageDataUri(TrafficLimiter::getHash(), 16);
$comment = $paste->getComment(Helper::getPasteId(), Helper::getCommentId())->get();
$pngdata = $identicon->getImageDataUri(TrafficLimiter::getHash(), 16);
$comment = $paste->getComment(Helper::getPasteId(), Helper::getCommentId())->get();
$this->assertEquals($pngdata, $comment->meta->vizhash, 'nickname triggers vizhash to be set');
}
@@ -230,13 +232,13 @@ class ModelTest extends PHPUnit_Framework_TestCase
public function testPurge()
{
$conf = new Configuration;
$conf = new Configuration;
$store = Database::getInstance($conf->getSection('model_options'));
$store->delete(Helper::getPasteId());
$expired = Helper::getPaste(array('expire_date' => 1344803344));
$paste = Helper::getPaste(array('expire_date' => time() + 3600));
$keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'x', 'y', 'z');
$ids = array();
$paste = Helper::getPaste(array('expire_date' => time() + 3600));
$keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'x', 'y', 'z');
$ids = array();
foreach ($keys as $key) {
$ids[$key] = substr(md5($key), 0, 16);
$store->delete($ids[$key]);
@@ -261,9 +263,9 @@ class ModelTest extends PHPUnit_Framework_TestCase
public function testCommentWithDisabledVizhash()
{
$options = parse_ini_file(CONF, true);
$options = parse_ini_file(CONF, true);
$options['main']['icon'] = 'none';
$options['model'] = array(
$options['model'] = array(
'class' => 'Database',
);
$options['model_options'] = array(
@@ -297,8 +299,8 @@ class ModelTest extends PHPUnit_Framework_TestCase
// storing comments
$commentData = Helper::getComment();
$paste = $model->getPaste(Helper::getPasteId());
$comment = $paste->getComment(Helper::getPasteId(), Helper::getCommentId());
$paste = $model->getPaste(Helper::getPasteId());
$comment = $paste->getComment(Helper::getPasteId(), Helper::getCommentId());
$this->assertFalse($comment->exists(), 'comment does not yet exist');
$comment = $paste->getComment(Helper::getPasteId());
@@ -316,9 +318,9 @@ class ModelTest extends PHPUnit_Framework_TestCase
public function testCommentIdenticon()
{
$options = parse_ini_file(CONF, true);
$options = parse_ini_file(CONF, true);
$options['main']['icon'] = 'identicon';
$options['model'] = array(
$options['model'] = array(
'class' => 'Database',
);
$options['model_options'] = array(
@@ -331,7 +333,7 @@ class ModelTest extends PHPUnit_Framework_TestCase
Helper::createIniFile(CONF, $options);
$model = new Model(new Configuration);
$pasteData = Helper::getPaste();
$pasteData = Helper::getPaste();
$commentData = Helper::getComment();
$model->getPaste(Helper::getPasteId())->delete();
@@ -347,16 +349,16 @@ class ModelTest extends PHPUnit_Framework_TestCase
$comment->store();
$identicon = new Identicon();
$pngdata = $identicon->getImageDataUri(TrafficLimiter::getHash(), 16);
$comment = $paste->getComment(Helper::getPasteId(), Helper::getCommentId())->get();
$pngdata = $identicon->getImageDataUri(TrafficLimiter::getHash(), 16);
$comment = $paste->getComment(Helper::getPasteId(), Helper::getCommentId())->get();
$this->assertEquals($pngdata, $comment->meta->vizhash, 'nickname triggers vizhash to be set');
}
public function testCommentVizhash()
{
$options = parse_ini_file(CONF, true);
$options = parse_ini_file(CONF, true);
$options['main']['icon'] = 'vizhash';
$options['model'] = array(
$options['model'] = array(
'class' => 'Database',
);
$options['model_options'] = array(
@@ -369,7 +371,7 @@ class ModelTest extends PHPUnit_Framework_TestCase
Helper::createIniFile(CONF, $options);
$model = new Model(new Configuration);
$pasteData = Helper::getPaste();
$pasteData = Helper::getPaste();
$commentData = Helper::getComment();
$model->getPaste(Helper::getPasteId())->delete();
@@ -384,7 +386,7 @@ class ModelTest extends PHPUnit_Framework_TestCase
$comment->setNickname($commentData['meta']['nickname']);
$comment->store();
$vz = new Vizhash16x16();
$vz = new Vizhash16x16();
$pngdata = 'data:image/png;base64,' . base64_encode($vz->generate(TrafficLimiter::getHash()));
$comment = $paste->getComment(Helper::getPasteId(), Helper::getCommentId())->get();
$this->assertEquals($pngdata, $comment->meta->vizhash, 'nickname triggers vizhash to be set');