Fix the détection of bad publication date. fix #245

The previous one was based on the fact that the PHP version used was 64bits and so the unix timestamp could go way back.

With a 32bits PHP that's not the case.  Check the notes in http://php.net/manual/en/function.strtotime.php for more information.
This commit is contained in:
Sébastien Lucas 2016-02-13 06:25:20 +01:00
parent df592eb668
commit 0a0007a096
3 changed files with 39 additions and 6 deletions

View file

@ -173,6 +173,27 @@ class BookTest extends PHPUnit_Framework_TestCase
$this->assertCount (15, $entryArray);
}
/**
* @dataProvider providerPublicationDate
*/
public function testGetPubDate ($pubdate, $expectedYear)
{
$book = Book::getBookById(2);
$book->pubdate = $pubdate;
$this->assertEquals($expectedYear, $book->getPubDate());
}
public function providerPublicationDate() {
return array(
array('2010-10-05 22:00:00+00:00', '2010'),
array('1982-11-15 13:05:29.908657+00:00', '1982'),
array('1562-10-05 00:00:00+00:00', '1562'),
array('0100-12-31 23:00:00+00:00', ''),
array('', ''),
array(NULL, '')
);
}
public function testGetBookById ()
{
// also check most of book's class methods