fixing deprecations with newer phpunit versions

This commit is contained in:
El RIDO 2016-05-22 18:35:07 +02:00
parent 1158c81259
commit e89a8b6898
4 changed files with 65 additions and 127 deletions

View File

@ -62,54 +62,36 @@ class RainTPLTest extends PHPUnit_Framework_TestCase
public function testTemplateRendersCorrectly() public function testTemplateRendersCorrectly()
{ {
$this->assertTag( $this->assertContains(
array( '<div id="cipherdata" class="hidden">' .
'id' => 'cipherdata', htmlspecialchars(helper::getPaste()['data'], ENT_NOQUOTES) .
'content' => htmlspecialchars(helper::getPaste()['data'], ENT_NOQUOTES) '</div>',
),
$this->_content, $this->_content,
'outputs data correctly' 'outputs data correctly'
); );
$this->assertTag( $this->assertRegExp(
array( '#<div[^>]+id="errormessage"[^>]*>.*' . self::$error . '</div>#',
'id' => 'errormessage',
'content' => self::$error
),
$this->_content, $this->_content,
'outputs error correctly' 'outputs error correctly'
); );
$this->assertTag( $this->assertRegExp(
array( '#<[^>]+id="password"[^>]*>#',
'id' => 'password',
),
$this->_content, $this->_content,
'password available if configured' 'password available if configured'
); );
$this->assertTag( $this->assertRegExp(
array( '#<input[^>]+id="opendiscussion"[^>]*checked="checked"[^>]*>#',
'id' => 'opendiscussion',
'attributes' => array(
'checked' => 'checked'
),
),
$this->_content, $this->_content,
'checked discussion if configured' 'checked discussion if configured'
); );
$this->assertTag( $this->assertRegExp(
array( '#<[^>]+id="opendisc"[^>]*>#',
'id' => 'opendisc',
),
$this->_content, $this->_content,
'discussions available if configured' 'discussions available if configured'
); );
// testing version number in JS address, since other instances may not be present in different templates // testing version number in JS address, since other instances may not be present in different templates
$this->assertTag( $this->assertRegExp(
array( '#<script[^>]+src="js/zerobin.js\\?' . rawurlencode(self::$version) . '"[^>]*>#',
'tag' => 'script',
'attributes' => array(
'src' => 'js/zerobin.js?' . rawurlencode(self::$version)
),
),
$this->_content, $this->_content,
'outputs version correctly' 'outputs version correctly'
); );

View File

@ -2,9 +2,10 @@
error_reporting( E_ALL | E_STRICT ); error_reporting( E_ALL | E_STRICT );
// change this, if your php files and data is outside of your webservers document root // 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('PATH')) define('PATH', '..' . DIRECTORY_SEPARATOR);
if (!defined('CONF')) define('CONF', PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini'); 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'; require PATH . 'lib/auto.php';

View File

@ -579,11 +579,10 @@ EOT;
case 'Read': case 'Read':
$code .= <<<'EOT' $code .= <<<'EOT'
$this->assertTag( $this->assertContains(
array( '<div id="cipherdata" class="hidden">' .
'id' => 'cipherdata', htmlspecialchars(helper::getPasteAsJson(), ENT_NOQUOTES) .
'content' => htmlspecialchars(helper::getPasteAsJson(), ENT_NOQUOTES) '</div>',
),
$content, $content,
'outputs data correctly' 'outputs data correctly'
); );
@ -592,11 +591,8 @@ EOT;
case 'Delete': case 'Delete':
$code .= <<<'EOT' $code .= <<<'EOT'
$this->assertTag( $this->assertRegExp(
array( '#<div[^>]*id="status"[^>]*>.*Paste was properly deleted</div>#',
'id' => 'status',
'content' => 'Paste was properly deleted'
),
$content, $content,
'outputs deleted status correctly' 'outputs deleted status correctly'
); );

View File

@ -36,18 +36,13 @@ class zerobinTest extends PHPUnit_Framework_TestCase
ob_start(); ob_start();
new zerobin; new zerobin;
$content = ob_get_contents(); $content = ob_get_contents();
$this->assertTag( $this->assertContains(
array( '<title>ZeroBin</title>',
'tag' => 'title',
'content' => 'ZeroBin'
),
$content, $content,
'outputs title correctly' 'outputs title correctly'
); );
$this->assertNotTag( $this->assertNotContains(
array( 'id="shortenbutton"',
'id' => 'shortenbutton'
),
$content, $content,
'doesn\'t output shortener button' 'doesn\'t output shortener button'
); );
@ -67,11 +62,8 @@ class zerobinTest extends PHPUnit_Framework_TestCase
ob_start(); ob_start();
new zerobin; new zerobin;
$content = ob_get_contents(); $content = ob_get_contents();
$this->assertTag( $this->assertContains(
array( '<title>ZeroBin</title>',
'tag' => 'title',
'content' => 'ZeroBin'
),
$content, $content,
'outputs title correctly' 'outputs title correctly'
); );
@ -92,11 +84,8 @@ class zerobinTest extends PHPUnit_Framework_TestCase
ob_start(); ob_start();
new zerobin; new zerobin;
$content = ob_get_contents(); $content = ob_get_contents();
$this->assertTag( $this->assertContains(
array( '<title>ZeroBin</title>',
'tag' => 'title',
'content' => 'ZeroBin'
),
$content, $content,
'outputs title correctly' 'outputs title correctly'
); );
@ -117,11 +106,8 @@ class zerobinTest extends PHPUnit_Framework_TestCase
ob_start(); ob_start();
new zerobin; new zerobin;
$content = ob_get_contents(); $content = ob_get_contents();
$this->assertTag( $this->assertRegExp(
array( '#id="shortenbutton"[^>]*data-shortener="' . preg_quote($shortener) . '"#',
'id' => 'shortenbutton',
'attributes' => array('data-shortener' => $shortener)
),
$content, $content,
'outputs configured shortener URL correctly' 'outputs configured shortener URL correctly'
); );
@ -248,6 +234,7 @@ class zerobinTest extends PHPUnit_Framework_TestCase
$_SERVER['HTTP_X_FORWARDED_FOR'] = '::1'; $_SERVER['HTTP_X_FORWARDED_FOR'] = '::1';
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest'; $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
$_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REMOTE_ADDR'] = '::1';
ob_start(); ob_start();
new zerobin; new zerobin;
$content = ob_get_contents(); $content = ob_get_contents();
@ -642,11 +629,10 @@ class zerobinTest extends PHPUnit_Framework_TestCase
ob_start(); ob_start();
new zerobin; new zerobin;
$content = ob_get_contents(); $content = ob_get_contents();
$this->assertTag( $this->assertContains(
array( '<div id="cipherdata" class="hidden">' .
'id' => 'cipherdata', htmlspecialchars(helper::getPasteAsJson(), ENT_NOQUOTES) .
'content' => htmlspecialchars(helper::getPasteAsJson(), ENT_NOQUOTES) '</div>',
),
$content, $content,
'outputs data correctly' 'outputs data correctly'
); );
@ -662,11 +648,8 @@ class zerobinTest extends PHPUnit_Framework_TestCase
ob_start(); ob_start();
new zerobin; new zerobin;
$content = ob_get_contents(); $content = ob_get_contents();
$this->assertTag( $this->assertRegExp(
array( '#<div[^>]*id="errormessage"[^>]*>.*Invalid paste ID\.</div>#',
'id' => 'errormessage',
'content' => 'Invalid paste ID'
),
$content, $content,
'outputs error correctly' 'outputs error correctly'
); );
@ -682,11 +665,8 @@ class zerobinTest extends PHPUnit_Framework_TestCase
ob_start(); ob_start();
new zerobin; new zerobin;
$content = ob_get_contents(); $content = ob_get_contents();
$this->assertTag( $this->assertRegExp(
array( '#<div[^>]*id="errormessage"[^>]*>.*Paste does not exist[^<]*</div>#',
'id' => 'errormessage',
'content' => 'Paste does not exist'
),
$content, $content,
'outputs error correctly' 'outputs error correctly'
); );
@ -704,11 +684,8 @@ class zerobinTest extends PHPUnit_Framework_TestCase
ob_start(); ob_start();
new zerobin; new zerobin;
$content = ob_get_contents(); $content = ob_get_contents();
$this->assertTag( $this->assertRegExp(
array( '#<div[^>]*id="errormessage"[^>]*>.*Paste does not exist[^<]*</div>#',
'id' => 'errormessage',
'content' => 'Paste does not exist'
),
$content, $content,
'outputs error correctly' 'outputs error correctly'
); );
@ -726,11 +703,10 @@ class zerobinTest extends PHPUnit_Framework_TestCase
ob_start(); ob_start();
new zerobin; new zerobin;
$content = ob_get_contents(); $content = ob_get_contents();
$this->assertTag( $this->assertContains(
array( '<div id="cipherdata" class="hidden">' .
'id' => 'cipherdata', htmlspecialchars(helper::getPasteAsJson($burnPaste['meta']), ENT_NOQUOTES) .
'content' => htmlspecialchars(helper::getPasteAsJson($burnPaste['meta']), ENT_NOQUOTES) '</div>',
),
$content, $content,
'outputs data correctly' 'outputs data correctly'
); );
@ -795,11 +771,10 @@ class zerobinTest extends PHPUnit_Framework_TestCase
new zerobin; new zerobin;
$content = ob_get_contents(); $content = ob_get_contents();
$meta['formatter'] = 'syntaxhighlighting'; $meta['formatter'] = 'syntaxhighlighting';
$this->assertTag( $this->assertContains(
array( '<div id="cipherdata" class="hidden">' .
'id' => 'cipherdata', htmlspecialchars(helper::getPasteAsJson($meta), ENT_NOQUOTES) .
'content' => htmlspecialchars(helper::getPasteAsJson($meta), ENT_NOQUOTES) '</div>',
),
$content, $content,
'outputs data correctly' 'outputs data correctly'
); );
@ -819,11 +794,10 @@ class zerobinTest extends PHPUnit_Framework_TestCase
new zerobin; new zerobin;
$content = ob_get_contents(); $content = ob_get_contents();
$oldPaste['meta']['formatter'] = 'plaintext'; $oldPaste['meta']['formatter'] = 'plaintext';
$this->assertTag( $this->assertContains(
array( '<div id="cipherdata" class="hidden">' .
'id' => 'cipherdata', htmlspecialchars(helper::getPasteAsJson($oldPaste['meta']), ENT_NOQUOTES) .
'content' => htmlspecialchars(helper::getPasteAsJson($oldPaste['meta']), ENT_NOQUOTES) '</div>',
),
$content, $content,
'outputs data correctly' 'outputs data correctly'
); );
@ -842,11 +816,8 @@ class zerobinTest extends PHPUnit_Framework_TestCase
ob_start(); ob_start();
new zerobin; new zerobin;
$content = ob_get_contents(); $content = ob_get_contents();
$this->assertTag( $this->assertRegExp(
array( '#<div[^>]*id="status"[^>]*>.*Paste was properly deleted[^<]*</div>#s',
'id' => 'status',
'content' => 'Paste was properly deleted'
),
$content, $content,
'outputs deleted status correctly' 'outputs deleted status correctly'
); );
@ -865,11 +836,8 @@ class zerobinTest extends PHPUnit_Framework_TestCase
ob_start(); ob_start();
new zerobin; new zerobin;
$content = ob_get_contents(); $content = ob_get_contents();
$this->assertTag( $this->assertRegExp(
array( '#<div[^>]*id="errormessage"[^>]*>.*Invalid paste ID\.</div>#',
'id' => 'errormessage',
'content' => 'Invalid paste ID'
),
$content, $content,
'outputs delete error correctly' 'outputs delete error correctly'
); );
@ -887,11 +855,8 @@ class zerobinTest extends PHPUnit_Framework_TestCase
ob_start(); ob_start();
new zerobin; new zerobin;
$content = ob_get_contents(); $content = ob_get_contents();
$this->assertTag( $this->assertRegExp(
array( '#<div[^>]*id="errormessage"[^>]*>.*Paste does not exist[^<]*</div>#',
'id' => 'errormessage',
'content' => 'Paste does not exist'
),
$content, $content,
'outputs delete error correctly' 'outputs delete error correctly'
); );
@ -909,11 +874,8 @@ class zerobinTest extends PHPUnit_Framework_TestCase
ob_start(); ob_start();
new zerobin; new zerobin;
$content = ob_get_contents(); $content = ob_get_contents();
$this->assertTag( $this->assertRegExp(
array( '#<div[^>]*id="errormessage"[^>]*>.*Wrong deletion token[^<]*</div>#',
'id' => 'errormessage',
'content' => 'Wrong deletion token'
),
$content, $content,
'outputs delete error correctly' 'outputs delete error correctly'
); );
@ -976,11 +938,8 @@ class zerobinTest extends PHPUnit_Framework_TestCase
ob_start(); ob_start();
new zerobin; new zerobin;
$content = ob_get_contents(); $content = ob_get_contents();
$this->assertTag( $this->assertRegExp(
array( '#<div[^>]*id="errormessage"[^>]*>.*Paste does not exist[^<]*</div>#',
'id' => 'errormessage',
'content' => 'Paste does not exist'
),
$content, $content,
'outputs error correctly' 'outputs error correctly'
); );