Skip to content

Commit 9550fff

Browse files
committed
Fixed issue: Property $beforeSpecify does not exist
1 parent 3a21e75 commit 9550fff

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/Codeception/Specify.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,14 @@ private function specifyRestoreProperties($properties)
224224
private function getSpecifyObjectProperties()
225225
{
226226
$properties = [];
227+
$myReflection = new \ReflectionObject($this);
227228

228-
foreach (get_object_vars($this) as $property => $value) {
229-
if ($this->specifyConfig->propertyIgnored($property)) {
229+
foreach ($myReflection->getProperties() as $property) {
230+
if ($this->specifyConfig->propertyIgnored($property->getName())) {
230231
continue;
231232
}
232233

233-
$properties[] = new ObjectProperty($this, $property, $value);
234+
$properties[] = new ObjectProperty($this, $property);
234235
}
235236

236237
// isolate mockObjects property from PHPUnit_Framework_TestCase

tests/SpecifyTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class SpecifyTest extends \SpecifyUnitTest
44
{
55
protected $user;
66
protected $a;
7+
protected $private = false;
78

89
public function testSpecification()
910
{
@@ -227,7 +228,15 @@ function testPropertyRestore()
227228
['bye'],
228229
['world'],
229230
]]);
231+
230232
$this->assertEquals(['hello', 'world'], $this->testOne->prop);
233+
$this->assertFalse($this->private);
234+
235+
$this->specify('property $private should be restored properly', function() {
236+
$this->private = 'i\'m protected';
237+
});
238+
239+
$this->assertFalse($this->private);
231240
}
232241

233242
public function testExamplesIndexInName()

tests/_support/SpecifyUnitTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
class SpecifyUnitTest extends \PHPUnit_Framework_TestCase
44
{
55
use Codeception\Specify;
6+
7+
private $private = true;
68
}

0 commit comments

Comments
 (0)