Browse Source

Replace `expectExceptionMessageRegExp()` with `expectExceptionMessageMatches()`

pull/10307/head
Philipp 5 months ago
parent
commit
dda817cad8
No known key found for this signature in database GPG Key ID: 9A28B7D4FF5667BD
  1. 4
      tests/src/Model/Storage/FilesystemStorageTest.php
  2. 2
      tests/src/Util/BasePathTest.php
  3. 2
      tests/src/Util/Config/ConfigFileLoaderTest.php
  4. 8
      tests/src/Util/Logger/StreamLoggerTest.php
  5. 6
      tests/src/Util/Logger/SyslogLoggerTest.php

4
tests/src/Model/Storage/FilesystemStorageTest.php

@ -81,7 +81,7 @@ class FilesystemStorageTest extends StorageTest
public function testMissingDirPermissions()
{
$this->expectException(StorageException::class);
$this->expectExceptionMessageRegExp("/Filesystem storage failed to create \".*\". Check you write permissions./");
$this->expectExceptionMessageMatches("/Filesystem storage failed to create \".*\". Check you write permissions./");
$this->root->getChild('storage')->chmod(000);
$instance = $this->getInstance();
@ -97,7 +97,7 @@ class FilesystemStorageTest extends StorageTest
static::markTestIncomplete("Cannot catch file_put_content() error due vfsStream failure");
$this->expectException(StorageException::class);
$this->expectExceptionMessageRegExp("/Filesystem storage failed to save data to \".*\". Check your write permissions/");
$this->expectExceptionMessageMatches("/Filesystem storage failed to save data to \".*\". Check your write permissions/");
vfsStream::create(['storage' => ['f0' => ['c0' => ['k0i0' => '']]]], $this->root);

2
tests/src/Util/BasePathTest.php

@ -68,7 +68,7 @@ class BasePathTest extends MockedTest
public function testFailedBasePath()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessageRegExp("/(.*) is not a valid basepath/");
$this->expectExceptionMessageMatches("/(.*) is not a valid basepath/");
$basepath = new BasePath('/now23452sgfgas', []);
$basepath->getPath();

2
tests/src/Util/Config/ConfigFileLoaderTest.php

@ -59,7 +59,7 @@ class ConfigFileLoaderTest extends MockedTest
*/
public function testLoadConfigWrong()
{
$this->expectExceptionMessageRegExp("/Error loading config file \w+/");
$this->expectExceptionMessageMatches("/Error loading config file \w+/");
$this->expectException(\Exception::class);
$this->delConfigFile('local.config.php');

8
tests/src/Util/Logger/StreamLoggerTest.php

@ -128,7 +128,7 @@ class StreamLoggerTest extends AbstractLoggerTest
public function testWrongUrl()
{
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionMessageRegExp("/The stream or file .* could not be opened: .* /");
$this->expectExceptionMessageMatches("/The stream or file .* could not be opened: .* /");
$logfile = vfsStream::newFile('friendica.log')
->at($this->root)->chmod(0);
@ -144,7 +144,7 @@ class StreamLoggerTest extends AbstractLoggerTest
public function testWrongDir()
{
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionMessageRegExp("/Directory .* cannot get created: .* /");
$this->expectExceptionMessageMatches("/Directory .* cannot get created: .* /");
static::markTestIncomplete('We need a platform independent way to set directory to readonly');
@ -159,7 +159,7 @@ class StreamLoggerTest extends AbstractLoggerTest
public function testWrongMinimumLevel()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessageRegExp("/The level \".*\" is not valid./");
$this->expectExceptionMessageMatches("/The level \".*\" is not valid./");
$logger = new StreamLogger('test', 'file.text', $this->introspection, $this->fileSystem, 'NOPE');
}
@ -170,7 +170,7 @@ class StreamLoggerTest extends AbstractLoggerTest
public function testWrongLogLevel()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessageRegExp("/The level \".*\" is not valid./");
$this->expectExceptionMessageMatches("/The level \".*\" is not valid./");
$logfile = vfsStream::newFile('friendica.log')
->at($this->root);

6
tests/src/Util/Logger/SyslogLoggerTest.php

@ -63,7 +63,7 @@ class SyslogLoggerTest extends AbstractLoggerTest
public function testWrongMinimumLevel()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessageRegExp("/The level \".*\" is not valid./");
$this->expectExceptionMessageMatches("/The level \".*\" is not valid./");
$logger = new SyslogLoggerWrapper('test', $this->introspection, 'NOPE');
}
@ -74,7 +74,7 @@ class SyslogLoggerTest extends AbstractLoggerTest
public function testWrongLogLevel()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessageRegExp("/The level \".*\" is not valid./");
$this->expectExceptionMessageMatches("/The level \".*\" is not valid./");
$logger = new SyslogLoggerWrapper('test', $this->introspection);
@ -88,7 +88,7 @@ class SyslogLoggerTest extends AbstractLoggerTest
{
if (PHP_MAJOR_VERSION < 8) {
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionMessageRegExp("/Can\'t open syslog for ident \".*\" and facility \".*\": .* /");
$this->expectExceptionMessageMatches("/Can\'t open syslog for ident \".*\" and facility \".*\": .* /");
} else {
$this->expectException(\TypeError::class);
$this->expectExceptionMessage("openlog(): Argument #3 (\$facility) must be of type int, string given");

Loading…
Cancel
Save