Skip to content
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

[Admin][Payment] Sorting payment metods by position #6745

Merged
merged 5 commits into from
Nov 23, 2016

Conversation

tuka217
Copy link
Contributor

@tuka217 tuka217 commented Nov 16, 2016

Q A
Bug fix? no
New feature? yes
BC breaks? yes
Related tickets -
License MIT

@tuka217 tuka217 force-pushed the sort-payment-method-by-position branch 3 times, most recently from 8a1ad30 to 464b9d4 Compare November 16, 2016 14:20

@ui
Scenario: Payment methods are sorted by position in ascending order by default
When I am browsing payment methods
Copy link
Member

Choose a reason for hiding this comment

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

When I browse payment methods
or
Given I am browsing payment methods
in my opinion


@ui
Scenario: Payment method added at no position is added as the last one
Given the store also allows paying with "Credit Card"
Copy link
Member

Choose a reason for hiding this comment

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

I guess that also is not needed

* @Given the store allows paying :paymentMethodName
* @Given the store allows paying with :paymentMethodName
* @Given the store (also) allows paying :paymentMethodName
* @Given the store (also) allows paying with :paymentMethodName
Copy link
Member

Choose a reason for hiding this comment

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

You could merge this line with above by adding (with)

Copy link
Contributor

Choose a reason for hiding this comment

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

Is the variation without "with" correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably not, but it is old step. I can fix it here if it won't cause to many problems.

Copy link
Contributor

Choose a reason for hiding this comment

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

@pamil While it doesn't sound right for credit card or paypal; for offline (which we use quite a lot) using with would be silly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yups

@@ -16,6 +16,8 @@
use Sylius\Component\Payment\Model\PaymentMethodInterface;

/**
* @mixin PaymentMethod
Copy link
Member

Choose a reason for hiding this comment

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

We should not add @mixin docbloc

@tuka217 tuka217 force-pushed the sort-payment-method-by-position branch from 464b9d4 to cd078dc Compare November 16, 2016 14:23
->add('position', IntegerType::class, [
'required' => false,
'label' => 'sylius.form.shipping_method.position',
])
->add('enabled', 'checkbox', [
Copy link
Contributor

Choose a reason for hiding this comment

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

Imo checkbox should be changed into CheckboxType::class.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not a part of this PR, I've already done that in #6738.

And I am logged in as an administrator

@ui
Scenario: Payment methods are sorted by position in ascending order by default
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually it does not assert that methods are sorted by position, because they can be as well sorted by id and this scenario would pass. We need to shuffle the order of creating payment methods.

* @Given the store allows paying :paymentMethodName
* @Given the store allows paying with :paymentMethodName
* @Given the store (also) allows paying :paymentMethodName
* @Given the store (also) allows paying with :paymentMethodName
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the variation without "with" correct?

->add('position', IntegerType::class, [
'required' => false,
'label' => 'sylius.form.shipping_method.position',
])
->add('enabled', 'checkbox', [
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a part of this PR, I've already done that in #6738.


function it_adds_add_code_event_subscriber(FormBuilder $builder)
{
$builder->add(Argument::any(), Argument::cetera())->willReturn($builder);
Copy link
Contributor

Choose a reason for hiding this comment

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

It does not check anything, deleting the whole spec would be the better option 🗡

Copy link
Contributor

Choose a reason for hiding this comment

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

💯 👍 for deleting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you say, that I can kill it then I will 🔫

@tuka217 tuka217 force-pushed the sort-payment-method-by-position branch 2 times, most recently from d1f0a04 to 248d3c4 Compare November 17, 2016 08:51
);
}


Copy link
Member

Choose a reason for hiding this comment

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

Redundant blank line.

@@ -83,20 +83,20 @@ public function __construct(
}

/**
* @Given the store allows paying :paymentMethodName
* @Given the store allows paying with :paymentMethodName
* @Given the store (also) allows paying (with) :paymentMethodName
Copy link
Member

@lchrusciel lchrusciel Nov 17, 2016

Choose a reason for hiding this comment

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

After this change few steps could be broken. It is because also keyword is optional but spaces around it are not. So only two valid sentences are store (two spaces here) allows and store also allows, but store allows will be broken. (same for with)

Copy link
Member

Choose a reason for hiding this comment

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

Or I can be wrong and it will work. Nvm 💨

Copy link
Member

Choose a reason for hiding this comment

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

If I am right, when the definition of step in docblock is not a regexp, behat is quite clever and interprets this correctly.

Copy link
Member

Choose a reason for hiding this comment

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

My bad! Sorry ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

That's not true, Turnip will allow for the following patterns:

store allows
store also allows

Unfortunately, it will also allow for:

store  allows
storeallows
storealso allows
store alsoallows
storealsoallows

See https://github.com/Behat/Behat/blob/v3.2.2/src/Behat/Behat/Definition/Pattern/Policy/TurnipPatternPolicy.php#L161

Copy link
Member

Choose a reason for hiding this comment

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

So meaningful regexp :D

Nevertheless, at the end we should have store (also )allows

I knew, there were a reason for this change 🎱

@tuka217 tuka217 force-pushed the sort-payment-method-by-position branch 5 times, most recently from 99d189b to 0e022c6 Compare November 21, 2016 14:08
…r implementation

[Behat] Add scenario about viewing sorted payment method during checkout and it's implementation
[AdminBundle] Add sorting by position, allow admin to declare payment method position
@tuka217 tuka217 force-pushed the sort-payment-method-by-position branch from 0e022c6 to a067654 Compare November 22, 2016 09:00
@pjedrzejewski pjedrzejewski merged commit a6d0231 into Sylius:master Nov 23, 2016
@pjedrzejewski
Copy link
Member

Thank you Ania, nice work! :)

pamil pushed a commit to pamil/Sylius that referenced this pull request May 7, 2019
…sition

[Admin][Payment] Sorting payment metods by position
pamil pushed a commit to pamil/Sylius that referenced this pull request May 7, 2019
…sition

[Admin][Payment] Sorting payment metods by position
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants