Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[API][AddressBook] Setting default address#11961

Merged
GSadee merged 1 commit into
Sylius:masterfrom
AdamKasp:api-default-address-in-address-book
Oct 26, 2020
Merged

[API][AddressBook] Setting default address#11961
GSadee merged 1 commit into
Sylius:masterfrom
AdamKasp:api-default-address-in-address-book

Conversation

@AdamKasp
Copy link
Copy Markdown
Contributor

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
License MIT

@AdamKasp AdamKasp requested a review from a team as a code owner October 26, 2020 09:31
{
$userShowResponse = $this->customerClient->show((string) $this->sharedStorage->get('user')->getCustomer()->getId());
Assert::null($this->responseChecker->getValue($userShowResponse, 'defaultAddress'), 'Default address should be null'
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we move this ); to one line 😄 As we can see it even cries because of it

@GSadee GSadee added the API APIs related issues and PRs. label Oct 26, 2020
$this->addressClient->index();

Assert::same(count($this->responseChecker->getCollection($this->client->getLastResponse())), $count);
Assert::same(count($this->responseChecker->getCollection($this->addressClient->getLastResponse())), $count);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Assert::same(count($this->responseChecker->getCollection($this->addressClient->getLastResponse())), $count);
Assert::same(count($this->responseChecker->getCollection($this->addressClient->index())), $count);

public function iShouldHaveAddresses(int $count = 1): void
{
$this->client->index();
$this->addressClient->index();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
$this->addressClient->index();

Comment on lines +183 to +191
$addressIri = $this->getAddressIriFromAddressBookByFullName($fullName);
$addressBook = $this->responseChecker->getCollection($this->addressClient->getLastResponse());

Assert::notEmpty(
array_filter($addressBook, function($address) use ($addressIri) {
return $address['@id'] === $addressIri;
}),
sprintf('There is no Address assigned to %s', $fullName)
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if this method makes sense, because in getAddressIriFromAddressBookByFullName method you are getting an address from the address book and then you are checking if this address is in the same address book 😃

Maybe you could use an address transformer to get an address by full name and then check if this address is in address book? Or even simple, just check if the value returned from getAddressIriFromAddressBookByFullName method is not null.

public function thereShouldBeNoAddresses(): void
{
$this->client->index();
$this->addressClient->index();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
$this->addressClient->index();

$this->addressClient->index();

Assert::same(count($this->responseChecker->getCollection($this->client->getLastResponse())), 0);
Assert::same(count($this->responseChecker->getCollection($this->addressClient->getLastResponse())), 0);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Assert::same(count($this->responseChecker->getCollection($this->addressClient->getLastResponse())), 0);
Assert::same(count($this->responseChecker->getCollection($this->addressClient->index())), 0);

{
Assert::notNull($fullName);
$fullNameArray = explode(' ',$fullName);
[$firstName, $lastName] = explode(' ',$fullName);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
[$firstName, $lastName] = explode(' ',$fullName);
[$firstName, $lastName] = explode(' ', $fullName);

private function getAddressIriFromAddressBookByFullName(string $fullName): ?string
{
Assert::notNull($fullName);
[$firstName, $lastName] = explode(' ',$fullName);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
[$firstName, $lastName] = explode(' ',$fullName);
[$firstName, $lastName] = explode(' ', $fullName);

@GSadee GSadee merged commit e38fbd6 into Sylius:master Oct 26, 2020
@GSadee
Copy link
Copy Markdown
Member

GSadee commented Oct 26, 2020

Thank you, Adam! 🥇

@AdamKasp AdamKasp deleted the api-default-address-in-address-book branch July 19, 2021 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API APIs related issues and PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants