MatchDaysTest.php 1.75 KB
<?php

namespace FootyRoom\Tests\Unit\Match;

use FootyRoom\Core\Match\MatchDays;
use FootyRoom\Tests\TestCase;
use MongoDB\BSON\UTCDateTime;

class MatchDaysTest extends TestCase
{
    /**
     * @covers \MatchDays::getDays
     */
    public function testGetDays()
    {
        $matchTimes = [
            new UTCDateTime(strtotime('2014/06/12T00:00:00') * 1000),
            new UTCDateTime(strtotime('2014/07/12T00:00:00') * 1000),
            new UTCDateTime(strtotime('2014/06/13T00:00:00') * 1000),
            new UTCDateTime(strtotime('2014/07/08T00:00:00') * 1000),
            new UTCDateTime(strtotime('2014/07/13T00:00:00') * 1000),
            new UTCDateTime(strtotime('2014/06/13T00:00:00') * 1000),
            new UTCDateTime(strtotime('2014/06/13T00:00:00') * 1000),
            new UTCDateTime(strtotime('2014/06/29T00:00:00') * 1000),
            new UTCDateTime(strtotime('2014/07/12T00:00:00') * 1000),
            new UTCDateTime(strtotime('2014/07/12T00:00:00') * 1000),
            new UTCDateTime(strtotime('2014/07/12T00:00:00') * 1000),
        ];

        $expectedDays = [
            'days' => [
                '2014/06/12',
                '2014/06/13',
                '2014/06/29',
                '2014/07/08',
                '2014/07/12',
                '2014/07/13',
            ],
            'currentDay' => '2014/07/13',
        ];

        $days = MatchDays::getDays($matchTimes);

        sort($days['days']);

        $this->assertEquals($expectedDays, $days, 'Days retrieved are not as expected.');

        $days = MatchDays::getDays([]);

        $this->assertEquals([
            'days' => [],
            'currentDay' => date('Y/m/d', time()),
        ], $days, 'When no matches times are given days are not handled correctly.');
    }
}