Skip to content

Commit

Permalink
added couple of holidays which will be in scope for Romania in 2017 +…
Browse files Browse the repository at this point in the history
… adjusted test to include these
  • Loading branch information
danielgp committed Nov 28, 2016
1 parent b8e6758 commit 526eb1a
Show file tree
Hide file tree
Showing 8 changed files with 307 additions and 274 deletions.
29 changes: 16 additions & 13 deletions source/Romanian.php
Expand Up @@ -98,20 +98,23 @@ protected function setHolidays(\DateTime $lngDate, $inclCatholicEaster = false,
*/
private function setHolidaysFixed(\DateTime $lngDate)
{
$givenYear = $lngDate->format('Y');
$daying = [
mktime(0, 0, 0, 1, 1, $givenYear), // Happy New Year
mktime(0, 0, 0, 1, 2, $givenYear), // recovering from New Year party
mktime(0, 0, 0, 5, 1, $givenYear), // May 1st
mktime(0, 0, 0, 12, 1, $givenYear), // Romanian National Day
mktime(0, 0, 0, 12, 25, $givenYear), // Christmas Day
mktime(0, 0, 0, 12, 26, $givenYear), // Christmas 2nd Day
$daying = [
mktime(0, 0, 0, 1, 1, $lngDate->format('Y')), // Happy New Year
mktime(0, 0, 0, 1, 2, $lngDate->format('Y')), // recovering from New Year party
mktime(0, 0, 0, 5, 1, $lngDate->format('Y')), // May 1st
mktime(0, 0, 0, 12, 1, $lngDate->format('Y')), // Romanian National Day
mktime(0, 0, 0, 12, 25, $lngDate->format('Y')), // Christmas Day
mktime(0, 0, 0, 12, 26, $lngDate->format('Y')), // Christmas 2nd Day
];
if ($givenYear >= 2009) {
$daying[] = mktime(0, 0, 0, 8, 15, $givenYear); // St. Marry
}
if ($givenYear >= 2012) {
$daying[] = mktime(0, 0, 0, 11, 30, $givenYear); // St. Andrew
if ($lngDate->format('Y') >= 2009) {
$daying[] = mktime(0, 0, 0, 8, 15, $lngDate->format('Y')); // St. Marry
if ($lngDate->format('Y') >= 2012) {
$daying[] = mktime(0, 0, 0, 11, 30, $lngDate->format('Y')); // St. Andrew
if ($lngDate->format('Y') >= 2017) {
$daying[] = mktime(0, 0, 0, 1, 24, $lngDate->format('Y')); // Union Day
$daying[] = mktime(0, 0, 0, 6, 1, $lngDate->format('Y')); // Child's Day
}
}
}
sort($daying);
return $daying;
Expand Down
65 changes: 44 additions & 21 deletions tests/php-unit/RomanianTest.php
Expand Up @@ -30,105 +30,128 @@ class RomanianTest extends \PHPUnit_Framework_TestCase

use \danielgp\bank_holidays\Romanian;

public function testHolidaysFixedButWorkingIncluded() {
// Arrange
$a = $this->setHolidays(new \DateTime('2016-04-01'), true, true);
// Assert
$this->assertContains(strtotime('2016-02-19'), $a);
}

public function testHolidaysEaster2015CatholicEasterFirstDay() {
public function testHolidaysEaster2015CatholicEasterFirstDay()
{
// Arrange
$a = $this->setHolidays(new \DateTime('2015-04-01'), true);
// Assert
$this->assertContains(strtotime('2015-04-05'), $a);
}

public function testHolidaysEaster2015CatholicEasterSecondDay() {
public function testHolidaysEaster2015CatholicEasterSecondDay()
{
// Arrange
$a = $this->setHolidays(new \DateTime('2015-04-01'), true);
// Assert
$this->assertContains(strtotime('2015-04-06'), $a);
}

public function testHolidaysEaster2015FirstDayOfYear() {
public function testHolidaysEaster2015FirstDayOfYear()
{
// Arrange
$a = $this->setHolidays(new \DateTime('2015-12-01'));
// Assert
$this->assertContains(strtotime('2015-01-01'), $a);
}

public function testHolidaysEaster2015LastDayOfYear() {
public function testHolidaysEaster2015LastDayOfYear()
{
// Arrange
$a = $this->setHolidays(new \DateTime('2015-12-01'));
// Assert
$this->assertNotContains(strtotime('2015-12-31'), $a);
}

public function testHolidaysEaster2015OrthodoxEasterFirstDay() {
public function testHolidaysEaster2015OrthodoxEasterFirstDay()
{
// Arrange
$a = $this->setHolidays(new \DateTime('2015-04-01'), true);
// Assert
$this->assertContains(strtotime('2015-04-12'), $a);
}

public function testHolidaysEaster2015OrthodoxEasterSecondDay() {
public function testHolidaysEaster2015OrthodoxEasterSecondDay()
{
// Arrange
$a = $this->setHolidays(new \DateTime('2015-04-01'), true);
// Assert
$this->assertContains(strtotime('2015-04-13'), $a);
}

public function testHolidaysInMonthForMonthWithCatholicEaster() {
public function testHolidaysFixedButWorkingIncluded()
{
// Arrange
$a = $this->setHolidays(new \DateTime('2016-04-01'), true, true);
// Assert
$this->assertContains(strtotime('2016-02-19'), $a);
}

public function testHolidaysFixedNewIn2017()
{
// Arrange
$a = $this->setHolidays(new \DateTime('2017-01-24'), true, true);
// Assert
$this->assertContains(strtotime('2017-01-24'), $a);
}

public function testHolidaysInMonthForMonthWithCatholicEaster()
{
// Arrange
$a = $this->setHolidaysInMonth(new \DateTime('2015-04-01'), true);
// Assert
$this->assertEquals(4, $a);
}

public function testHolidaysInMonthForMonthWithoutCatholicEaster() {
public function testHolidaysInMonthForMonthWithoutCatholicEaster()
{
// Arrange
$a = $this->setHolidaysInMonth(new \DateTime('2015-04-01'), false);
// Assert
$this->assertEquals(2, $a);
}

public function testWorkingDaysInMonthForMonthOf19Days() {
public function testWorkingDaysInMonthForMonthOf19Days()
{
// Arrange
$a = $this->setWorkingDaysInMonth(new \DateTime('2001-12-01'));
// Assert
$this->assertEquals(19, $a);
}

public function testWorkingDaysInMonthForMonthOf20Days() {
public function testWorkingDaysInMonthForMonthOf20Days()
{
// Arrange
$a = $this->setWorkingDaysInMonth(new \DateTime('2001-02-01'));
// Assert
$this->assertEquals(20, $a);
}

public function testWorkingDaysInMonthForMonthOf20DaysWithCatholicEaster() {
public function testWorkingDaysInMonthForMonthOf20DaysWithCatholicEaster()
{
// Arrange
$a = $this->setWorkingDaysInMonth(new \DateTime('2015-04-01'), true);
// Assert
$this->assertEquals(20, $a);
}

public function testWorkingDaysInMonthForMonthOf21Days() {
public function testWorkingDaysInMonthForMonthOf21Days()
{
// Arrange
$a = $this->setWorkingDaysInMonth(new \DateTime('2006-01-01'));
// Assert
$this->assertEquals(21, $a);
}

public function testWorkingDaysInMonthForMonthOf22Days() {
public function testWorkingDaysInMonthForMonthOf22Days()
{
// Arrange
$a = $this->setWorkingDaysInMonth(new \DateTime('2016-09-01'), false);
// Assert
$this->assertEquals(22, $a);
}

public function testWorkingDaysInMonthForMonthOf23Days() {
public function testWorkingDaysInMonthForMonthOf23Days()
{
// Arrange
$a = $this->setWorkingDaysInMonth(new \DateTime('2015-07-01'));
// Assert
Expand Down

0 comments on commit 526eb1a

Please sign in to comment.