英文:
Does Codeception BDD have a @Transform function like Behat does?
问题
在Behat中,你可以进行如下的转换:
<?php
/**
* @Transform /^"([^"]+)" shipping method$/
* @Transform /^shipping method "([^"]+)"$/
* @Transform :shippingMethod
*/
public function getShippingMethodByName($shippingMethodName)
{
$shippingMethod = $this->shippingMethodRepository->findOneByName($shippingMethodName);
Assert::notNull(
$shippingMethod,
sprintf('Shipping method with name "%s" does not exist', $shippingMethodName)
);
return $shippingMethod;
}
/**
* @Given /^(shipping method "[^"]+") belongs to ("[^"]+" tax category)$/
*/
public function shippingMethodBelongsToTaxCategory(
ShippingMethodInterface $shippingMethod,
TaxCategoryInterface $taxCategory
) {
// some logic here
}
基本上,你可以在变量前面加上冒号,并使用 @Transform
关键字来实现这种转换。
在Codeception中是否有类似的方式可以实现这个功能?
英文:
In Behat you can do a transformation like so:
<?php
/**
* @Transform /^"([^"]+)" shipping method$/
* @Transform /^shipping method "([^"]+)"$/
* @Transform :shippingMethod
*/
public function getShippingMethodByName($shippingMethodName)
{
$shippingMethod = $this->shippingMethodRepository->findOneByName($shippingMethodName);
Assert::notNull(
$shippingMethod,
sprintf('Shipping method with name "%s" does not exist', $shippingMethodName)
);
return $shippingMethod;
}
/**
* @Given /^(shipping method "[^"]+") belongs to ("[^"]+" tax category)$/
*/
public function shippingMethodBelongsToTaxCategory(
ShippingMethodInterface $shippingMethod,
TaxCategoryInterface $taxCategory
) {
// some logic here
}
Basically, adding a colon before a variable and using @Transform
keyword.
Is there a way to do that in Codeception?
答案1
得分: 1
Codeception,尽管使用了Behat供应商库,但不实现@Transform
功能。
英文:
codeception, despite using behat vendor libraries, does not implement the @Transform
feature.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论