Codeception BDD是否有类似Behat的@Transform函数?

huangapple go评论97阅读模式
英文:

Does Codeception BDD have a @Transform function like Behat does?

问题

在Behat中,你可以进行如下的转换:

  1. <?php
  2. /**
  3. * @Transform /^"([^"]+)" shipping method$/
  4. * @Transform /^shipping method "([^"]+)"$/
  5. * @Transform :shippingMethod
  6. */
  7. public function getShippingMethodByName($shippingMethodName)
  8. {
  9. $shippingMethod = $this->shippingMethodRepository->findOneByName($shippingMethodName);
  10. Assert::notNull(
  11. $shippingMethod,
  12. sprintf('Shipping method with name "%s" does not exist', $shippingMethodName)
  13. );
  14. return $shippingMethod;
  15. }
  16. /**
  17. * @Given /^(shipping method "[^"]+") belongs to ("[^"]+" tax category)$/
  18. */
  19. public function shippingMethodBelongsToTaxCategory(
  20. ShippingMethodInterface $shippingMethod,
  21. TaxCategoryInterface $taxCategory
  22. ) {
  23. // some logic here
  24. }

基本上,你可以在变量前面加上冒号,并使用 @Transform 关键字来实现这种转换。

Codeception中是否有类似的方式可以实现这个功能?

英文:

In Behat you can do a transformation like so:

  1. &lt;?php
  2. /**
  3. * @Transform /^&quot;([^&quot;]+)&quot; shipping method$/
  4. * @Transform /^shipping method &quot;([^&quot;]+)&quot;$/
  5. * @Transform :shippingMethod
  6. */
  7. public function getShippingMethodByName($shippingMethodName)
  8. {
  9. $shippingMethod = $this-&gt;shippingMethodRepository-&gt;findOneByName($shippingMethodName);
  10. Assert::notNull(
  11. $shippingMethod,
  12. sprintf(&#39;Shipping method with name &quot;%s&quot; does not exist&#39;, $shippingMethodName)
  13. );
  14. return $shippingMethod;
  15. }
  16. /**
  17. * @Given /^(shipping method &quot;[^&quot;]+&quot;) belongs to (&quot;[^&quot;]+&quot; tax category)$/
  18. */
  19. public function shippingMethodBelongsToTaxCategory(
  20. ShippingMethodInterface $shippingMethod,
  21. TaxCategoryInterface $taxCategory
  22. ) {
  23. // some logic here
  24. }

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.

huangapple
  • 本文由 发表于 2023年3月7日 23:25:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/75663918.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定