From 5e5af941db019da57fa2bfd5ecb06c90bd6b7a33 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 25 Nov 2013 23:03:50 -0500 Subject: [PATCH] Add stub test case methods. --- Cake/ORM/Entity.php | 17 ++++++++++++++++- Cake/Test/TestCase/ORM/EntityTest.php | 17 +++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/Cake/ORM/Entity.php b/Cake/ORM/Entity.php index 45b917160ad..e14e1c968ea 100644 --- a/Cake/ORM/Entity.php +++ b/Cake/ORM/Entity.php @@ -318,6 +318,21 @@ public function hiddenProperties() { return $this->_hidden; } +/** + * Get the list of visible properties. + * + * The list of visible properties is all standard properties + * plus virtual properties minus hidden properties. + * + * @return array A list of properties that are 'visible' in all + * representations. + */ + public function visibleProperties() { + $properties = array_keys($this->_properties); + $properties = array_merge($properties, $this->_virtual); + return array_diff($properties, $this->_hidden); + } + /** * Returns an array with all the properties that have been set * to this entity @@ -329,7 +344,7 @@ public function hiddenProperties() { */ public function toArray() { $result = []; - foreach ($this->_properties as $property => $value) { + foreach ($this->visibleProperties() as $property) { $value = $this->get($property); if (is_array($value) && isset($value[0]) && $value[0] instanceof self) { $result[$property] = []; diff --git a/Cake/Test/TestCase/ORM/EntityTest.php b/Cake/Test/TestCase/ORM/EntityTest.php index ad80bc51355..fe9f25d3d26 100644 --- a/Cake/Test/TestCase/ORM/EntityTest.php +++ b/Cake/Test/TestCase/ORM/EntityTest.php @@ -649,6 +649,14 @@ public function testToArrayWithAccessor() { $this->assertEquals($expected, $entity->toArray()); } + public function testToArrayHiddenProperties() { + $this->markTestIncomplete("not done"); + } + + public function testToArrayVirtualProperties() { + $this->markTestIncomplete("not done"); + } + /** * Tests that missing fields will not be passed as null to the validator * @@ -745,4 +753,13 @@ public function testCleanRemovesErrors() { $entity->clean(); $this->assertEmpty($entity->errors()); } + + public function testHideProperties() { + $this->markTestIncomplete("not done"); + } + + public function testVisibleProperties() { + $this->markTestIncomplete("not done"); + } + }