-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC][Behat] Extract reusable transformers #4269
[RFC][Behat] Extract reusable transformers #4269
Conversation
@@ -24,6 +24,8 @@ | |||
<parameter key="sylius.behat.context.setup.shipping.class">Sylius\Behat\Context\Setup\ShippingContext</parameter> | |||
<parameter key="sylius.behat.context.setup.zone.class">Sylius\Behat\Context\Setup\ZoneContext</parameter> | |||
<parameter key="sylius.behat.context.setup.tax.class">Sylius\Behat\Context\Setup\TaxContext</parameter> | |||
<parameter key="sylius.behat.context.setup.lexical.class">Sylius\Behat\Context\Setup\LexicalContext</parameter> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO new namespace sylius.behat.context.transform.*
would be the most suitable for contexts that only transforms arguments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed 👍 I couldn't come up with some good name, bad transform
is simple and accurate 😄
👍, we will have to use shared context directly only to set a resource after this PR gets merged! :) |
b3975b8
to
1f9f43c
Compare
7331229
to
d563782
Compare
} | ||
|
||
/** | ||
* @Transform /^"([^"]+)%"$/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't it be better to use here regex which will match only floats? ([0-9]*\.)?[0-9]+
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can make it /^"((?:\d+\.)?\d+)%"$/
🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, same for price from string :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
a72a4fa
to
503386a
Compare
Also implement usage of LexicalContext in promotions steps
503386a
to
6b0f4aa
Compare
[RFC][Behat] Extract reusable transformers
Thanks Mateusz! 👍 |
In order to avoid (current or future) duplications and make new behat scenarios even easier to write and it (they're already pretty natural 😄), here is propose of two additional contexts, containing reusable transformers. Concept is widely described in related issue, just to make it clear about new features:
SharedStorageContext
:it
-> transform to last resource fromSharedStorage
this|that|the {resource}
-> transform to specific resource fromSharedStorage
LexicalContext
:€103.00
(string) ->10300
(int)20%
(string) ->0.2
(float)I'm sure we could find lots of more use cases that can be placed in one of this context. Moreover, I hope that by using them wisely, we could get rid of injecting
SharedContext
into most of contexts and minimize number of private functions.