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

tryTo methods must always return Boolean result #6614

Merged
merged 1 commit into from Dec 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Codeception/Step/TryTo.php
Expand Up @@ -46,6 +46,8 @@ public static function getTemplate(Template $template): ?Template
return $template
->place('doc', $conditionalDoc)
->place('action', 'tryTo' . ucfirst($action))
->place('return', 'return ')
->place('return_type', ': bool')
->place('step', 'TryTo');
}
}
2 changes: 1 addition & 1 deletion tests/data/retries/tests/_support/Helper/Retry.php
Expand Up @@ -16,7 +16,7 @@ public function _before(\Codeception\TestInterface $test)
$this->time = microtime(true);
}

public function failAt($amount = 3)
public function failAt($amount = 3): void
{
if ($this->fails < $amount) {
++$this->fails;
Expand Down
1 change: 1 addition & 0 deletions tests/data/retries/tests/retry.suite.yml
Expand Up @@ -2,6 +2,7 @@ actor: RetryTester
modules:
enabled:
- \Helper\Retry
- Asserts
step_decorators:
- Codeception\Step\Retry
- Codeception\Step\TryTo
3 changes: 2 additions & 1 deletion tests/data/retries/tests/retry/TryToCest.php
Expand Up @@ -7,6 +7,7 @@ class TryToCest
#[Group('ignore')]
public function ignoreFailure(RetryTester $I)
{
$I->tryToFailAt(1);
$result = $I->tryToFailAt(1);
$I->assertFalse($result, 'tryTo must return false on failure');
}
}