diff options
-rw-r--r-- | db/entity.php | 3 | ||||
-rw-r--r-- | tests/db/EntityTest.php | 6 |
2 files changed, 5 insertions, 4 deletions
diff --git a/db/entity.php b/db/entity.php index 2c6f4f899..5654e1b80 100644 --- a/db/entity.php +++ b/db/entity.php @@ -121,7 +121,8 @@ abstract class Entity { */ public function fromRow(array $row){ foreach($row as $key => $value){ - $this->$key = $value; + $prop = $this->columnToProperty($key); + $this->$prop = $value; } } diff --git a/tests/db/EntityTest.php b/tests/db/EntityTest.php index 44f288a04..793ca8ded 100644 --- a/tests/db/EntityTest.php +++ b/tests/db/EntityTest.php @@ -43,15 +43,15 @@ class EntityTest extends \PHPUnit_Framework_TestCase { public function testFromRow(){ $row = array( - 'name' => 'john', + 'pre_name' => 'john', 'email' => 'john@something.com' ); $entity = new TestEntity(); $entity->fromRow($row); - $this->assertEquals($row['name'], $entity->name); - $this->assertEquals($row['email'], $entity->email); + $this->assertEquals($row['pre_name'], $entity->getPreName()); + $this->assertEquals($row['email'], $entity->getEmail()); } |