Fix pb into date management.

Added phpunit to avoid this in future.
This commit is contained in:
Laurent Destailleur
2015-02-03 11:25:51 +01:00
parent 75f451ccc7
commit 20121c2fbe
6 changed files with 92 additions and 25 deletions

View File

@@ -341,4 +341,24 @@ class DateLibTest extends PHPUnit_Framework_TestCase
return $result;
}
/**
* testDolGetFirstDayWeek
*
* @return int
*/
public function testDolGetFirstDayWeek()
{
global $conf;
$day=3; $month=2; $year=2015;
$conf->global->MAIN_START_WEEK = 1; // start on monday
$prev = dol_get_first_day_week($day, $month, $year);
$this->assertEquals(2, (int) $prev['first_day']); // monday for month 2, year 2014 is the 2
$day=3; $month=2; $year=2015;
$conf->global->MAIN_START_WEEK = 0; // start on sunday
$prev = dol_get_first_day_week($day, $month, $year);
$this->assertEquals(1, (int) $prev['first_day']); // sunday for month 2, year 2015 is the 1st
}
}