FIX Allow quotes in expected ReflectionExceptions within tests

This commit is contained in:
Garion Herman 2020-09-05 11:24:37 +12:00
parent 44685eceba
commit f1c94e6d54
3 changed files with 9 additions and 8 deletions

View File

@ -3,6 +3,7 @@
namespace SilverStripe\Core\Injector;
use Psr\Container\NotFoundExceptionInterface;
use Throwable;
class InjectorNotFoundException extends \Exception implements NotFoundExceptionInterface
{

View File

@ -105,7 +105,7 @@ class ClassInfoTest extends SapphireTest
public function testNonClassName()
{
$this->expectException(ReflectionException::class);
$this->expectExceptionMessage('Class IAmAClassThatDoesNotExist does not exist');
$this->expectExceptionMessageRegExp('/Class "?IAmAClassThatDoesNotExist"? does not exist/');
$this->assertEquals('IAmAClassThatDoesNotExist', ClassInfo::class_name('IAmAClassThatDoesNotExist'));
}

View File

@ -4,6 +4,7 @@ namespace SilverStripe\ORM\Tests;
use InvalidArgumentException;
use SilverStripe\Core\Convert;
use SilverStripe\Core\Injector\InjectorNotFoundException;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataQuery;
@ -751,24 +752,23 @@ class DataListTest extends SapphireTest
$this->assertEquals('Bob', $list->first()->Name, 'First comment should be from Bob');
}
/**
* @expectedException \SilverStripe\Core\Injector\InjectorNotFoundException
* @expectedExceptionMessage Class DataListFilter.Bogus does not exist
*/
public function testSimpleFilterWithNonExistingComparisator()
{
$this->expectException(InjectorNotFoundException::class);
$this->expectExceptionMessageRegExp('/Class "?DataListFilter.Bogus"? does not exist/');
$list = TeamComment::get();
$list->filter('Comment:Bogus', 'team comment');
}
/**
* Invalid modifiers are treated as failed filter construction
*
* @expectedException \SilverStripe\Core\Injector\InjectorNotFoundException
* @expectedExceptionMessage Class DataListFilter.invalidmodifier does not exist
*/
public function testInvalidModifier()
{
$this->expectException(InjectorNotFoundException::class);
$this->expectExceptionMessageRegExp('/Class "?DataListFilter.invalidmodifier"? does not exist/');
$list = TeamComment::get();
$list->filter('Comment:invalidmodifier', 'team comment');
}