Skip to content

Commit

Permalink
Merge adf9c80 into 451c3cd
Browse files Browse the repository at this point in the history
  • Loading branch information
tkulka committed Apr 13, 2020
2 parents 451c3cd + adf9c80 commit cd1e64c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 8 additions & 0 deletions spec/Prophecy/Argument/Token/ExactValueTokenSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ function it_scores_10_if_value_is_an_object_and_equal_to_argument()
$this->scoreArgument($value2)->shouldReturn(10);
}

function it_scores_10_if_value_is_a_double_object_and_equal_to_argument(\stdClass $value)
{
$value2 = clone $value->getWrappedObject();

$this->beConstructedWith($value);
$this->scoreArgument($value2)->shouldReturn(10);
}

function it_does_not_scores_if_value_is_not_equal_to_argument()
{
$this->scoreArgument(50)->shouldReturn(false);
Expand Down
11 changes: 9 additions & 2 deletions src/Prophecy/Doubler/ClassPatch/ProphecySubjectPatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,17 @@ public function apply(ClassNode $node)
$prophecyArgument = new ArgumentNode('prophecy');
$prophecyArgument->setTypeHint('Prophecy\Prophecy\ProphecyInterface');
$prophecySetter->addArgument($prophecyArgument);
$prophecySetter->setCode('$this->objectProphecyClosure = function () use ($prophecy) { return $prophecy; };');
$prophecySetter->setCode(<<<PHP
if (null === \$this->objectProphecyClosure) {
\$this->objectProphecyClosure = static function () use (\$prophecy) {
return \$prophecy;
};
}
PHP
);

$prophecyGetter = new MethodNode('getProphecy');
$prophecyGetter->setCode('return call_user_func($this->objectProphecyClosure);');
$prophecyGetter->setCode('return \call_user_func($this->objectProphecyClosure);');

if ($node->hasMethod('__call')) {
$__call = $node->getMethod('__call');
Expand Down

0 comments on commit cd1e64c

Please sign in to comment.