Business\Tests\BusinessTest::testClosestBeforeSpecialDaysCalledCorrectly PHP Method

testClosestBeforeSpecialDaysCalledCorrectly() public method

    public function testClosestBeforeSpecialDaysCalledCorrectly()
    {
        $mondayOne = new \DateTime('2015-05-11 10:00');
        $mondayTwo = new \DateTime('2015-05-18 10:00');
        $tuesday = new \DateTime('2015-05-12 10:00');
        $mondayOneCalls = 0;
        $mondayTwoCalls = 0;
        $tuesdayCalls = 0;
        $business = new Business([new SpecialDay(Days::MONDAY, function (\DateTime $date) use($mondayOne, &$mondayOneCalls, $mondayTwo, &$mondayTwoCalls, $tuesday, &$tuesdayCalls) {
            if ($date == $mondayOne) {
                $mondayOneCalls++;
            } elseif ($date == $mondayTwo) {
                $mondayTwoCalls++;
            } elseif ($date == $tuesday) {
                $tuesdayCalls++;
            }
            return [['09:00', '13:00'], ['14:00', '17:00']];
        })]);
        $business->closest($mondayOne, BusinessInterface::CLOSEST_LAST);
        $business->closest($mondayTwo, BusinessInterface::CLOSEST_LAST);
        $business->closest($tuesday, BusinessInterface::CLOSEST_LAST);
        $this->assertEquals(1, $mondayOneCalls);
        $this->assertEquals(1, $mondayTwoCalls);
        $this->assertEquals(0, $tuesdayCalls);
    }