Commit: fdb1ad0bb08474cf02bfc4e0ad9959cb5ad0c72d

Author: alkemann | Date: 2009-11-17 19:05:25 +0100
tests for using filter to apply the latest view if it doesnt exist
diff --git a/tests/integration/PasteTest.php b/tests/integration/PasteTest.php index b37e981..f5b9d08 100644 --- a/tests/integration/PasteTest.php +++ b/tests/integration/PasteTest.php @@ -191,7 +191,28 @@ class PasteTest extends \lithium\test\Unit { } public function testLatestView() { - $this->setUpTasks(array('PutTable','PutView','FillTableFull')); + $this->setUpTasks(array('PutTable','FillTableFull')); + MockPaste::applyFilter('find', function($self, $params, $chain) { + var_dump($params); + if ($params['options']['conditions']['design'] = 'latest') { + $conditions = $params['options']['conditions']; + $result = $chain->next($self, $params, $chain); + if ($result === null) { + MockPaste::createView()->save(); + return null; //static::find('all', $conditions); + } + return $result; + } else { + return $chain->next($self, $params, $chain); + } + }); + $latest = MockPaste::find('all', array('conditions'=> array( + 'design' => 'latest', + 'view' => 'all', + 'limit' => '10', + 'descending' => 'true' + ))); + $this->assertNull($latest); $latest = MockPaste::find('all', array('conditions'=> array( 'design' => 'latest',