8000 Don't override test feature at runtime · Codeception/Codeception@0f9141b · GitHub
[go: up one dir, main page]

Skip to content

Commit 0f9141b

Browse files
committed
Don't override test feature at runtime
1 parent 92af1b4 commit 0f9141b

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

src/Codeception/Actor.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,20 @@ protected function getScenario(): Scenario
2424
return $this->scenario;
2525
}
2626

27-
public function wantToTest(string $text): void
27+
/**
28+
* This method is used by Cept format to add description to test output
29+
*
30+
* It can be used by Cest format too.
31+
* It doesn't do anything when called, but it is parsed by Parser before execution
32+
*
33+
* @see \Codeception\Lib\Parser::parseFeature
34+
*/
35+
public function wantTo(string $text): void
2836
{
29-
$this->wantTo('test ' . $text);
3037
}
3138

32-
public function wantTo(string $text): void
39+
public function wantToTest(string $text): void
3340
{
34-
$this->scenario->setFeature($text);
3541
}
3642

3743
public function __call(string $method, array $arguments)

src/Codeception/Test/Cept.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* Executes tests delivered in Cept format.
1818
* Prepares metadata, parses test body on preload, and executes a test in `test` method.
19+
*
20+
* Note: If the time came to delete Cept format, please delete Actor::wantTo method too
1921
*/
2022
class Cept extends Test implements Interfaces\Plain, Interfaces\ScenarioDriven, Interfaces\Reported, Interfaces\Dependent
2123
{

tests/cli/WantToCest.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,40 @@ public function iWantToSetsFeatureInCestFormat(CliGuy $I): void
1616
$I->seeInShellOutput('+ WantToCest: Check if I->wantTo works');
1717
}
1818

19-
public function testerWantToSetsFeatureInCestFormat(CliGuy $I): void
19+
/**
20+
* Tests https://github.com/Codeception/Codeception/issues/4123
21+
*/
22+
public function testerWantDoesntSetFeatureInCestFormat(CliGuy $I): void
2023
{
2124
$I->amInPath('tests/data/want_to');
2225
$I->executeCommand('run --no-ansi unit WantToCest.php:^TesterWantTo');
23-
$I->seeInShellOutput('+ WantToCest: Check if tester->wantTo works');
26+
$I->seeInShellOutput('+ WantToCest: Tester want to');
2427
}
2528

26-
public function variablePassedToIWantToIsEvaluated(CliGuy $I): void
29+
public function iWantToWithVariableIsIgnored(CliGuy $I): void
2730
{
2831
$I->amInPath('tests/data/want_to');
2932
$I->executeCommand('run --no-ansi unit WantToCest.php:Variable');
30-
$I->seeInShellOutput('+ WantToCest: Check if variable wantTo is evaluated');
33+
$I->seeInShellOutput('+ WantToCest: Variable argument of want to');
3134
}
3235

33-
public function iWantToIncorrectlyOverridesDataproviderData(CliGuy $I): void
36+
/**
37+
* Tests https://github.com/Codeception/Codeception/issues/4124
38+
*/
39+
public function iWantToDoesntOverrideDataproviderData(CliGuy $I): void
3440
{
3541
$I->amInPath('tests/data/want_to');
3642
$I->executeCommand('run --no-ansi unit WantToCest.php:DataProviderIWantTo');
37-
$I->seeInShellOutput('+ WantToCest: Check if I->wantTo doesn\'t override data provider data');
43+
$I->seeInShellOutput('+ WantToCest: Check if I->wantTo doesn\\\'t override data provider data | "aaa"');
44+
$I->seeInShellOutput('+ WantToCest: Check if I->wantTo doesn\\\'t override data provider data | "bbb"');
3845
}
3946

40-
public function testerWantToIncorrectlyOverridesDataproviderData(CliGuy $I): void
47+
public function testerWantToDoesntOverrideDataproviderData(CliGuy $I): void
4148
{
4249
$I->amInPath('tests/data/want_to');
4350
$I->executeCommand('run --no-ansi unit WantToCest.php:DataProviderTesterWantTo');
44-
$I->seeInShellOutput('+ WantToCest: Check if tester->wantTo doesn\'t override data provider data');
51+
$I->seeInShellOutput('+ WantToCest: Data provider tester want to | "aaa"');
52+
$I->seeInShellOutput('+ WantToCest: Data provider tester want to | "bbb"');
4553
}
4654

4755
public function wantToTextIsUsedInXmlReport(CliGuy $I): void

0 commit comments

Comments
 (0)
0