Skip to content

Commit

Permalink
Fixes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Laviale committed Apr 13, 2014
1 parent 0aa0297 commit 10d1655
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/datetime.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class DateTime extends \DateTime
*/
static public function from($source, $timezone=null)
{
if ($source instanceof self)
if ($source instanceof static)
{
return clone $source;
}
Expand Down
19 changes: 19 additions & 0 deletions tests/DateTimeTest.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Tests\ICanBoogie\Time;

use ICanBoogie\DateTime;
use ICanBoogie\DateTimeTest\MyDateTime;

class DateTimeTest extends \PHPUnit_Framework_TestCase
{
Expand Down Expand Up @@ -81,6 +82,17 @@ public function test_from()
$this->assertEquals('2001-01-01 01:01:01', $d->as_db);
}

public function test_from_instance()
{
$d = new \DateTime;
$this->assertInstanceOf('ICanBoogie\DateTime', DateTime::from($d));
$this->assertInstanceOf('ICanBoogie\DateTimeTest\MyDateTime', MyDateTime::from($d));

$d = new DateTime;
$this->assertInstanceOf('ICanBoogie\DateTime', DateTime::from($d));
$this->assertInstanceOf('ICanBoogie\DateTimeTest\MyDateTime', MyDateTime::from($d));
}

public function test_change()
{
$d = new DateTime('2001-01-01 01:01:01');
Expand Down Expand Up @@ -1195,4 +1207,11 @@ public function test_set_as_time()
$d = DateTime::now();
$d->as_time = true;
}
}

namespace ICanBoogie\DateTimeTest;

class MyDateTime extends \ICanBoogie\DateTime
{

}

0 comments on commit 10d1655

Please sign in to comment.