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

[RFC] Address book #229

Merged
merged 34 commits into from
Aug 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9f50150
[Address-book] Implement create address-book
Oct 25, 2017
3892cac
[Address-book] Removed unused valdiation messagess
Oct 25, 2017
2481ea6
[Address-book] Changed province name to provinceCode
Oct 25, 2017
d16ed25
[Address-book] Add default address field to show action, and remove a…
Oct 26, 2017
b8a6dca
Removed mistake
Oct 26, 2017
e6efb47
[Address-book] Implement default address feature
jseparovic1 Oct 27, 2017
4f1a7d8
[Address-book] Apply coding standard fixes
jseparovic1 Oct 27, 2017
8613bee
[Address-book] Add final keyword to classes
jseparovic1 Oct 27, 2017
a158958
[Address-book] Apply scrutinizer fixes and updated existing test
jseparovic1 Oct 27, 2017
c8849d5
[Address-book] implemented address update and add tests
jseparovic1 Oct 30, 2017
0472e04
[Address-book] Refactored create address, now using address model ins…
jseparovic1 Oct 30, 2017
31f67e3
[Address-book] Apply ecs fix
jseparovic1 Oct 30, 2017
e5276a2
[Address-book] Fix tests
jseparovic1 Oct 30, 2017
79718f8
[Address-book] Move getting current user from request to handler
jseparovic1 Oct 30, 2017
e3b109a
[Address-book] Remove address request test
jseparovic1 Oct 30, 2017
13930a7
[Address-book] Remove show address request test
jseparovic1 Oct 30, 2017
1f21f68
[Address-book] Move user from SetDefaultAddressRequest to correspondi…
jseparovic1 Oct 30, 2017
8f1aa83
[Address-book] apply ecs fixes
jseparovic1 Oct 30, 2017
45a1202
[Address-book] add phpspec
jseparovic1 Nov 2, 2017
2e57ef3
[Address-book] add validation labels, and change address constructor …
jseparovic1 Nov 2, 2017
528c8ad
[Address-book] returned old path for sql
jseparovic1 Nov 2, 2017
2df80ea
[Address-book] add final to all phpunit tests
jseparovic1 Nov 3, 2017
b95e3f7
[Address-book] add final classes and empty lines at the end of the file
jseparovic1 Nov 3, 2017
8bdec06
[Address-book] Checking province refactored
jseparovic1 Nov 3, 2017
151b5df
[Address-book] add return type
jseparovic1 Nov 3, 2017
e8d2294
[Address-book] changed expected address model parameters types
jseparovic1 Nov 3, 2017
1a0fc9b
[Address-book] Refactor create address
jseparovic1 Nov 6, 2017
9581b43
[Address-book] Refactor
jseparovic1 Nov 6, 2017
338b28d
[Address-book] Removed test db hack
jseparovic1 Nov 6, 2017
db1390c
[Address-book] Changed error messages
jseparovic1 Nov 6, 2017
f8bbfc0
[Address-book] add return type
jseparovic1 Nov 10, 2017
7772868
change 'address_id to string'
jseparovic1 Feb 26, 2018
f7ab829
Fixed phpspec
jseparovic1 Feb 27, 2018
b9efa6c
Apply small fixes and add better validation
jseparovic1 Aug 9, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions spec/Command/CreateAddressSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace spec\Sylius\ShopApiPlugin\Command;

use PhpSpec\ObjectBehavior;
use Sylius\ShopApiPlugin\Model\Address;

final class CreateAddressSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith(Address::createFromArray([
'firstName' => 'Sherlock',
'lastName' => 'Holmes',
'city' => 'London',
'street' => 'Baker Street 221b',
'countryCode' => 'GB',
'postcode' => 'NWB',
'provinceName' => 'Greater London',
'provinceCode' => 'GB-GL',
'phoneNumber' => '0912538092',
'company' => 'Sherlock ltd.',
]), 'user@email.com');
}

function it_has_address()
{
$this->address()->shouldBeAnInstanceOf(Address::class);
}

function it_has_user_email()
{
$this->userEmail()->shouldReturn('user@email.com');
}
}
25 changes: 25 additions & 0 deletions spec/Command/RemoveAddressSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace spec\Sylius\ShopApiPlugin\Command;

use PhpSpec\ObjectBehavior;

final class RemoveAddressSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith('ADDRESS_ID', 'user@email.com');
}

function it_has_id()
{
$this->id()->shouldReturn('ADDRESS_ID');
}

function it_has_user_email()
{
$this->userEmail()->shouldReturn('user@email.com');
}
}
25 changes: 25 additions & 0 deletions spec/Command/SetDefaultAddressSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace spec\Sylius\ShopApiPlugin\Command;

use PhpSpec\ObjectBehavior;

final class SetDefaultAddressSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith('ADDRESS_ID', 'user@email.com');
}

function it_has_id()
{
$this->id()->shouldReturn('ADDRESS_ID');
}

function it_has_user_email()
{
$this->userEmail()->shouldReturn('user@email.com');
}
}
89 changes: 89 additions & 0 deletions spec/Command/UpdateAddressSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php

declare(strict_types=1);

namespace spec\Sylius\ShopApiPlugin\Command;

use PhpSpec\ObjectBehavior;
use Sylius\ShopApiPlugin\Command\UpdateAddress;
use Sylius\ShopApiPlugin\Model\Address;

final class UpdateAddressSpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType(UpdateAddress::class);
}

function let()
{
$this->beConstructedWith(Address::createFromArray([
'id' => 'ADDRESS_ID',
'firstName' => 'Sherlock',
'lastName' => 'Holmes',
'city' => 'London',
'street' => 'Baker Street 221b',
'countryCode' => 'GB',
'postcode' => 'NWB',
'provinceName' => 'Greater London',
'provinceCode' => 'GB-GL',
'phoneNumber' => '0912538092',
'company' => 'Sherlock ltd.',
]), 'user@email.com', 'ADDRESS_ID');
}

function it_has_address_id()
{
$this->id()->shouldReturn('ADDRESS_ID');
}

function it_has_first_name()
{
$this->firstName()->shouldReturn('Sherlock');
}

function it_has_last_name()
{
$this->lastName()->shouldReturn('Holmes');
}

function it_has_company()
{
$this->company()->shouldReturn('Sherlock ltd.');
}

function it_has_street()
{
$this->street()->shouldReturn('Baker Street 221b');
}

function it_has_country_code()
{
$this->countryCode()->shouldReturn('GB');
}

function it_has_province_code()
{
$this->provinceCode()->shouldReturn('GB-GL');
}

function it_has_city()
{
$this->city()->shouldReturn('London');
}

function it_has_postcode()
{
$this->postcode()->shouldReturn('NWB');
}

function it_has_phone_number()
{
$this->phoneNumber()->shouldReturn('0912538092');
}

function it_has_user_email()
{
$this->userEmail()->shouldReturn('user@email.com');
}
}
57 changes: 57 additions & 0 deletions spec/Factory/AddressBookViewFactorySpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

declare(strict_types=1);

namespace spec\Sylius\ShopApiPlugin\Factory;

use PhpSpec\ObjectBehavior;
use Sylius\Component\Core\Model\AddressInterface;
use Sylius\Component\Core\Model\CustomerInterface;
use Sylius\ShopApiPlugin\Factory\AddressBookViewFactory;
use Sylius\ShopApiPlugin\View\AddressBookView;

final class AddressBookViewFactorySpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith(AddressBookView::class);
}

function it_is_initializable()
{
$this->shouldHaveType(AddressBookViewFactory::class);
}

function it_creates_address_book_view(AddressInterface $address, CustomerInterface $customer)
{
$address->getId()->willReturn('ADDRESS_ID');
$address->getFirstName()->willReturn('Sherlock');
$address->getLastName()->willReturn('Holmes');
$address->getCountryCode()->willReturn('GB');
$address->getCity()->willReturn('London');
$address->getStreet()->willReturn('Baker Street 221b');
$address->getPostcode()->willReturn('NMW');
$address->getProvinceName()->willReturn('Greater London');
$address->getProvinceCode()->willReturn('GB-GL');
$address->getPhoneNumber()->willReturn('0912538092');
$address->getCompany()->willReturn('Sherlock ltd.');

$customer->getDefaultAddress()->willReturn($address);

$addressBookView = new AddressBookView();
$addressBookView->id = 'ADDRESS_ID';
$addressBookView->firstName = 'Sherlock';
$addressBookView->lastName = 'Holmes';
$addressBookView->countryCode = 'GB';
$addressBookView->city = 'London';
$addressBookView->street = 'Baker Street 221b';
$addressBookView->postcode = 'NMW';
$addressBookView->provinceName = 'Greater London';
$addressBookView->provinceCode = 'GB-GL';
$addressBookView->phoneNumber = '0912538092';
$addressBookView->company = 'Sherlock ltd.';
$addressBookView->default = true;

$this->create($address, $customer)->shouldBeLike($addressBookView);
}
}
Loading