diff --git a/tests/model/DataObjectTest.php b/tests/model/DataObjectTest.php index 5521c1aa5..9c071564f 100644 --- a/tests/model/DataObjectTest.php +++ b/tests/model/DataObjectTest.php @@ -1788,6 +1788,10 @@ class DataObjectTest extends SapphireTest { $this->assertEquals(1, $do->DynamicField); } + /** + * @expectedException PHPUnit_Framework_Error + * @expectedExceptionMessageRegExp /parameterised field assignments are disallowed/ + */ public function testWriteManipulationWithNonScalarValuesDisallowed() { @@ -1797,12 +1801,7 @@ class DataObjectTest extends SapphireTest { $do->DynamicScalarOnlyField = true; $do->DynamicField = false; - try { - $do->write(); - $this->fail("Expected exception \"parameterised field assignments are disallowed\""); - } catch (Exception $ex) { - $this->assertContains('parameterised field assignments are disallowed', $ex->getMessage()); - } + $do->write(); } } diff --git a/tests/model/ManyManyListTest.php b/tests/model/ManyManyListTest.php index 11d3c2b9c..a75c92cc2 100644 --- a/tests/model/ManyManyListTest.php +++ b/tests/model/ManyManyListTest.php @@ -324,6 +324,10 @@ class ManyManyListTest extends SapphireTest { $this->assertEquals(1, $pivot->ManyManyDynamicField); } + /** + * @expectedException PHPUnit_Framework_Error + * @expectedExceptionMessageRegExp /parameterised field assignments are disallowed/ + */ public function testWriteManipulationWithNonScalarValuesDisallowed() { $left = MockDynamicAssignmentDataObject::create(); @@ -331,16 +335,11 @@ class ManyManyListTest extends SapphireTest { $right = MockDynamicAssignmentDataObject::create(); $right->write(); - try { - $left->MockManyMany()->add($right, array( - 'ManyManyStaticScalarOnlyField' => true, - 'ManyManyDynamicScalarOnlyField' => false, - 'ManyManyDynamicField' => true - )); - $this->fail("Expected exception \"parameterised field assignments are disallowed\""); - } catch (Exception $ex) { - $this->assertContains('parameterised field assignments are disallowed', $ex->getMessage()); - } + $left->MockManyMany()->add($right, array( + 'ManyManyStaticScalarOnlyField' => false, + 'ManyManyDynamicScalarOnlyField' => true, + 'ManyManyDynamicField' => false + )); } } diff --git a/tests/model/Mock/MockDynamicAssignmentDBField.php b/tests/model/Mock/MockDynamicAssignmentDBField.php index bd82d1700..5949434fd 100644 --- a/tests/model/Mock/MockDynamicAssignmentDBField.php +++ b/tests/model/Mock/MockDynamicAssignmentDBField.php @@ -15,7 +15,7 @@ class MockDynamicAssignmentDBField extends Boolean private $dynamicAssignment; /** - * @param $name + * @param string $name * @param boolean $scalarOnly Whether our fake field should be scalar only. * @param boolean $dynamicAssignment Whether our fake field will try to do a dynamic assignment. */ @@ -28,7 +28,7 @@ class MockDynamicAssignmentDBField extends Boolean /** * If the field value and dynamicAssignment are true, we'll try to do a dynamic assignment - * @param $value + * @param mixed $value * @return array|int|mixed */ public function prepValueForDB($value)