diff --git a/composer.json b/composer.json index 9d3cd9a5..88640d50 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "yzalis/identicon" : "^2.0.0" }, "require-dev" : { - "phpunit/phpunit" : "^5 || ^9" + "phpunit/phpunit" : "^9" }, "autoload" : { "psr-4" : { diff --git a/composer.lock b/composer.lock index 7149b7e7..fa0c7b51 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c5e5c4d3d99ae93c94cc75e225aa50f5", + "content-hash": "f8f346748370d0efd672270571c4aa74", "packages": [ { "name": "paragonie/random_compat", @@ -897,16 +897,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.4.0", + "version": "9.4.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "ef533467a7974c4b6c354f3eff42a115910bd4e5" + "reference": "1f09a12726593737e8a228ebb1c8647305d07c41" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ef533467a7974c4b6c354f3eff42a115910bd4e5", - "reference": "ef533467a7974c4b6c354f3eff42a115910bd4e5", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1f09a12726593737e8a228ebb1c8647305d07c41", + "reference": "1f09a12726593737e8a228ebb1c8647305d07c41", "shasum": "" }, "require": { @@ -921,23 +921,23 @@ "phar-io/manifest": "^2.0.1", "phar-io/version": "^3.0.2", "php": ">=7.3", - "phpspec/prophecy": "^1.11.1", + "phpspec/prophecy": "^1.12.1", "phpunit/php-code-coverage": "^9.2", - "phpunit/php-file-iterator": "^3.0.4", - "phpunit/php-invoker": "^3.1", - "phpunit/php-text-template": "^2.0.2", - "phpunit/php-timer": "^5.0.1", - "sebastian/cli-parser": "^1.0", - "sebastian/code-unit": "^1.0.5", - "sebastian/comparator": "^4.0.3", - "sebastian/diff": "^4.0.2", - "sebastian/environment": "^5.1.2", - "sebastian/exporter": "^4.0.2", - "sebastian/global-state": "^5.0", - "sebastian/object-enumerator": "^4.0.2", - "sebastian/resource-operations": "^3.0.2", - "sebastian/type": "^2.2.1", - "sebastian/version": "^3.0.1" + "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-invoker": "^3.1.1", + "phpunit/php-text-template": "^2.0.3", + "phpunit/php-timer": "^5.0.2", + "sebastian/cli-parser": "^1.0.1", + "sebastian/code-unit": "^1.0.6", + "sebastian/comparator": "^4.0.5", + "sebastian/diff": "^4.0.3", + "sebastian/environment": "^5.1.3", + "sebastian/exporter": "^4.0.3", + "sebastian/global-state": "^5.0.1", + "sebastian/object-enumerator": "^4.0.3", + "sebastian/resource-operations": "^3.0.3", + "sebastian/type": "^2.3", + "sebastian/version": "^3.0.2" }, "require-dev": { "ext-pdo": "*", @@ -992,7 +992,7 @@ "type": "github" } ], - "time": "2020-10-02T03:54:37+00:00" + "time": "2020-10-11T07:41:19+00:00" }, { "name": "sebastian/cli-parser", diff --git a/tst/ConfigurationTest.php b/tst/ConfigurationTest.php index 9afa829b..5e694885 100644 --- a/tst/ConfigurationTest.php +++ b/tst/ConfigurationTest.php @@ -58,13 +58,11 @@ class ConfigurationTest extends TestCase $this->assertEquals($this->_options, $conf->get(), 'returns correct defaults on missing file'); } - /** - * @expectedException Exception - * @expectedExceptionCode 2 - */ public function testHandleBlankConfigFile() { file_put_contents(CONF, ''); + $this->expectException(Exception::class); + $this->expectExceptionCode(2); new Configuration; } @@ -75,25 +73,21 @@ class ConfigurationTest extends TestCase $this->assertEquals($this->_options, $conf->get(), 'returns correct defaults on empty file'); } - /** - * @expectedException Exception - * @expectedExceptionCode 3 - */ public function testHandleInvalidSection() { file_put_contents(CONF, $this->_minimalConfig); $conf = new Configuration; + $this->expectException(Exception::class); + $this->expectExceptionCode(3); $conf->getKey('foo', 'bar'); } - /** - * @expectedException Exception - * @expectedExceptionCode 4 - */ public function testHandleInvalidKey() { file_put_contents(CONF, $this->_minimalConfig); $conf = new Configuration; + $this->expectException(Exception::class); + $this->expectExceptionCode(4); $conf->getKey('foo'); } @@ -160,8 +154,8 @@ class ConfigurationTest extends TestCase $conf = new Configuration; $this->assertFileExists(CONF, 'old configuration file gets converted'); - $this->assertFileNotExists(PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini', 'old configuration file gets removed'); - $this->assertFileNotExists(PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini.sample', 'old configuration sample file gets removed'); + $this->assertFileDoesNotExist(PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini', 'old configuration file gets removed'); + $this->assertFileDoesNotExist(PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini.sample', 'old configuration sample file gets removed'); $this->assertTrue( $conf->getKey('opendiscussion') && $conf->getKey('fileupload') && @@ -180,10 +174,10 @@ class ConfigurationTest extends TestCase } rename(CONF_SAMPLE, $iniSample); new Configuration; - $this->assertFileNotExists($iniSample, 'old sample file gets removed'); + $this->assertFileDoesNotExist($iniSample, 'old sample file gets removed'); $this->assertFileExists(CONF_SAMPLE, 'new sample file gets created'); $this->assertFileExists(CONF, 'old configuration file gets converted'); - $this->assertFileNotExists(PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini', 'old configuration file gets removed'); + $this->assertFileDoesNotExist(PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini', 'old configuration file gets removed'); } public function testConfigPath() @@ -214,15 +208,15 @@ class ConfigurationTest extends TestCase $options = $this->_options; $options['main']['name'] = 'OtherBin'; Helper::createIniFile($configFile, $options); - $this->assertFileNotExists(CONF, 'configuration in the default location is non existing'); + $this->assertFileDoesNotExist(CONF, 'configuration in the default location is non existing'); // test putenv('CONFIG_PATH=' . $this->_path); $conf = new Configuration; $this->assertEquals('OtherBin', $conf->getKey('name'), 'changing config path is supported for ini files as well'); $this->assertFileExists($configMigrated, 'old configuration file gets converted'); - $this->assertFileNotExists($configFile, 'old configuration file gets removed'); - $this->assertFileNotExists(CONF, 'configuration is not created in the default location'); + $this->assertFileDoesNotExist($configFile, 'old configuration file gets removed'); + $this->assertFileDoesNotExist(CONF, 'configuration is not created in the default location'); // cleanup environment if (is_file($configFile)) { diff --git a/tst/ConfigurationTestGenerator.php b/tst/ConfigurationTestGenerator.php index b5551c0a..611181cc 100755 --- a/tst/ConfigurationTestGenerator.php +++ b/tst/ConfigurationTestGenerator.php @@ -565,7 +565,7 @@ EOT; case 'Delete': $code .= <<<'EOT' - $this->assertRegExp( + $this->assertMatchesRegularExpression( '#]*id="status"[^>]*>.*Paste was properly deleted[^<]*#s', $content, 'outputs deleted status correctly' diff --git a/tst/ControllerTest.php b/tst/ControllerTest.php index 8610dd9b..b199f7b2 100644 --- a/tst/ControllerTest.php +++ b/tst/ControllerTest.php @@ -54,12 +54,12 @@ class ControllerTest extends TestCase new Controller; $content = ob_get_contents(); ob_end_clean(); - $this->assertContains( + $this->assertStringContainsString( 'PrivateBin', $content, 'outputs title correctly' ); - $this->assertNotContains( + $this->assertStringNotContainsString( 'id="shortenbutton"', $content, 'doesn\'t output shortener button' @@ -79,7 +79,7 @@ class ControllerTest extends TestCase new Controller; $content = ob_get_contents(); ob_end_clean(); - $this->assertContains( + $this->assertStringContainsString( 'PrivateBin', $content, 'outputs title correctly' @@ -100,7 +100,7 @@ class ControllerTest extends TestCase new Controller; $content = ob_get_contents(); ob_end_clean(); - $this->assertContains( + $this->assertStringContainsString( 'PrivateBin', $content, 'outputs title correctly' @@ -121,7 +121,7 @@ class ControllerTest extends TestCase new Controller; $content = ob_get_contents(); ob_end_clean(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '#id="shortenbutton"[^>]*data-shortener="' . preg_quote($shortener) . '"#', $content, 'outputs configured shortener URL correctly' @@ -150,13 +150,11 @@ class ControllerTest extends TestCase $this->assertFileExists($htaccess, 'htaccess recreated'); } - /** - * @expectedException Exception - * @expectedExceptionCode 2 - */ public function testConf() { file_put_contents(CONF, ''); + $this->expectException(Exception::class); + $this->expectExceptionCode(2); new Controller; } @@ -452,8 +450,6 @@ class ControllerTest extends TestCase * silently removed, check that this case is handled * * @runInSeparateProcess - * @expectedException Exception - * @expectedExceptionCode 90 */ public function testCreateBrokenUpload() { @@ -465,6 +461,8 @@ class ControllerTest extends TestCase $_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['REMOTE_ADDR'] = '::1'; $this->assertFalse($this->_data->exists(Helper::getPasteId()), 'paste does not exists before posting data'); + $this->expectException(Exception::class); + $this->expectExceptionCode(90); new Controller; $this->assertFalse($this->_data->exists(Helper::getPasteId()), 'paste exists after posting data'); } @@ -799,7 +797,7 @@ class ControllerTest extends TestCase new Controller; $content = ob_get_contents(); ob_end_clean(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '#]*id="status"[^>]*>.*Paste was properly deleted\.#s', $content, 'outputs deleted status correctly' @@ -819,7 +817,7 @@ class ControllerTest extends TestCase new Controller; $content = ob_get_contents(); ob_end_clean(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '#]*id="errormessage"[^>]*>.*Invalid paste ID\.#s', $content, 'outputs delete error correctly' @@ -838,7 +836,7 @@ class ControllerTest extends TestCase new Controller; $content = ob_get_contents(); ob_end_clean(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '#]*id="errormessage"[^>]*>.*Paste does not exist, has expired or has been deleted\.#s', $content, 'outputs delete error correctly' @@ -857,7 +855,7 @@ class ControllerTest extends TestCase new Controller; $content = ob_get_contents(); ob_end_clean(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '#]*id="errormessage"[^>]*>.*Wrong deletion token\. Paste was not deleted\.#s', $content, 'outputs delete error correctly' @@ -905,7 +903,7 @@ class ControllerTest extends TestCase new Controller; $content = ob_get_contents(); ob_end_clean(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '#]*id="errormessage"[^>]*>.*Paste does not exist, has expired or has been deleted\.#s', $content, 'outputs error correctly' @@ -928,7 +926,7 @@ class ControllerTest extends TestCase new Controller; $content = ob_get_contents(); ob_end_clean(); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '#]*id="status"[^>]*>.*Paste was properly deleted\.#s', $content, 'outputs deleted status correctly' diff --git a/tst/Data/DatabaseTest.php b/tst/Data/DatabaseTest.php index 8820b341..1d61cb71 100644 --- a/tst/Data/DatabaseTest.php +++ b/tst/Data/DatabaseTest.php @@ -122,124 +122,102 @@ class DatabaseTest extends TestCase } } - /** - * @expectedException PDOException - */ public function testGetIbmInstance() { + $this->expectException(PDOException::class); Database::getInstance(array( 'dsn' => 'ibm:', 'usr' => null, 'pwd' => null, 'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION), )); } - /** - * @expectedException PDOException - */ public function testGetInformixInstance() { + $this->expectException(PDOException::class); Database::getInstance(array( 'dsn' => 'informix:', 'usr' => null, 'pwd' => null, 'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION), )); } - /** - * @expectedException PDOException - */ public function testGetMssqlInstance() { + $this->expectException(PDOException::class); Database::getInstance(array( 'dsn' => 'mssql:', 'usr' => null, 'pwd' => null, 'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION), )); } - /** - * @expectedException PDOException - */ public function testGetMysqlInstance() { + $this->expectException(PDOException::class); Database::getInstance(array( 'dsn' => 'mysql:', 'usr' => null, 'pwd' => null, 'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION), )); } - /** - * @expectedException PDOException - */ public function testGetOciInstance() { + $this->expectException(PDOException::class); Database::getInstance(array( 'dsn' => 'oci:', 'usr' => null, 'pwd' => null, 'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION), )); } - /** - * @expectedException PDOException - */ public function testGetPgsqlInstance() { + $this->expectException(PDOException::class); Database::getInstance(array( 'dsn' => 'pgsql:', 'usr' => null, 'pwd' => null, 'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION), )); } - /** - * @expectedException Exception - * @expectedExceptionCode 5 - */ public function testGetFooInstance() { + $this->expectException(Exception::class); + $this->expectExceptionCode(5); Database::getInstance(array( 'dsn' => 'foo:', 'usr' => null, 'pwd' => null, 'opt' => null, )); } - /** - * @expectedException Exception - * @expectedExceptionCode 6 - */ public function testMissingDsn() { $options = $this->_options; unset($options['dsn']); + $this->expectException(Exception::class); + $this->expectExceptionCode(6); Database::getInstance($options); } - /** - * @expectedException Exception - * @expectedExceptionCode 6 - */ public function testMissingUsr() { $options = $this->_options; unset($options['usr']); + $this->expectException(Exception::class); + $this->expectExceptionCode(6); Database::getInstance($options); } - /** - * @expectedException Exception - * @expectedExceptionCode 6 - */ public function testMissingPwd() { $options = $this->_options; unset($options['pwd']); + $this->expectException(Exception::class); + $this->expectExceptionCode(6); Database::getInstance($options); } - /** - * @expectedException Exception - * @expectedExceptionCode 6 - */ public function testMissingOpt() { $options = $this->_options; unset($options['opt']); + $this->expectException(Exception::class); + $this->expectExceptionCode(6); Database::getInstance($options); } diff --git a/tst/Data/FilesystemTest.php b/tst/Data/FilesystemTest.php index 64b83962..0388ffcb 100644 --- a/tst/Data/FilesystemTest.php +++ b/tst/Data/FilesystemTest.php @@ -162,13 +162,13 @@ class FilesystemTest extends TestCase $this->_model->purge(10); foreach ($ids as $dataid => $storagedir) { $this->assertFileExists($storagedir . $dataid . '.php', "paste $dataid exists in new format"); - $this->assertFileNotExists($storagedir . $dataid, "old format paste $dataid got removed"); + $this->assertFileDoesNotExist($storagedir . $dataid, "old format paste $dataid got removed"); $this->assertTrue($this->_model->exists($dataid), "paste $dataid exists"); $this->assertEquals($this->_model->read($dataid), $paste, "paste $dataid wasn't modified in the conversion"); $storagedir .= $dataid . '.discussion' . DIRECTORY_SEPARATOR; $this->assertFileExists($storagedir . $dataid . '.' . $commentid . '.' . $dataid . '.php', "comment of $dataid exists in new format"); - $this->assertFileNotExists($storagedir . $dataid . '.' . $commentid . '.' . $dataid, "old format comment of $dataid got removed"); + $this->assertFileDoesNotExist($storagedir . $dataid . '.' . $commentid . '.' . $dataid, "old format comment of $dataid got removed"); $this->assertTrue($this->_model->existsComment($dataid, $dataid, $commentid), "comment in paste $dataid exists"); $comment = $comment; $comment['id'] = $commentid; diff --git a/tst/FilterTest.php b/tst/FilterTest.php index df9581b4..39c4f5df 100644 --- a/tst/FilterTest.php +++ b/tst/FilterTest.php @@ -13,12 +13,10 @@ class FilterTest extends TestCase $this->assertEquals('6 months', Filter::formatHumanReadableTime('6months')); } - /** - * @expectedException Exception - * @expectedExceptionCode 30 - */ public function testFilterFailTimesHumanlyReadable() { + $this->expectException(Exception::class); + $this->expectExceptionCode(30); Filter::formatHumanReadableTime('five_minutes'); } diff --git a/tst/I18nTest.php b/tst/I18nTest.php index d5732420..8ccf125d 100644 --- a/tst/I18nTest.php +++ b/tst/I18nTest.php @@ -18,7 +18,7 @@ class I18nTest extends TestCase public function tearDown(): void { - /* Tear Down Routine */ + unset($_COOKIE['lang'], $_SERVER['HTTP_ACCEPT_LANGUAGE']); } public function testTranslationFallback() diff --git a/tst/ModelTest.php b/tst/ModelTest.php index cbfd9cea..de7ec74b 100644 --- a/tst/ModelTest.php +++ b/tst/ModelTest.php @@ -116,10 +116,6 @@ class ModelTest extends TestCase $this->assertEquals(Helper::getPasteId(), $comment->getParentId(), 'comment parent ID gets initialized to paste ID'); } - /** - * @expectedException Exception - * @expectedExceptionCode 75 - */ public function testPasteDuplicate() { $pasteData = Helper::getPastePost(); @@ -131,13 +127,11 @@ class ModelTest extends TestCase $paste = $this->_model->getPaste(); $paste->setData($pasteData); + $this->expectException(Exception::class); + $this->expectExceptionCode(75); $paste->store(); } - /** - * @expectedException Exception - * @expectedExceptionCode 69 - */ public function testCommentDuplicate() { $pasteData = Helper::getPastePost(); @@ -154,6 +148,8 @@ class ModelTest extends TestCase $comment = $paste->getComment(Helper::getPasteId()); $comment->setData($commentData); + $this->expectException(Exception::class); + $this->expectExceptionCode(69); $comment->store(); } @@ -185,40 +181,30 @@ class ModelTest extends TestCase $this->assertFalse(Paste::isValidId('../bar/baz'), 'path attack'); } - /** - * @expectedException Exception - * @expectedExceptionCode 64 - */ public function testInvalidPaste() { $this->_model->getPaste(Helper::getPasteId())->delete(); $paste = $this->_model->getPaste(Helper::getPasteId()); + $this->expectException(Exception::class); + $this->expectExceptionCode(64); $paste->get(); } - /** - * @expectedException Exception - * @expectedExceptionCode 60 - */ public function testInvalidPasteId() { + $this->expectException(Exception::class); + $this->expectExceptionCode(60); $this->_model->getPaste(''); } - /** - * @expectedException Exception - * @expectedExceptionCode 62 - */ public function testInvalidComment() { $paste = $this->_model->getPaste(); + $this->expectException(Exception::class); + $this->expectExceptionCode(62); $paste->getComment(Helper::getPasteId()); } - /** - * @expectedException Exception - * @expectedExceptionCode 67 - */ public function testInvalidCommentDeletedPaste() { $pasteData = Helper::getPastePost(); @@ -228,13 +214,11 @@ class ModelTest extends TestCase $comment = $paste->getComment(Helper::getPasteId()); $paste->delete(); + $this->expectException(Exception::class); + $this->expectExceptionCode(67); $comment->store(); } - /** - * @expectedException Exception - * @expectedExceptionCode 68 - */ public function testInvalidCommentData() { $pasteData = Helper::getPastePost(); @@ -244,18 +228,17 @@ class ModelTest extends TestCase $paste->store(); $comment = $paste->getComment(Helper::getPasteId()); + $this->expectException(Exception::class); + $this->expectExceptionCode(68); $comment->store(); } - /** - * @expectedException Exception - * @expectedExceptionCode 65 - */ public function testInvalidCommentParent() { $paste = $this->_model->getPaste(Helper::getPasteId()); - $comment = $paste->getComment(''); - $comment->store(); + $this->expectException(Exception::class); + $this->expectExceptionCode(65); + $paste->getComment(''); } public function testExpiration() @@ -273,10 +256,6 @@ class ModelTest extends TestCase $this->assertEquals((float) 300, (float) $paste['meta']['time_to_live'], 'remaining time is set correctly', 1.0); } - /** - * @expectedException Exception - * @expectedExceptionCode 64 - */ public function testCommentDeletion() { $pasteData = Helper::getPastePost(); @@ -285,6 +264,8 @@ class ModelTest extends TestCase $paste = $this->_model->getPaste(); $paste->setData($pasteData); $paste->store(); + $this->expectException(Exception::class); + $this->expectExceptionCode(64); $paste->getComment(Helper::getPasteId())->delete(); } diff --git a/tst/Persistence/ServerSaltTest.php b/tst/Persistence/ServerSaltTest.php index 216e6c62..36486cb4 100644 --- a/tst/Persistence/ServerSaltTest.php +++ b/tst/Persistence/ServerSaltTest.php @@ -51,22 +51,16 @@ class ServerSaltTest extends TestCase $this->assertEquals($salt, ServerSalt::get()); } - /** - * @expectedException Exception - * @expectedExceptionCode 11 - */ public function testPathShenanigans() { // try setting an invalid path chmod($this->_invalidPath, 0000); ServerSalt::setPath($this->_invalidPath); + $this->expectException(Exception::class); + $this->expectExceptionCode(11); ServerSalt::get(); } - /** - * @expectedException Exception - * @expectedExceptionCode 20 - */ public function testFileRead() { // try setting an invalid file @@ -74,13 +68,11 @@ class ServerSaltTest extends TestCase file_put_contents($this->_invalidFile, ''); chmod($this->_invalidFile, 0000); ServerSalt::setPath($this->_invalidPath); + $this->expectException(Exception::class); + $this->expectExceptionCode(20); ServerSalt::get(); } - /** - * @expectedException Exception - * @expectedExceptionCode 13 - */ public function testFileWrite() { // try setting an invalid file @@ -92,18 +84,18 @@ class ServerSaltTest extends TestCase file_put_contents($this->_invalidPath . DIRECTORY_SEPARATOR . '.htaccess', ''); chmod($this->_invalidPath, 0500); ServerSalt::setPath($this->_invalidPath); + $this->expectException(Exception::class); + $this->expectExceptionCode(13); ServerSalt::get(); } - /** - * @expectedException Exception - * @expectedExceptionCode 10 - */ public function testPermissionShenanigans() { // try creating an invalid path chmod($this->_invalidPath, 0000); ServerSalt::setPath($this->_invalidPath . DIRECTORY_SEPARATOR . 'baz'); + $this->expectException(Exception::class); + $this->expectExceptionCode(10); ServerSalt::get(); } } diff --git a/tst/ViewTest.php b/tst/ViewTest.php index 4094c03d..dd6f3bbc 100644 --- a/tst/ViewTest.php +++ b/tst/ViewTest.php @@ -95,28 +95,28 @@ class ViewTest extends TestCase public function testTemplateRendersCorrectly() { foreach ($this->_content as $template => $content) { - $this->assertRegExp( + $this->assertMatchesRegularExpression( '#]+id="errormessage"[^>]*>.*' . self::$error . '#s', $content, $template . ': outputs error correctly' ); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '#<[^>]+id="password"[^>]*>#', $content, $template . ': password available if configured' ); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '#]+id="opendiscussion"[^>]*checked="checked"[^>]*>#', $content, $template . ': checked discussion if configured' ); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '#<[^>]+id="opendiscussionoption"[^>]*>#', $content, $template . ': discussions available if configured' ); // testing version number in JS address, since other instances may not be present in different templates - $this->assertRegExp( + $this->assertMatchesRegularExpression( '#]+src="js/privatebin.js\\?' . rawurlencode(self::$version) . '"[^>]*>#', $content, $template . ': outputs version correctly' @@ -124,13 +124,11 @@ class ViewTest extends TestCase } } - /** - * @expectedException Exception - * @expectedExceptionCode 80 - */ public function testMissingTemplate() { $test = new View; + $this->expectException(Exception::class); + $this->expectExceptionCode(80); $test->draw('123456789 does not exist!'); } } diff --git a/tst/phpunit.xml b/tst/phpunit.xml index caaa67d7..504ba1b8 100644 --- a/tst/phpunit.xml +++ b/tst/phpunit.xml @@ -1,19 +1,22 @@ - - - ./ - ConfigurationTestGenerator.php - - - - ../lib - - ../lib/Data/AbstractData.php - - - - - - - - + + + + + ../lib + + + ../lib/Data/AbstractData.php + + + + + + + + ./ + ConfigurationTestGenerator.php + + + +