Skip to content

Commit

Permalink
Fix API docs and make tests smaller/simpler.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Feb 3, 2016
1 parent 6a36f60 commit 0b33513
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Database/Type/DateType.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function marshal($value)
*
* @param string $value The value to convert.
* @param \Cake\Database\Driver $driver The driver instance to convert with.
* @return \Carbon\Carbon
* @return \Cake\I18n\Date|\DateTime
*/
public function toPHP($value, Driver $driver)
{
Expand Down
14 changes: 11 additions & 3 deletions tests/TestCase/Database/Type/DateTimeTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,19 @@ public function setUp()
*
* @return void
*/
public function testToPHP()
public function testToPHPEmpty()
{
$this->assertNull($this->type->toPHP(null, $this->driver));
$this->assertNull($this->type->toPHP('0000-00-00 00:00:00', $this->driver));
}

/**
* Test toPHP
*
* @return void
*/
public function testToPHPString()
{
$result = $this->type->toPHP('2001-01-04 12:13:14', $this->driver);
$this->assertInstanceOf('Cake\I18n\Time', $result);
$this->assertEquals('2001', $result->format('Y'));
Expand Down Expand Up @@ -260,10 +268,10 @@ public function testToImmutableAndToMutable()
{
$this->type->useImmutable();
$this->assertInstanceOf('DateTimeImmutable', $this->type->marshal('2015-11-01 11:23:00'));
$this->assertInstanceOf('DateTimeImmutable', $this->type->toPhp('2015-11-01 11:23:00', $this->driver));
$this->assertInstanceOf('DateTimeImmutable', $this->type->toPHP('2015-11-01 11:23:00', $this->driver));

$this->type->useMutable();
$this->assertInstanceOf('DateTime', $this->type->marshal('2015-11-01 11:23:00'));
$this->assertInstanceOf('DateTime', $this->type->toPhp('2015-11-01 11:23:00', $this->driver));
$this->assertInstanceOf('DateTime', $this->type->toPHP('2015-11-01 11:23:00', $this->driver));
}
}

0 comments on commit 0b33513

Please sign in to comment.