Skip to content

Commit

Permalink
Merge pull request #6614 from Codeception/try-to-methods-always-retur…
Browse files Browse the repository at this point in the history
…n-bool

tryTo methods must always return Boolean result
  • Loading branch information
Naktibalda committed Dec 17, 2022
2 parents 7139bca + 63aaaa4 commit 7bee938
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
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');
}
}

0 comments on commit 7bee938

Please sign in to comment.