Skip to content

Commit

Permalink
Fixed Remaining failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Apr 15, 2014
1 parent 28b15a9 commit 9a09a9d
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 50 deletions.
Expand Up @@ -16,6 +16,7 @@
*/
namespace Cake\Test\TestCase\Controller\Component\Auth;

use Carbon\Carbon;
use Cake\Controller\Component\Auth\BasicAuthenticate;
use Cake\Error;
use Cake\Network\Request;
Expand Down Expand Up @@ -172,8 +173,8 @@ public function testAuthenticateSuccess() {
$expected = array(
'id' => 1,
'username' => 'mariano',
'created' => new \DateTime('2007-03-17 01:16:23'),
'updated' => new \DateTime('2007-03-17 01:18:31')
'created' => new Carbon('2007-03-17 01:16:23'),
'updated' => new Carbon('2007-03-17 01:18:31')
);
$this->assertEquals($expected, $result);
}
Expand Down Expand Up @@ -229,8 +230,8 @@ public function testAuthenticateWithBlowfish() {
$expected = array(
'id' => 1,
'username' => 'mariano',
'created' => new \DateTime('2007-03-17 01:16:23'),
'updated' => new \DateTime('2007-03-17 01:18:31')
'created' => new Carbon('2007-03-17 01:16:23'),
'updated' => new Carbon('2007-03-17 01:18:31')
);
$this->assertEquals($expected, $result);
}
Expand Down
Expand Up @@ -16,6 +16,7 @@
*/
namespace Cake\Test\TestCase\Controller\Component\Auth;

use Carbon\Carbon;
use Cake\Controller\Component\Auth\DigestAuthenticate;
use Cake\Error;
use Cake\Network\Request;
Expand Down Expand Up @@ -168,8 +169,8 @@ public function testAuthenticateSuccess() {
$expected = array(
'id' => 1,
'username' => 'mariano',
'created' => new \DateTime('2007-03-17 01:16:23'),
'updated' => new \DateTime('2007-03-17 01:18:31')
'created' => new Carbon('2007-03-17 01:16:23'),
'updated' => new Carbon('2007-03-17 01:18:31')
);
$this->assertEquals($expected, $result);
}
Expand Down
Expand Up @@ -16,6 +16,7 @@
*/
namespace Cake\Test\TestCase\Controller\Component\Auth;

use Carbon\Carbon;
use Cake\Cache\Cache;
use Cake\Controller\Component\Auth\FormAuthenticate;
use Cake\Core\App;
Expand Down Expand Up @@ -199,8 +200,8 @@ public function testAuthenticateSuccess() {
$expected = [
'id' => 1,
'username' => 'mariano',
'created' => new \DateTime('2007-03-17 01:16:23'),
'updated' => new \DateTime('2007-03-17 01:18:31')
'created' => new Carbon('2007-03-17 01:16:23'),
'updated' => new Carbon('2007-03-17 01:18:31')
];
$this->assertEquals($expected, $result);
}
Expand Down Expand Up @@ -248,8 +249,8 @@ public function testPluginModel() {
$expected = [
'id' => 1,
'username' => 'gwoo',
'created' => new \DateTime('2007-03-17 01:16:23'),
'updated' => new \DateTime('2007-03-17 01:18:31')
'created' => new Carbon('2007-03-17 01:16:23'),
'updated' => new Carbon('2007-03-17 01:18:31')
];
$this->assertEquals($expected, $result);
Plugin::unload();
Expand Down Expand Up @@ -287,8 +288,8 @@ public function testPasswordHasherSettings() {
$expected = [
'id' => 1,
'username' => 'mariano',
'created' => new \DateTime('2007-03-17 01:16:23'),
'updated' => new \DateTime('2007-03-17 01:18:31')
'created' => new Carbon('2007-03-17 01:16:23'),
'updated' => new Carbon('2007-03-17 01:18:31')
];
$this->assertEquals($expected, $result);

Expand Down
9 changes: 5 additions & 4 deletions tests/TestCase/ORM/MarshallerTest.php
Expand Up @@ -14,6 +14,7 @@
*/
namespace Cake\Test\TestCase\ORM;

use Carbon\Carbon;
use Cake\ORM\Entity;
use Cake\ORM\Marshaller;
use Cake\ORM\Table;
Expand Down Expand Up @@ -130,7 +131,7 @@ public function testOneWithDatetimeField() {
$marshall = new Marshaller($this->comments);
$result = $marshall->one($data, []);

$this->assertEquals(new \DateTime('2014-02-14 00:00:00'), $result->created);
$this->assertEquals(new Carbon('2014-02-14 00:00:00'), $result->created);

$data['created'] = [
'year' => '2014',
Expand All @@ -141,7 +142,7 @@ public function testOneWithDatetimeField() {
'meridian' => 'pm'
];
$result = $marshall->one($data, []);
$this->assertEquals(new \DateTime('2014-02-14 21:25:00'), $result->created);
$this->assertEquals(new Carbon('2014-02-14 21:25:00'), $result->created);

$data['created'] = [
'year' => '2014',
Expand All @@ -151,11 +152,11 @@ public function testOneWithDatetimeField() {
'minute' => 25,
];
$result = $marshall->one($data, []);
$this->assertEquals(new \DateTime('2014-02-14 09:25:00'), $result->created);
$this->assertEquals(new Carbon('2014-02-14 09:25:00'), $result->created);

$data['created'] = '2014-02-14 09:25:00';
$result = $marshall->one($data, []);
$this->assertEquals(new \DateTime('2014-02-14 09:25:00'), $result->created);
$this->assertEquals(new Carbon('2014-02-14 09:25:00'), $result->created);

$data['created'] = 1392387900;
$result = $marshall->one($data, []);
Expand Down
5 changes: 3 additions & 2 deletions tests/TestCase/ORM/QueryRegressionTest.php
Expand Up @@ -14,6 +14,7 @@
*/
namespace Cake\Test\TestCase\ORM;

use Carbon\Carbon;
use Cake\ORM\Query;
use Cake\ORM\Table;
use Cake\ORM\TableRegistry;
Expand Down Expand Up @@ -51,8 +52,8 @@ public function tearDown() {
public function testSelectTimestampColumn() {
$table = TableRegistry::get('users');
$user = $table->find()->where(['id' => 1])->first();
$this->assertEquals(new \DateTime('2007-03-17 01:16:23'), $user->created);
$this->assertEquals(new \DateTime('2007-03-17 01:18:31'), $user->updated);
$this->assertEquals(new Carbon('2007-03-17 01:16:23'), $user->created);
$this->assertEquals(new Carbon('2007-03-17 01:18:31'), $user->updated);
}

/**
Expand Down
65 changes: 33 additions & 32 deletions tests/TestCase/ORM/TableTest.php
Expand Up @@ -14,6 +14,7 @@
*/
namespace Cake\Test\TestCase\ORM;

use Carbon\Carbon;
use Cake\Core\Configure;
use Cake\Database\Expression\OrderByExpression;
use Cake\Database\Expression\QueryExpression;
Expand Down Expand Up @@ -284,15 +285,15 @@ public function testFindAllNoFieldsAndNoHydration() {
'id' => 1,
'username' => 'mariano',
'password' => '$2a$10$u05j8FjsvLBNdfhBhc21LOuVMpzpabVXQ9OpC2wO3pSO0q6t7HHMO',
'created' => new \DateTime('2007-03-17 01:16:23'),
'updated' => new \DateTime('2007-03-17 01:18:31'),
'created' => new Carbon('2007-03-17 01:16:23'),
'updated' => new Carbon('2007-03-17 01:18:31'),
],
[
'id' => 2,
'username' => 'nate',
'password' => '$2a$10$u05j8FjsvLBNdfhBhc21LOuVMpzpabVXQ9OpC2wO3pSO0q6t7HHMO',
'created' => new \DateTime('2008-03-17 01:18:23'),
'updated' => new \DateTime('2008-03-17 01:20:31'),
'created' => new Carbon('2008-03-17 01:18:23'),
'updated' => new Carbon('2008-03-17 01:20:31'),
],
];
$this->assertEquals($expected, $results);
Expand Down Expand Up @@ -347,7 +348,7 @@ public function testFindAllConditionAutoTypes() {
]);
$query = $table->find('all')
->select(['id', 'username'])
->where(['created >=' => new \DateTime('2010-01-22 00:00')])
->where(['created >=' => new Carbon('2010-01-22 00:00')])
->hydrate(false)
->order('id');
$expected = [
Expand All @@ -356,7 +357,7 @@ public function testFindAllConditionAutoTypes() {
];
$this->assertSame($expected, $query->toArray());

$query->orWhere(['users.created' => new \DateTime('2008-03-17 01:18:23')]);
$query->orWhere(['users.created' => new Carbon('2008-03-17 01:18:23')]);
$expected = [
['id' => 2, 'username' => 'nate'],
['id' => 3, 'username' => 'larry'],
Expand Down Expand Up @@ -1117,8 +1118,8 @@ public function testSaveNewEntity() {
$entity = new \Cake\ORM\Entity([
'username' => 'superuser',
'password' => 'root',
'created' => new \DateTime('2013-10-10 00:00'),
'updated' => new \DateTime('2013-10-10 00:00')
'created' => new Carbon('2013-10-10 00:00'),
'updated' => new Carbon('2013-10-10 00:00')
]);
$table = TableRegistry::get('users');
$this->assertSame($entity, $table->save($entity));
Expand Down Expand Up @@ -1152,8 +1153,8 @@ public function testSaveEntityOnlySchemaFields() {
'username' => 'superuser',
'password' => 'root',
'crazyness' => 'super crazy value',
'created' => new \DateTime('2013-10-10 00:00'),
'updated' => new \DateTime('2013-10-10 00:00'),
'created' => new Carbon('2013-10-10 00:00'),
'updated' => new Carbon('2013-10-10 00:00'),
]);
$table = TableRegistry::get('users');
$this->assertSame($entity, $table->save($entity));
Expand All @@ -1174,8 +1175,8 @@ public function testBeforeSaveModifyData() {
$table = TableRegistry::get('users');
$data = new \Cake\ORM\Entity([
'username' => 'superuser',
'created' => new \DateTime('2013-10-10 00:00'),
'updated' => new \DateTime('2013-10-10 00:00')
'created' => new Carbon('2013-10-10 00:00'),
'updated' => new Carbon('2013-10-10 00:00')
]);
$listener = function($e, $entity, $options) use ($data) {
$this->assertSame($data, $entity);
Expand All @@ -1199,8 +1200,8 @@ public function testBeforeSaveModifyOptions() {
$data = new \Cake\ORM\Entity([
'username' => 'superuser',
'password' => 'foo',
'created' => new \DateTime('2013-10-10 00:00'),
'updated' => new \DateTime('2013-10-10 00:00')
'created' => new Carbon('2013-10-10 00:00'),
'updated' => new Carbon('2013-10-10 00:00')
]);
$listener1 = function($e, $entity, $options) {
$options['crazy'] = true;
Expand Down Expand Up @@ -1228,8 +1229,8 @@ public function testBeforeSaveStopEvent() {
$table = TableRegistry::get('users');
$data = new \Cake\ORM\Entity([
'username' => 'superuser',
'created' => new \DateTime('2013-10-10 00:00'),
'updated' => new \DateTime('2013-10-10 00:00')
'created' => new Carbon('2013-10-10 00:00'),
'updated' => new Carbon('2013-10-10 00:00')
]);
$listener = function($e, $entity) {
$e->stopPropagation();
Expand All @@ -1252,8 +1253,8 @@ public function testAfterSave() {
$table = TableRegistry::get('users');
$data = new \Cake\ORM\Entity([
'username' => 'superuser',
'created' => new \DateTime('2013-10-10 00:00'),
'updated' => new \DateTime('2013-10-10 00:00')
'created' => new Carbon('2013-10-10 00:00'),
'updated' => new Carbon('2013-10-10 00:00')
]);

$called = false;
Expand Down Expand Up @@ -1287,8 +1288,8 @@ public function testAfterSaveNotCalled() {
$statement = $this->getMock('\Cake\Database\Statement\StatementDecorator');
$data = new \Cake\ORM\Entity([
'username' => 'superuser',
'created' => new \DateTime('2013-10-10 00:00'),
'updated' => new \DateTime('2013-10-10 00:00')
'created' => new Carbon('2013-10-10 00:00'),
'updated' => new Carbon('2013-10-10 00:00')
]);

$table->expects($this->once())->method('exists')
Expand Down Expand Up @@ -1335,8 +1336,8 @@ public function testAtomicSave() {
$connection->expects($this->once())->method('commit');
$data = new \Cake\ORM\Entity([
'username' => 'superuser',
'created' => new \DateTime('2013-10-10 00:00'),
'updated' => new \DateTime('2013-10-10 00:00')
'created' => new Carbon('2013-10-10 00:00'),
'updated' => new Carbon('2013-10-10 00:00')
]);
$this->assertSame($data, $table->save($data));
}
Expand Down Expand Up @@ -1382,8 +1383,8 @@ public function testAtomicSaveRollback() {

$data = new \Cake\ORM\Entity([
'username' => 'superuser',
'created' => new \DateTime('2013-10-10 00:00'),
'updated' => new \DateTime('2013-10-10 00:00')
'created' => new Carbon('2013-10-10 00:00'),
'updated' => new Carbon('2013-10-10 00:00')
]);
$table->save($data);
}
Expand Down Expand Up @@ -1433,8 +1434,8 @@ public function testAtomicSaveRollbackOnFailure() {

$data = new \Cake\ORM\Entity([
'username' => 'superuser',
'created' => new \DateTime('2013-10-10 00:00'),
'updated' => new \DateTime('2013-10-10 00:00')
'created' => new Carbon('2013-10-10 00:00'),
'updated' => new Carbon('2013-10-10 00:00')
]);
$table->save($data);
}
Expand All @@ -1450,8 +1451,8 @@ public function testSaveOnlyDirtyProperties() {
$entity = new \Cake\ORM\Entity([
'username' => 'superuser',
'password' => 'root',
'created' => new \DateTime('2013-10-10 00:00'),
'updated' => new \DateTime('2013-10-10 00:00')
'created' => new Carbon('2013-10-10 00:00'),
'updated' => new Carbon('2013-10-10 00:00')
]);
$entity->clean();
$entity->dirty('username', true);
Expand All @@ -1477,8 +1478,8 @@ public function testsASavedEntityIsClean() {
$entity = new \Cake\ORM\Entity([
'username' => 'superuser',
'password' => 'root',
'created' => new \DateTime('2013-10-10 00:00'),
'updated' => new \DateTime('2013-10-10 00:00')
'created' => new Carbon('2013-10-10 00:00'),
'updated' => new Carbon('2013-10-10 00:00')
]);
$table = TableRegistry::get('users');
$this->assertSame($entity, $table->save($entity));
Expand All @@ -1498,8 +1499,8 @@ public function testsASavedEntityIsNotNew() {
$entity = new \Cake\ORM\Entity([
'username' => 'superuser',
'password' => 'root',
'created' => new \DateTime('2013-10-10 00:00'),
'updated' => new \DateTime('2013-10-10 00:00')
'created' => new Carbon('2013-10-10 00:00'),
'updated' => new Carbon('2013-10-10 00:00')
]);
$table = TableRegistry::get('users');
$this->assertSame($entity, $table->save($entity));
Expand Down

0 comments on commit 9a09a9d

Please sign in to comment.