Skip to content

Commit

Permalink
Bugfix issue #5163 (#5236)
Browse files Browse the repository at this point in the history
* [Yii2] Bugfix issue 5163
* Address case when argument is instance of MockObject but no __mocked property
  • Loading branch information
dh9325 authored and Naktibalda committed Dec 18, 2018
1 parent 45c82b2 commit 51ea153
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Codeception/Step.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Codeception\Step\Argument\FormattedOutput;
use Codeception\Step\Meta as MetaStep;
use Codeception\Util\Locator;
use PHPUnit\Framework\MockObject\MockObject;

abstract class Step
{
Expand Down Expand Up @@ -173,7 +174,7 @@ protected function getClassName($argument)
{
if ($argument instanceof \Closure) {
return 'Closure';
} elseif ((isset($argument->__mocked))) {
} elseif ($argument instanceof MockObject && isset($argument->__mocked)) {
return $this->formatClassName($argument->__mocked);
}

Expand Down
9 changes: 9 additions & 0 deletions tests/unit/Codeception/StepTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Codeception\Util\Stub;
use Facebook\WebDriver\WebDriverBy;
use Codeception\Util\Locator;

Expand Down Expand Up @@ -32,6 +33,14 @@ public function testGetArguments()

$step = $this->getStep([null, [['PDO', 'getAvailableDrivers']]]);
$this->assertEquals('["PDO","getAvailableDrivers"]', $step->getArgumentsAsString());

$step = $this->getStep([null, [[Stub::make($this, []), 'testGetArguments']]]);
$this->assertEquals('["StepTest","testGetArguments"]', $step->getArgumentsAsString());

$mock = $this->createMock(get_class($this));
$step = $this->getStep([null, [[$mock, 'testGetArguments']]]);
$className = get_class($mock);
$this->assertEquals('["' . $className . '","testGetArguments"]', $step->getArgumentsAsString());
}

public function testGetHtml()
Expand Down

0 comments on commit 51ea153

Please sign in to comment.