Skip to content

Commit 0f94a07

Browse files
committed
robo file added
1 parent 6726788 commit 0f94a07

4 files changed

Lines changed: 126 additions & 59 deletions

File tree

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
}
1010
],
1111
"require": {
12-
"php": ">=5.4.0"
12+
"php": ">=5.4.0",
13+
"myclabs/deep-copy": "*"
1314
},
1415
"require-dev": {
1516
"phpunit/phpunit": "3.7.*"

composer.lock

Lines changed: 100 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Codeception/Specify.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ function specify($specification, \Closure $callable = null, $params = [])
1515
$name = $this->getName();
1616
$this->setName($this->getName().' | '.$specification);
1717

18+
$copier = new \DeepCopy\DeepCopy();
1819
// copy current object properties
1920
$properties = get_object_vars($this);
2021
foreach ($properties as $property => $val) {
2122
if ($property == '__beforeSpecify') continue;
2223
if ($property == '__afterSpecify') continue;
2324
if ($property == '__savedProperties') continue;
24-
if (is_object($val)) {
25-
$this->$property = clone($val);
26-
}
25+
$this->$property = $copier->copy($val);
2726
}
2827

28+
2929
// prepare for execution
3030
$throws = $this->getSpecifyExpectedException($params);
3131
$examples = $this->getSpecifyExamples($params);

tests/SpecifyTest.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class SpecifyTest extends \PHPUnit_Framework_TestCase {
66
use Codeception\Specify;
77

88
protected $user;
9+
protected $a;
910

1011
public function testSpecification()
1112
{
@@ -99,6 +100,25 @@ public function testExamples()
99100
function testOnlySpecifications()
100101
{
101102
$this->specify('should be valid');
102-
}
103+
}
104+
105+
public function testDeepCopy()
106+
{
107+
$this->a = new TestOne();
108+
$this->a->prop = new TestOne();
109+
$this->a->prop->prop = 1;
110+
$this->specify('nested object can be changed', function() {
111+
$this->assertEquals(1, $this->a->prop->prop);
112+
$this->a->prop->prop = 2;
113+
$this->assertEquals(2, $this->a->prop->prop);
114+
});
115+
$this->assertEquals(1, $this->a->prop->prop);
116+
117+
}
103118

104119
}
120+
121+
class TestOne
122+
{
123+
public $prop;
124+
}

0 commit comments

Comments
 (0)