Skip to content

Replace annotations with attributes#6476

Merged
Naktibalda merged 1 commit intoCodeception:5.0from
TavoNiievez:5.0-attributes
Jun 30, 2022
Merged

Replace annotations with attributes#6476
Naktibalda merged 1 commit intoCodeception:5.0from
TavoNiievez:5.0-attributes

Conversation

@TavoNiievez
Copy link
Member

No description provided.

Copy link
Member

@Naktibalda Naktibalda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we need test for annotations :)

* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This docblock was autogenerated, generator still doesn't generate any comments with self return type -

$returnType = 'void';
if ($method->name == 'haveFriend') {
$returnType = Friend::class;
}
$params = $this->getParamsString($method);
$inherited[] = (new Template($this->inheritedMethodTemplate))
->place('method', $method->name)
->place('params', $params)
->place('return', $returnType)
->produce();
}

@DavertMik
Copy link
Member

@TavoNiievez thank you! This one is really important to get merged!
Please check my PR #6487 as it also adds support for repeatable attributes so we could have multiple #[Group] attributes

@Naktibalda
Copy link
Member

Naktibalda commented Jun 30, 2022

Are we dropping support for annotations now?
If we are keeping support for annotations, we must have some tests using or (even better) testing them.

* @group core
*/
#[DataProvider('getRelativeDirTestData')]
#[Group('core')]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codeception DataProvider attribute does not work in Unit tests.

  [ArgumentCountError] Too few arguments to function Codeception\Util\PathResolverTest::testGetRelativeDir(), 0 passed in /.../Codeception/vendor/phpunit/phpunit/src/Framework/TestCase.php on line 1545 and exactly 4 expected


#1  /.../Codeception/tests/unit/Codeception/Util/PathResolverTest.php:15

@DavertMik
Copy link
Member

Are we dropping support for annotations now?
If we are keeping support for annotations, we must have some tests using or (even better) testing them.

No, we are not dropping, so I agree that some tests with annotation should also be kept

@Naktibalda Naktibalda merged commit 100a2ab into Codeception:5.0 Jun 30, 2022
@Naktibalda
Copy link
Member

I resolved conflicts, fixed failing tests and merged to 5.0

See 128727f for tests where it was necessary to keep @dataProvider annotation.

@TavoNiievez
Copy link
Member Author

Thank you @Naktibalda

@Naktibalda
Copy link
Member

and d432509

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants