Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not truncate arguments for --html options #5870

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Codeception/Step.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

abstract class Step
{
const ARGUMENTS_DEFAULT_LENGTH = 200;

const STACK_POSITION = 3;
/**
* @var string
Expand Down Expand Up @@ -94,7 +96,7 @@ public function getArguments()
return $this->arguments;
}

public function getArgumentsAsString($maxLength = 200)
public function getArgumentsAsString($maxLength = self::ARGUMENTS_DEFAULT_LENGTH)
Naktibalda marked this conversation as resolved.
Show resolved Hide resolved
{
$arguments = $this->arguments;

Expand Down Expand Up @@ -224,15 +226,15 @@ public function getHtml($highlightColor = '#732E81')
return sprintf('%s %s', ucfirst($this->prefix), $this->humanize($this->getAction()));
}

return sprintf('%s %s <span style="color: %s">%s</span>', ucfirst($this->prefix), htmlspecialchars($this->humanize($this->getAction())), $highlightColor, htmlspecialchars($this->getHumanizedArguments()));
return sprintf('%s %s <span style="color: %s">%s</span>', ucfirst($this->prefix), htmlspecialchars($this->humanize($this->getAction())), $highlightColor, htmlspecialchars($this->getHumanizedArguments(0)));
}

public function getHumanizedActionWithoutArguments()
{
return $this->humanize($this->getAction());
}

public function getHumanizedArguments($maxLength = 200)
public function getHumanizedArguments($maxLength = self::ARGUMENTS_DEFAULT_LENGTH)
{
return $this->getArgumentsAsString($maxLength);
}
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/Codeception/StepTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use Codeception\Util\Stub;
use Facebook\WebDriver\WebDriverBy;
use Codeception\Util\Locator;
use Codeception\Step;

class StepTest extends \PHPUnit\Framework\TestCase
{
Expand Down Expand Up @@ -51,6 +52,10 @@ public function testGetHtml()

$step = $this->getStep(['Do some testing', []]);
$this->assertSame('I do some testing', $step->getHtml());

$argument = str_repeat("A string with a length exceeding Step::ARGUMENTS_DEFAULT_LENGTH.", Step::ARGUMENTS_DEFAULT_LENGTH);
$step = $this->getStep(['Do some testing', [$argument]]);
$this->assertSame('I do some testing <span style="color: #732E81">&quot;' . $argument . '&quot;</span>', $step->getHtml());
}

public function testLongArguments()
Expand Down