| 1 | <?php |
||
| 6 | class RedirectionTest extends \PHPUnit_Framework_TestCase |
||
| 7 | { |
||
| 8 | /** |
||
| 9 | * @var Redirection |
||
| 10 | */ |
||
| 11 | private $redirection; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @var DateTime |
||
| 15 | */ |
||
| 16 | private $date; |
||
| 17 | |||
| 18 | protected function setUp() |
||
| 19 | { |
||
| 20 | $this->date = new DateTime('2014-05-30'); |
||
| 21 | $this->redirection = new Redirection(1, $this->date, 'http://example.org'); |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @test |
||
| 26 | */ |
||
| 27 | public function constructShouldConfigureTheAttributes() |
||
| 28 | { |
||
| 29 | $this->assertAttributeEquals(1, 'code', $this->redirection); |
||
| 30 | $this->assertAttributeSame($this->date, 'date', $this->redirection); |
||
| 31 | $this->assertAttributeEquals('http://example.org', 'uri', $this->redirection); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @test |
||
| 36 | * @depends constructShouldConfigureTheAttributes |
||
| 37 | */ |
||
| 38 | public function getCodeShouldReturnTheConfiguredCode() |
||
| 39 | { |
||
| 40 | $this->assertEquals(1, $this->redirection->getCode()); |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @test |
||
| 45 | * @depends constructShouldConfigureTheAttributes |
||
| 46 | */ |
||
| 47 | public function getDateShouldReturnTheConfiredDate() |
||
| 48 | { |
||
| 49 | $this->assertSame($this->date, $this->redirection->getDate()); |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @test |
||
| 54 | * @depends constructShouldConfigureTheAttributes |
||
| 55 | */ |
||
| 56 | public function getRedirectionUrlShouldReturnTheUriWithCodeAsQueryString() |
||
| 57 | { |
||
| 58 | $this->assertSame('http://example.org?code=1', $this->redirection->getRedirectionUrl()); |
||
| 59 | } |
||
| 60 | } |
||
| 61 |