Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #106 from bjornpost/fix-domainobject-set
Browse files Browse the repository at this point in the history
Make sure variable can be set to NULL if empty string before
  • Loading branch information
lox committed Apr 18, 2014
2 parents 9f59f08 + 945762e commit e0f78a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Pheasant/DomainObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ public function get($prop)
*/
public function set($prop, $value)
{
if (!isset($this->_data[$prop]) || $this->_data[$prop] != $value) {
if (!isset($this->_data[$prop]) || $this->_data[$prop] !== $value) {
$this->_data[$prop] = $value;
$this->_changed[] = $prop;
}
Expand Down
9 changes: 9 additions & 0 deletions tests/Pheasant/Tests/TypeMarshallingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,13 @@ public function testDecimalTypesAreMarshalledCorrectInLocale()

setlocale(LC_ALL, $prevLocale);
}

public function testVariableIsNullable() {
$object = new DomainObject;
$object->weight = 88.5; // var type = double
$object->weight = ''; // var type = string
$object->weight = null;

$this->assertSame($object->weight, null);
}
}

0 comments on commit e0f78a1

Please sign in to comment.