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

[Country] Adding a province to a country manually #6002

Merged
merged 6 commits into from
Sep 22, 2016

Conversation

tuka217
Copy link
Contributor

@tuka217 tuka217 commented Sep 7, 2016

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

@tuka217 tuka217 force-pushed the country-province branch 3 times, most recently from 5089a2a to 1edb2f6 Compare September 7, 2016 09:51
@tuka217 tuka217 force-pushed the country-province branch 5 times, most recently from e1234b1 to 4d367a2 Compare September 12, 2016 09:41
@tuka217 tuka217 changed the title [WIP][Country] Adding a province to a country manually [Country] Adding a province to a country manually Sep 12, 2016
@tuka217 tuka217 force-pushed the country-province branch 8 times, most recently from 3a55532 to ac986e0 Compare September 13, 2016 08:00
/**
* @Then the province in the shipping address should be :provinceName
*/
public function hisProvinceInTheShippingAddressShouldBe($provinceName)
Copy link
Member

Choose a reason for hiding this comment

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

theProvinceInTheShippingAddressShouldBe

Assert::notNull($province,sprintf('Province with code "%s" not found.', $address->getProvinceCode()));

if (null !== $provinceAbbreviation = $province->getAbbreviation()) {

Copy link
Member

Choose a reason for hiding this comment

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

Unneeded blank line, I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shouldn't we always put blank line before return?

Copy link
Contributor

Choose a reason for hiding this comment

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

Add a blank line before return statements, unless the return is alone inside a statement-group (like an if statement);

Btw. we can remove this if and the next return statement by:

return $province->getAbbreviation() ?: $province->getName();

@tuka217 tuka217 force-pushed the country-province branch 4 times, most recently from 4f48377 to c9a8b56 Compare September 14, 2016 09:04
Scenario: Seeing a province manually defined in a order history
When I view the summary of the order "#00000666"
Then I should see "East of England" as province in the shipping address
And I should see "East of England" ad province in the billing address
Copy link
Contributor

Choose a reason for hiding this comment

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

as province

And the store has "DHL" shipping method with "$20.00" fee within "EN" zone
And the store has a product "Angel T-Shirt" priced at "$39.00"
And I am a logged in customer
And I placed an order "#00000666"
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have to be logged in customer, We can use step "And customer "x" placed order ...`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But I want to see my order in the history.

And the store has a zone "English" with code "EN"
And this zone has the "United Kingdom" country member
And the store operates on a channel named "Web"
And that channel allows to shop using the "GBP" currency
Copy link
Contributor

Choose a reason for hiding this comment

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

Not needed.

Given the store ships to "United Kingdom"
And the store has a zone "English" with code "EN"
And this zone has the "United Kingdom" country member
And the store operates on a channel named "Web"
Copy link
Contributor

Choose a reason for hiding this comment

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

Channel should be specified in the first step.

I want to be able to see province in the order history

Background:
Given the store ships to "United Kingdom"
Copy link
Contributor

Choose a reason for hiding this comment

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

the store operates in "United Kingdom"


@ui @javascript
Scenario: Seeing manually defined province on order summary page
Given I had product "PHP T-Shirt" in the cart
Copy link
Contributor

Choose a reason for hiding this comment

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

I added - IMO is more appropriate

{{ address.provinceCode|sylius_province_abbreviation }}<br/>
{{ address|sylius_province_name }}
{% if address|sylius_province_name is not null %}
<br/>
Copy link
Contributor

@michalmarcinkowski michalmarcinkowski Sep 15, 2016

Choose a reason for hiding this comment

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

I think the following will be more readable:

{% if address|sylius_province_name is not null %}
    {{ address|sylius_province_name }}<br/>
{% endif %}

{{ address.provinceCode|sylius_province_abbreviation }}<br/>
{{ address|sylius_province_name }}
{% if address|sylius_province_name is not null %}
<br/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

}

return $provinceCode;
return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

       if (null !== $address->getProvinceName()) {
            return $address->getProvinceName();
        }

        if (null === $address->getProvinceCode()) {
             return null;
        }

        $province = $this->provinceRepository->findOneBy(['code' => $address->getProvinceCode()]);
        Assert::notNull($province,sprintf('Province with code "%s" not found.', $address->getProvinceCode()));

        return $province->getName();

IMO looks more readable, WDYT?

}

return $province;
return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

*
* @return string
* @return string|null
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we return null or empty string, WDYT?

Copy link
Contributor Author

@tuka217 tuka217 Sep 15, 2016

Choose a reason for hiding this comment

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

Not big difference, because in twig we do not render this field if it is null. But using string only will be more coherent.

@tuka217 tuka217 force-pushed the country-province branch 4 times, most recently from 1644fa2 to c6f7c48 Compare September 16, 2016 10:54
I want to be able to see specific customer's page with provinces in the addresses

Background:
Given I am logged in as an administrator
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we have only one scenario here the background in not necessary.

return $this->hasElement('login_button');
});
}

private function waitForLoginAction()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be replaced with waitForElement

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cannot. It waits until an element disappear.

@@ -1,4 +1,4 @@
<address>
\<address>
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be reverted.

*
* @return string
* @return string|null
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 return null anymore.

*
* @return string
* @return string|null
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 return null anymore.

@michalmarcinkowski
Copy link
Contributor

@tuka217 please rebase. Last comments can be applied in a separate PR.

@tuka217 tuka217 force-pushed the country-province branch 2 times, most recently from be195ed to a8f2e19 Compare September 22, 2016 08:37
@michalmarcinkowski
Copy link
Contributor

Nice work Ania! 👍

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

6 participants