From ae1e17edeca1334bf0d6ad459a2111fa1b96a09e Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Fri, 25 Sep 2020 09:30:52 -0700 Subject: [PATCH] Update exception assertions in tests and remove deprecated annotations --- src/ORM/Connect/Database.php | 2 +- tests/php/Control/HTTPRequestTest.php | 8 ++------ tests/php/Forms/CompositeFieldTest.php | 10 +++++----- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/ORM/Connect/Database.php b/src/ORM/Connect/Database.php index d8920a8d4..da66d9314 100644 --- a/src/ORM/Connect/Database.php +++ b/src/ORM/Connect/Database.php @@ -432,7 +432,7 @@ abstract class Database default: throw new \InvalidArgumentException( - "SS_Database::manipulate() Can't recognise command '{$writeInfo['command']}'", + "SS_Database::manipulate() Can't recognise command '{$writeInfo['command']}'" ); } } diff --git a/tests/php/Control/HTTPRequestTest.php b/tests/php/Control/HTTPRequestTest.php index 51ea76fa3..52ce61b49 100644 --- a/tests/php/Control/HTTPRequestTest.php +++ b/tests/php/Control/HTTPRequestTest.php @@ -160,11 +160,9 @@ class HTTPRequestTest extends SapphireTest $this->assertEquals($expected, $actual); } - /** - * @expectedException PHPUnit_Framework_Error - */ public function testBadDetectMethod() { + $this->expectException(\InvalidArgumentException::class); HTTPRequest::detect_method('POST', ['_method' => 'Boom']); } @@ -191,11 +189,9 @@ class HTTPRequestTest extends SapphireTest $this->assertEquals($request, $returnedRequest); } - /** - * @expectedException PHPUnit_Framework_Error - */ public function testBadSetHttpMethod() { + $this->expectException(\InvalidArgumentException::class); $request = new HTTPRequest('GET', '/hello'); $request->setHttpMethod('boom'); } diff --git a/tests/php/Forms/CompositeFieldTest.php b/tests/php/Forms/CompositeFieldTest.php index 382c339dc..6bc72cda4 100644 --- a/tests/php/Forms/CompositeFieldTest.php +++ b/tests/php/Forms/CompositeFieldTest.php @@ -2,7 +2,6 @@ namespace SilverStripe\Forms\Tests; -use PHPUnit_Framework_Error; use SilverStripe\Dev\CSSContentParser; use SilverStripe\Dev\SapphireTest; use SilverStripe\Forms\CompositeField; @@ -161,12 +160,13 @@ class CompositeFieldTest extends SapphireTest $this->assertNull($result['title']); } - /** - * @expectedException PHPUnit_Framework_Error - * @expectedExceptionMessageRegExp /a field called 'Test' appears twice in your form.*TextField.*TextField/ - */ public function testCollateDataFieldsThrowsErrorOnDuplicateChildren() { + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessageRegExp( + "/a field called 'Test' appears twice in your form.*TextField.*TextField/" + ); + $field = CompositeField::create( TextField::create('Test'), TextField::create('Test')