mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUG Address PR feedback.
This commit is contained in:
parent
4ec1a682cf
commit
adbc560bd7
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user