-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't extract static properties, as they won't get serialized
- Loading branch information
Showing
6 changed files
with
71 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
test/EdeMeijer/SerializeDebugger/Test/ObjectPropertyExtractorTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
|
||
namespace EdeMeijer\SerializeDebugger\Test; | ||
|
||
|
||
use EdeMeijer\SerializeDebugger\ObjectPropertyExtractor; | ||
use EdeMeijer\SerializeDebugger\Test\Mocks\TestSubClass; | ||
|
||
class ObjectPropertyExtractorTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testExtraction() | ||
{ | ||
require_once __DIR__ . '/Mocks/TestBaseClass.php'; | ||
require_once __DIR__ . '/Mocks/TestSubClass.php'; | ||
|
||
$objWithInheritance = new TestSubClass(); | ||
|
||
$SUT = new ObjectPropertyExtractor($objWithInheritance); | ||
|
||
$extractedProperties = $SUT->getProperties(); | ||
|
||
// We expect 7 properties, no static properties | ||
$this->assertCount(7, $extractedProperties); | ||
// Check if all expected properties are indexed | ||
$this->assertContains('privateSubVar', $extractedProperties); | ||
$this->assertContains('protectedSubVar', $extractedProperties); | ||
$this->assertContains('publicSubVar', $extractedProperties); | ||
$this->assertContains('overriddenBaseVar', $extractedProperties); | ||
$this->assertContains('protectedBaseVar', $extractedProperties); | ||
$this->assertContains('publicBaseVar', $extractedProperties); | ||
$this->assertContains('privateBaseVar', $extractedProperties); | ||
// Check if value of overridden property is the one of the sub class | ||
$overriddenBaseVar = $SUT->getValue('overriddenBaseVar'); | ||
$this->assertEquals('def', $overriddenBaseVar); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...eDebugger/Test/PlainTextFormatterTest.php → ...gger/Test/Unit/PlainTextFormatterTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters