Skip to content

Commit

Permalink
Fix tests that occasionally fail on postgres.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Nov 12, 2012
1 parent 644d47c commit e0586da
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions lib/Cake/Test/Case/Model/BehaviorCollectionTest.php
Expand Up @@ -786,21 +786,22 @@ public function testBehaviorHasOneFindCallbacks() {
public function testBehaviorBelongsToFindCallbacks() {
$this->skipIf($this->db instanceof Sqlserver, 'This test is not compatible with SQL Server.');

$conditions = array('order' => 'Apple.id ASC');
$Apple = new Apple();
$Apple->unbindModel(array('hasMany' => array('Child'), 'hasOne' => array('Sample')), false);
$expected = $Apple->find('all');
$expected = $Apple->find('all', $conditions);

$Apple->unbindModel(array('belongsTo' => array('Parent')));
$wellBehaved = $Apple->find('all');
$wellBehaved = $Apple->find('all', $conditions);
$Apple->Parent->Behaviors->attach('Test');
$Apple->unbindModel(array('belongsTo' => array('Parent')));
$this->assertSame($Apple->find('all'), $wellBehaved);
$this->assertSame($Apple->find('all', $conditions), $wellBehaved);

$Apple->Parent->Behaviors->attach('Test', array('before' => 'off'));
$this->assertSame($expected, $Apple->find('all'));
$this->assertSame($expected, $Apple->find('all', $conditions));

$Apple->Parent->Behaviors->attach('Test', array('before' => 'test'));
$this->assertSame($expected, $Apple->find('all'));
$this->assertSame($expected, $Apple->find('all', $conditions));

$Apple->Parent->Behaviors->attach('Test', array('before' => 'modify'));
$expected2 = array(
Expand All @@ -816,22 +817,23 @@ public function testBehaviorBelongsToFindCallbacks() {
);
$result2 = $Apple->find('all', array(
'fields' => array('Apple.id', 'Parent.id', 'Parent.name', 'Parent.mytime'),
'conditions' => array('Apple.id <' => '4')
'conditions' => array('Apple.id <' => '4'),
'order' => 'Apple.id ASC',
));
$this->assertEquals($expected2, $result2);

$Apple->Parent->Behaviors->disable('Test');
$result = $Apple->find('all');
$result = $Apple->find('all', $conditions);
$this->assertEquals($expected, $result);

$Apple->Parent->Behaviors->attach('Test', array('after' => 'off'));
$this->assertEquals($expected, $Apple->find('all'));
$this->assertEquals($expected, $Apple->find('all', $conditions));

$Apple->Parent->Behaviors->attach('Test', array('after' => 'test'));
$this->assertEquals($expected, $Apple->find('all'));
$this->assertEquals($expected, $Apple->find('all', $conditions));

$Apple->Parent->Behaviors->attach('Test', array('after' => 'test2'));
$this->assertEquals($expected, $Apple->find('all'));
$this->assertEquals($expected, $Apple->find('all', $conditions));
}

/**
Expand Down

0 comments on commit e0586da

Please sign in to comment.