Update exception assertions in tests and remove deprecated annotations

This commit is contained in:
Robbie Averill 2020-09-25 09:30:52 -07:00
parent 27bd5d12e3
commit ae1e17edec
3 changed files with 8 additions and 12 deletions

View File

@ -432,7 +432,7 @@ abstract class Database
default: default:
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
"SS_Database::manipulate() Can't recognise command '{$writeInfo['command']}'", "SS_Database::manipulate() Can't recognise command '{$writeInfo['command']}'"
); );
} }
} }

View File

@ -160,11 +160,9 @@ class HTTPRequestTest extends SapphireTest
$this->assertEquals($expected, $actual); $this->assertEquals($expected, $actual);
} }
/**
* @expectedException PHPUnit_Framework_Error
*/
public function testBadDetectMethod() public function testBadDetectMethod()
{ {
$this->expectException(\InvalidArgumentException::class);
HTTPRequest::detect_method('POST', ['_method' => 'Boom']); HTTPRequest::detect_method('POST', ['_method' => 'Boom']);
} }
@ -191,11 +189,9 @@ class HTTPRequestTest extends SapphireTest
$this->assertEquals($request, $returnedRequest); $this->assertEquals($request, $returnedRequest);
} }
/**
* @expectedException PHPUnit_Framework_Error
*/
public function testBadSetHttpMethod() public function testBadSetHttpMethod()
{ {
$this->expectException(\InvalidArgumentException::class);
$request = new HTTPRequest('GET', '/hello'); $request = new HTTPRequest('GET', '/hello');
$request->setHttpMethod('boom'); $request->setHttpMethod('boom');
} }

View File

@ -2,7 +2,6 @@
namespace SilverStripe\Forms\Tests; namespace SilverStripe\Forms\Tests;
use PHPUnit_Framework_Error;
use SilverStripe\Dev\CSSContentParser; use SilverStripe\Dev\CSSContentParser;
use SilverStripe\Dev\SapphireTest; use SilverStripe\Dev\SapphireTest;
use SilverStripe\Forms\CompositeField; use SilverStripe\Forms\CompositeField;
@ -161,12 +160,13 @@ class CompositeFieldTest extends SapphireTest
$this->assertNull($result['title']); $this->assertNull($result['title']);
} }
/**
* @expectedException PHPUnit_Framework_Error
* @expectedExceptionMessageRegExp /a field called 'Test' appears twice in your form.*TextField.*TextField/
*/
public function testCollateDataFieldsThrowsErrorOnDuplicateChildren() public function testCollateDataFieldsThrowsErrorOnDuplicateChildren()
{ {
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessageRegExp(
"/a field called 'Test' appears twice in your form.*TextField.*TextField/"
);
$field = CompositeField::create( $field = CompositeField::create(
TextField::create('Test'), TextField::create('Test'),
TextField::create('Test') TextField::create('Test')