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

generate:cest: Adding declare(strict_types=1); and return type void to generated files #6736

Open
wants to merge 5 commits into
base: 5.1
Choose a base branch
from
Open
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
14 changes: 9 additions & 5 deletions src/Codeception/Lib/Generator/Cest.php
Expand Up @@ -16,17 +16,20 @@ class Cest

protected string $template = <<<EOF
<?php

declare(strict_types=1);
{{namespace}}

class {{name}}Cest
final class {{name}}Cest
{
public function _before({{actor}} \$I)
public function _before({{actor}} \$I): void
{
// Code here will be executed before each test.
// To execute code before just *some* tests, use the `#[Before]` attribute, see https://codeception.com/docs/AdvancedUsage#BeforeAfter-Attributes
}

// tests
public function tryToTest({{actor}} \$I)
// Your tests. All `public` methods will be executed as tests:

public function tryToTest({{actor}} \$I, Scenario \$scenario): void
{
}
}
Expand All @@ -51,6 +54,7 @@ public function produce(): string

if ($namespaceHeader) {
$namespaceHeader .= "\nuse " . $this->supportNamespace() . $actor . ";";
$namespaceHeader .= "\nuse Codeception\\Scenario;";
}

return (new Template($this->template))
Expand Down