Skip to content

Commit

Permalink
Date range fix
Browse files Browse the repository at this point in the history
  • Loading branch information
misantron committed Mar 23, 2016
1 parent 81a7eee commit a3ce229
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
4 changes: 0 additions & 4 deletions src/Object/DateRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ public function __construct($dateBegin, $dateEnd)
} else {
throw new \InvalidArgumentException('Range end date format is invalid.');
}

if ($this->rangeBegin->format('Y-m-d') === $this->rangeEnd->format('Y-m-d')) {
throw new \InvalidArgumentException('Range begin and end dates are equal.');
}
}

/**
Expand Down
15 changes: 7 additions & 8 deletions tests/Object/DateRangeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ public function testConstructor()
$this->assertInstanceOf('\\InvalidArgumentException', $e);
$this->assertEquals('Range begin date format is invalid.', $e->getMessage());
}

try {
new DateRange('2016-02-01', '2016-02-01');
$this->fail('Expected exception not thrown');
} catch(\InvalidArgumentException $e) {
$this->assertInstanceOf('\\InvalidArgumentException', $e);
$this->assertEquals('Range begin and end dates are equal.', $e->getMessage());
}
}

public function testGetRangeBegin()
Expand Down Expand Up @@ -87,6 +79,13 @@ public function testGetRange()
$this->assertEquals('2016-03-11', $actual[0]);
$this->assertEquals('2016-03-16', $actual[5]);
$this->assertCount(6, $actual);

$range = new DateRange('2016-03-12', '2016-03-12');
$actual = $range->getRange('d-m-Y');

$this->assertInternalType('array', $actual);
$this->assertEquals('12-03-2016', $actual[0]);
$this->assertCount(1, $actual);
}

public function testToArray()
Expand Down

0 comments on commit a3ce229

Please sign in to comment.