BUG Address PR feedback.

This commit is contained in:
Maxime Rainville 2019-02-25 15:16:26 +13:00
parent 4ec1a682cf
commit adbc560bd7
3 changed files with 16 additions and 18 deletions

View File

@ -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();
}
}

View File

@ -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
));
}
}

View File

@ -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)