Skip to content

Instantly share code, notes, and snippets.

@ludofleury
Last active December 31, 2015 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ludofleury/7961379 to your computer and use it in GitHub Desktop.
Save ludofleury/7961379 to your computer and use it in GitHub Desktop.
<?php
public function it_is_initializable()
{
$this->beConstructedWith('FR');
$this->shouldHaveType(Country::class);
}
public function its_constructor_requires_a_valid_country_isocode()
{
// Hack due to phpspec current limitation to test the SUT constructor
$this->beConstructedWith('LOL');
$exception = new UnknownCountryException('XX');
$this->shouldThrow($exception)->during('__construct', ['XX']);
}
public function it_provides_the_country_code()
{
$this->beConstructedWith('FR');
$this->getCode()->shouldReturn('FR');
}
public function it_provides_the_country_name_mapped_to_the_isocode()
{
$this->beConstructedWith('FR');
$this->getName()->shouldReturn('France');
}
public function it_compares_like_a_value_object(Country $country)
{
$this->beConstructedWith('FR');
$this->equals($country)->shouldBeTrue();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment