ludofleury
12/14/2013 - 4:28 PM

CountrySpec.php

<?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();
    }