Skip to content

Commit

Permalink
Fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Feb 24, 2018
1 parent b577ed3 commit 029cd96
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/Database/Type/DateTimeType.php
Expand Up @@ -146,7 +146,8 @@ public function toPHP($value, Driver $driver)
return null;
}

$instance = (clone $this->_datetimeInstance)->modify($value);
$instance = clone $this->_datetimeInstance;
$instance = $instance->modify($value);

if ($this->setToDateStart) {
$instance = $instance->setTime(0, 0, 0);
Expand All @@ -172,7 +173,8 @@ public function manyToPHP(array $values, array $fields, Driver $driver)
continue;
}

$instance = (clone $this->_datetimeInstance)->modify($values[$field]);
$instance = clone $this->_datetimeInstance;
$instance = $instance->modify($value);

if ($this->setToDateStart) {
$instance = $instance->setTime(0, 0, 0);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Database/QueryTest.php
Expand Up @@ -4475,7 +4475,7 @@ public function testCastResults()
'true' => 'boolean'
]);
$results = $query
->select(['one' => '1', 'two' => '2', 'true' => '1', 'three' => '3.0'])
->select(['one' => '1 * 1', 'two' => '1 * 2', 'true' => '1', 'three' => '1 + 2'])
->setSelectTypeMap($typeMap)
->execute()
->fetchAll('assoc');
Expand Down
2 changes: 0 additions & 2 deletions tests/TestCase/Database/Type/DateTimeTypeTest.php
Expand Up @@ -104,12 +104,10 @@ public function testManyToPHP()
$values = [
'a' => null,
'b' => '2001-01-04 12:13:14',
'c' => '2001-01-04 12:13:14.12345',
];
$expected = [
'a' => null,
'b' => new Time('2001-01-04 12:13:14'),
'c' => new Time('2001-01-04 12:13:14.12345'),
];
$this->assertEquals(
$expected,
Expand Down
2 changes: 0 additions & 2 deletions tests/TestCase/Database/Type/TimeTypeTest.php
Expand Up @@ -95,12 +95,10 @@ public function testManyToPHP()
$values = [
'a' => null,
'b' => '01:30:13',
'c' => '12:13:14.12345',
];
$expected = [
'a' => null,
'b' => new Time('01:30:13'),
'c' => new Time('12:13:14.12345'),
];
$this->assertEquals(
$expected,
Expand Down

0 comments on commit 029cd96

Please sign in to comment.