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

Commit

Permalink
Merge pull request #17 from v-technologies/fix-null-affectation
Browse files Browse the repository at this point in the history
fix: makes null affectations transparent in Simples_Document
  • Loading branch information
RomainS authored Jun 29, 2016
2 parents 7a07b0e + 7163503 commit 5ea6a76
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/Simples/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ public function __isset($path) {
* @param mixed $value Property value
*/
public function __set($name, $value) {
$this->set($name, $value) ;
if (!is_null($value)) {
$this->set($name, $value) ;
}
}

/**
Expand Down
16 changes: 16 additions & 0 deletions tests/lib/Simples/DocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ public function testAccessors() {


}


/**
* BUG TEST
* when setting a property to null, SimplesDocument would set the whole
* data to the property name!
* !16
*/
public function testNullAffectation() {
$document = new Simples_Document();

$document->a = null;

// we don't want null values... nor strange behaviors
$this->assertEquals(array(), $document->get());
}

public function testToArray() {
$document = new Simples_Document($this->data['standard']) ;
Expand Down

0 comments on commit 5ea6a76

Please # to comment.