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

@@ -888,4 +888,32 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
return true;
}
/**
* testDolGetDate
*
* @return boolean
*/
public function testDolGetDate()
{
global $conf;
$conf->global->MAIN_START_WEEK = 0;
$tmp=dol_getdate(1); // 1/1/1970 and 1 second = thirday
$this->assertEquals(4, $tmp['wday']);
$tmp=dol_getdate(24*60*60+1); // 2/1/1970 and 1 second = friday
$this->assertEquals(5, $tmp['wday']);
$conf->global->MAIN_START_WEEK = 1;
$tmp=dol_getdate(1); // 1/1/1970 and 1 second = thirday
$this->assertEquals(4, $tmp['wday']);
$tmp=dol_getdate(24*60*60+1); // 2/1/1970 and 1 second = friday
$this->assertEquals(5, $tmp['wday']);
return true;
}
}