mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-10-01 01:26:10 -04:00
fixing deprecations with newer phpunit versions
This commit is contained in:
parent
1158c81259
commit
e89a8b6898
@ -62,54 +62,36 @@ class RainTPLTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testTemplateRendersCorrectly()
|
||||
{
|
||||
$this->assertTag(
|
||||
array(
|
||||
'id' => 'cipherdata',
|
||||
'content' => htmlspecialchars(helper::getPaste()['data'], ENT_NOQUOTES)
|
||||
),
|
||||
$this->assertContains(
|
||||
'<div id="cipherdata" class="hidden">' .
|
||||
htmlspecialchars(helper::getPaste()['data'], ENT_NOQUOTES) .
|
||||
'</div>',
|
||||
$this->_content,
|
||||
'outputs data correctly'
|
||||
);
|
||||
$this->assertTag(
|
||||
array(
|
||||
'id' => 'errormessage',
|
||||
'content' => self::$error
|
||||
),
|
||||
$this->assertRegExp(
|
||||
'#<div[^>]+id="errormessage"[^>]*>.*' . self::$error . '</div>#',
|
||||
$this->_content,
|
||||
'outputs error correctly'
|
||||
);
|
||||
$this->assertTag(
|
||||
array(
|
||||
'id' => 'password',
|
||||
),
|
||||
$this->assertRegExp(
|
||||
'#<[^>]+id="password"[^>]*>#',
|
||||
$this->_content,
|
||||
'password available if configured'
|
||||
);
|
||||
$this->assertTag(
|
||||
array(
|
||||
'id' => 'opendiscussion',
|
||||
'attributes' => array(
|
||||
'checked' => 'checked'
|
||||
),
|
||||
),
|
||||
$this->assertRegExp(
|
||||
'#<input[^>]+id="opendiscussion"[^>]*checked="checked"[^>]*>#',
|
||||
$this->_content,
|
||||
'checked discussion if configured'
|
||||
);
|
||||
$this->assertTag(
|
||||
array(
|
||||
'id' => 'opendisc',
|
||||
),
|
||||
$this->assertRegExp(
|
||||
'#<[^>]+id="opendisc"[^>]*>#',
|
||||
$this->_content,
|
||||
'discussions available if configured'
|
||||
);
|
||||
// testing version number in JS address, since other instances may not be present in different templates
|
||||
$this->assertTag(
|
||||
array(
|
||||
'tag' => 'script',
|
||||
'attributes' => array(
|
||||
'src' => 'js/zerobin.js?' . rawurlencode(self::$version)
|
||||
),
|
||||
),
|
||||
$this->assertRegExp(
|
||||
'#<script[^>]+src="js/zerobin.js\\?' . rawurlencode(self::$version) . '"[^>]*>#',
|
||||
$this->_content,
|
||||
'outputs version correctly'
|
||||
);
|
||||
|
@ -2,9 +2,10 @@
|
||||
error_reporting( E_ALL | E_STRICT );
|
||||
|
||||
// change this, if your php files and data is outside of your webservers document root
|
||||
if (!defined('PUBLIC_PATH')) define('PUBLIC_PATH', '..');
|
||||
if (!defined('PATH')) define('PATH', '..' . DIRECTORY_SEPARATOR);
|
||||
if (!defined('CONF')) define('CONF', PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini');
|
||||
if (!defined('PUBLIC_PATH')) define('PUBLIC_PATH', '..');
|
||||
if (!is_file(CONF)) copy(CONF . '.sample', CONF);
|
||||
|
||||
require PATH . 'lib/auto.php';
|
||||
|
||||
|
@ -579,11 +579,10 @@ EOT;
|
||||
case 'Read':
|
||||
$code .= <<<'EOT'
|
||||
|
||||
$this->assertTag(
|
||||
array(
|
||||
'id' => 'cipherdata',
|
||||
'content' => htmlspecialchars(helper::getPasteAsJson(), ENT_NOQUOTES)
|
||||
),
|
||||
$this->assertContains(
|
||||
'<div id="cipherdata" class="hidden">' .
|
||||
htmlspecialchars(helper::getPasteAsJson(), ENT_NOQUOTES) .
|
||||
'</div>',
|
||||
$content,
|
||||
'outputs data correctly'
|
||||
);
|
||||
@ -592,11 +591,8 @@ EOT;
|
||||
case 'Delete':
|
||||
$code .= <<<'EOT'
|
||||
|
||||
$this->assertTag(
|
||||
array(
|
||||
'id' => 'status',
|
||||
'content' => 'Paste was properly deleted'
|
||||
),
|
||||
$this->assertRegExp(
|
||||
'#<div[^>]*id="status"[^>]*>.*Paste was properly deleted</div>#',
|
||||
$content,
|
||||
'outputs deleted status correctly'
|
||||
);
|
||||
|
127
tst/zerobin.php
127
tst/zerobin.php
@ -36,18 +36,13 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
||||
ob_start();
|
||||
new zerobin;
|
||||
$content = ob_get_contents();
|
||||
$this->assertTag(
|
||||
array(
|
||||
'tag' => 'title',
|
||||
'content' => 'ZeroBin'
|
||||
),
|
||||
$this->assertContains(
|
||||
'<title>ZeroBin</title>',
|
||||
$content,
|
||||
'outputs title correctly'
|
||||
);
|
||||
$this->assertNotTag(
|
||||
array(
|
||||
'id' => 'shortenbutton'
|
||||
),
|
||||
$this->assertNotContains(
|
||||
'id="shortenbutton"',
|
||||
$content,
|
||||
'doesn\'t output shortener button'
|
||||
);
|
||||
@ -67,11 +62,8 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
||||
ob_start();
|
||||
new zerobin;
|
||||
$content = ob_get_contents();
|
||||
$this->assertTag(
|
||||
array(
|
||||
'tag' => 'title',
|
||||
'content' => 'ZeroBin'
|
||||
),
|
||||
$this->assertContains(
|
||||
'<title>ZeroBin</title>',
|
||||
$content,
|
||||
'outputs title correctly'
|
||||
);
|
||||
@ -92,11 +84,8 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
||||
ob_start();
|
||||
new zerobin;
|
||||
$content = ob_get_contents();
|
||||
$this->assertTag(
|
||||
array(
|
||||
'tag' => 'title',
|
||||
'content' => 'ZeroBin'
|
||||
),
|
||||
$this->assertContains(
|
||||
'<title>ZeroBin</title>',
|
||||
$content,
|
||||
'outputs title correctly'
|
||||
);
|
||||
@ -117,11 +106,8 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
||||
ob_start();
|
||||
new zerobin;
|
||||
$content = ob_get_contents();
|
||||
$this->assertTag(
|
||||
array(
|
||||
'id' => 'shortenbutton',
|
||||
'attributes' => array('data-shortener' => $shortener)
|
||||
),
|
||||
$this->assertRegExp(
|
||||
'#id="shortenbutton"[^>]*data-shortener="' . preg_quote($shortener) . '"#',
|
||||
$content,
|
||||
'outputs configured shortener URL correctly'
|
||||
);
|
||||
@ -248,6 +234,7 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
||||
$_SERVER['HTTP_X_FORWARDED_FOR'] = '::1';
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
ob_start();
|
||||
new zerobin;
|
||||
$content = ob_get_contents();
|
||||
@ -642,11 +629,10 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
||||
ob_start();
|
||||
new zerobin;
|
||||
$content = ob_get_contents();
|
||||
$this->assertTag(
|
||||
array(
|
||||
'id' => 'cipherdata',
|
||||
'content' => htmlspecialchars(helper::getPasteAsJson(), ENT_NOQUOTES)
|
||||
),
|
||||
$this->assertContains(
|
||||
'<div id="cipherdata" class="hidden">' .
|
||||
htmlspecialchars(helper::getPasteAsJson(), ENT_NOQUOTES) .
|
||||
'</div>',
|
||||
$content,
|
||||
'outputs data correctly'
|
||||
);
|
||||
@ -662,11 +648,8 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
||||
ob_start();
|
||||
new zerobin;
|
||||
$content = ob_get_contents();
|
||||
$this->assertTag(
|
||||
array(
|
||||
'id' => 'errormessage',
|
||||
'content' => 'Invalid paste ID'
|
||||
),
|
||||
$this->assertRegExp(
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Invalid paste ID\.</div>#',
|
||||
$content,
|
||||
'outputs error correctly'
|
||||
);
|
||||
@ -682,11 +665,8 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
||||
ob_start();
|
||||
new zerobin;
|
||||
$content = ob_get_contents();
|
||||
$this->assertTag(
|
||||
array(
|
||||
'id' => 'errormessage',
|
||||
'content' => 'Paste does not exist'
|
||||
),
|
||||
$this->assertRegExp(
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Paste does not exist[^<]*</div>#',
|
||||
$content,
|
||||
'outputs error correctly'
|
||||
);
|
||||
@ -704,11 +684,8 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
||||
ob_start();
|
||||
new zerobin;
|
||||
$content = ob_get_contents();
|
||||
$this->assertTag(
|
||||
array(
|
||||
'id' => 'errormessage',
|
||||
'content' => 'Paste does not exist'
|
||||
),
|
||||
$this->assertRegExp(
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Paste does not exist[^<]*</div>#',
|
||||
$content,
|
||||
'outputs error correctly'
|
||||
);
|
||||
@ -726,11 +703,10 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
||||
ob_start();
|
||||
new zerobin;
|
||||
$content = ob_get_contents();
|
||||
$this->assertTag(
|
||||
array(
|
||||
'id' => 'cipherdata',
|
||||
'content' => htmlspecialchars(helper::getPasteAsJson($burnPaste['meta']), ENT_NOQUOTES)
|
||||
),
|
||||
$this->assertContains(
|
||||
'<div id="cipherdata" class="hidden">' .
|
||||
htmlspecialchars(helper::getPasteAsJson($burnPaste['meta']), ENT_NOQUOTES) .
|
||||
'</div>',
|
||||
$content,
|
||||
'outputs data correctly'
|
||||
);
|
||||
@ -795,11 +771,10 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
||||
new zerobin;
|
||||
$content = ob_get_contents();
|
||||
$meta['formatter'] = 'syntaxhighlighting';
|
||||
$this->assertTag(
|
||||
array(
|
||||
'id' => 'cipherdata',
|
||||
'content' => htmlspecialchars(helper::getPasteAsJson($meta), ENT_NOQUOTES)
|
||||
),
|
||||
$this->assertContains(
|
||||
'<div id="cipherdata" class="hidden">' .
|
||||
htmlspecialchars(helper::getPasteAsJson($meta), ENT_NOQUOTES) .
|
||||
'</div>',
|
||||
$content,
|
||||
'outputs data correctly'
|
||||
);
|
||||
@ -819,11 +794,10 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
||||
new zerobin;
|
||||
$content = ob_get_contents();
|
||||
$oldPaste['meta']['formatter'] = 'plaintext';
|
||||
$this->assertTag(
|
||||
array(
|
||||
'id' => 'cipherdata',
|
||||
'content' => htmlspecialchars(helper::getPasteAsJson($oldPaste['meta']), ENT_NOQUOTES)
|
||||
),
|
||||
$this->assertContains(
|
||||
'<div id="cipherdata" class="hidden">' .
|
||||
htmlspecialchars(helper::getPasteAsJson($oldPaste['meta']), ENT_NOQUOTES) .
|
||||
'</div>',
|
||||
$content,
|
||||
'outputs data correctly'
|
||||
);
|
||||
@ -842,11 +816,8 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
||||
ob_start();
|
||||
new zerobin;
|
||||
$content = ob_get_contents();
|
||||
$this->assertTag(
|
||||
array(
|
||||
'id' => 'status',
|
||||
'content' => 'Paste was properly deleted'
|
||||
),
|
||||
$this->assertRegExp(
|
||||
'#<div[^>]*id="status"[^>]*>.*Paste was properly deleted[^<]*</div>#s',
|
||||
$content,
|
||||
'outputs deleted status correctly'
|
||||
);
|
||||
@ -865,11 +836,8 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
||||
ob_start();
|
||||
new zerobin;
|
||||
$content = ob_get_contents();
|
||||
$this->assertTag(
|
||||
array(
|
||||
'id' => 'errormessage',
|
||||
'content' => 'Invalid paste ID'
|
||||
),
|
||||
$this->assertRegExp(
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Invalid paste ID\.</div>#',
|
||||
$content,
|
||||
'outputs delete error correctly'
|
||||
);
|
||||
@ -887,11 +855,8 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
||||
ob_start();
|
||||
new zerobin;
|
||||
$content = ob_get_contents();
|
||||
$this->assertTag(
|
||||
array(
|
||||
'id' => 'errormessage',
|
||||
'content' => 'Paste does not exist'
|
||||
),
|
||||
$this->assertRegExp(
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Paste does not exist[^<]*</div>#',
|
||||
$content,
|
||||
'outputs delete error correctly'
|
||||
);
|
||||
@ -909,11 +874,8 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
||||
ob_start();
|
||||
new zerobin;
|
||||
$content = ob_get_contents();
|
||||
$this->assertTag(
|
||||
array(
|
||||
'id' => 'errormessage',
|
||||
'content' => 'Wrong deletion token'
|
||||
),
|
||||
$this->assertRegExp(
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Wrong deletion token[^<]*</div>#',
|
||||
$content,
|
||||
'outputs delete error correctly'
|
||||
);
|
||||
@ -976,11 +938,8 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
||||
ob_start();
|
||||
new zerobin;
|
||||
$content = ob_get_contents();
|
||||
$this->assertTag(
|
||||
array(
|
||||
'id' => 'errormessage',
|
||||
'content' => 'Paste does not exist'
|
||||
),
|
||||
$this->assertRegExp(
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Paste does not exist[^<]*</div>#',
|
||||
$content,
|
||||
'outputs error correctly'
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user