Skip to content

Commit

Permalink
Merge branch '1.3' into 1.4
Browse files Browse the repository at this point in the history
* 1.3:
  Add some missing void returns
  add one last missing behaviour test
  add some other missing behaviours tests on customer spec
  [Phpspec] Add missing specs on customer core model
  • Loading branch information
lchrusciel committed Mar 21, 2019
2 parents 2072abb + 36e5264 commit 405dd62
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/Sylius/Component/Core/spec/Model/CustomerSpec.php
Expand Up @@ -17,6 +17,8 @@
use PhpSpec\ObjectBehavior;
use Sylius\Component\Core\Model\AddressInterface;
use Sylius\Component\Core\Model\CustomerInterface;
use Sylius\Component\Core\Model\ShopUserInterface;
use Sylius\Component\User\Model\UserInterface;

final class CustomerSpec extends ObjectBehavior
{
Expand Down Expand Up @@ -64,4 +66,39 @@ function it_adds_address_when_billing_address_is_set(AddressInterface $address):
$this->setDefaultAddress($address);
$this->hasAddress($address)->shouldReturn(true);
}

function it_has_no_user_by_default(): void
{
$this->getUser()->shouldReturn(null);
}

function its_user_is_mutable(ShopUserInterface $user): void
{
$user->setCustomer($this)->shouldBeCalled();

$this->setUser($user);
$this->getUser()->shouldReturn($user);
}

function it_throws_an_invalid_argument_exception_when_user_is_not_a_shop_user_type(UserInterface $user): void
{
$this->shouldThrow(\InvalidArgumentException::class)->during('setUser', [$user]);
}

function it_resets_customer_of_previous_user(ShopUserInterface $previousUser, ShopUserInterface $user): void
{
$this->setUser($previousUser);

$previousUser->setCustomer(null)->shouldBeCalled();

$this->setUser($user);
}

function it_does_not_replace_user_if_it_is_already_set(ShopUserInterface $user): void
{
$user->setCustomer($this)->shouldBeCalledOnce();

$this->setUser($user);
$this->setUser($user);
}
}

0 comments on commit 405dd62

Please sign in to comment.