With codeception is there a way to use constants ( or variables) using the @example annotation ? I know that we can use doctrine style annotation.
Data is defined via the @example annotation, using JSON or Doctrine-style notation (limited to a single line). Doctrine-style
class PageCest { /** * @example(url="/", title="Welcome") * @example(url="/info", title="Info") * @example(url="/about", title="About Us") * @example(url="/contact", title="Contact Us") */ public function staticPages(AcceptanceTester $I, \Codeception\Example $example) { $I->amOnPage($example['url']); $I->see($example['title'], 'h1'); $I->seeInTitle($example['title']); } }
But using a constant which is working in doctrine doesn't seems to work here
/**
* @example(url=Class::Constant, title="Welcome")
*/
is there a way to achieve this to run multiple test examples but use constants or variables to provide the values?
It seems that there is no way to do that directly like doctrine's implementation. the workaround I found is to pass the constant name as a string .
/**
* @example(url="MyConstantName", title="Welcome")
*/
and then within the code use the constant function to find your constant value.
constant('Full\Namespace\MyClass::' . $example['MyConstantName'])