diff --git a/Test/Case/Controller/Component/FilterComponentTest.php b/Test/Case/Controller/Component/FilterComponentTest.php index f9b2139..3e88749 100644 --- a/Test/Case/Controller/Component/FilterComponentTest.php +++ b/Test/Case/Controller/Component/FilterComponentTest.php @@ -13,9 +13,15 @@ App::uses('Router', 'Routing'); App::uses('Component', 'Filter.Filter'); -require_once(dirname(dirname(dirname(__FILE__))) . DS . 'MockObjects.php'); - -class FilterTestCase extends CakeTestCase +App::uses('Document', 'Filter.Test/Case/MockObjects'); +App::uses('Document2', 'Filter.Test/Case/MockObjects'); +App::uses('Document3', 'Filter.Test/Case/MockObjects'); +App::uses('DocumentCategory', 'Filter.Test/Case/MockObjects'); +App::uses('DocumentTestsController', 'Filter.Test/Case/MockObjects'); +App::uses('Item', 'Filter.Test/Case/MockObjects'); +App::uses('Metadata', 'Filter.Test/Case/MockObjects'); + +class FilterComponentTest extends CakeTestCase { public $fixtures = array ( diff --git a/Test/Case/MockObjects.php b/Test/Case/MockObjects.php deleted file mode 100644 index 184aa46..0000000 --- a/Test/Case/MockObjects.php +++ /dev/null @@ -1,104 +0,0 @@ - - - Multi-licensed under: - MPL - LGPL - GPL -*/ - -App::uses('Behavior', 'Filter.Filtered'); -App::uses('Controller', 'Controller'); - -class DocumentCategory extends CakeTestModel -{ - public $name = 'DocumentCategory'; - public $hasMany = array('Document'); - - public function customSelector($options = array()) - { - $options['conditions']['DocumentCategory.title LIKE'] = '%T%'; - $options['nofilter'] = true; - - return $this->find('list', $options); - } -} - -class Document extends CakeTestModel -{ - public $name = 'Document'; - public $belongsTo = array('DocumentCategory'); - public $hasMany = array('Item'); - public $hasOne = array('Metadata'); -} - -class Document2 extends CakeTestModel -{ - public $name = 'Document'; - public $alias = 'Document'; - public $belongsTo = array('DocumentCategory'); - public $hasMany = array('Item'); - - public $returnValue = false; - - public function beforeDataFilter($query, $options) - { - return $this->returnValue; - } -} - -class Document3 extends CakeTestModel -{ - public $name = 'Document'; - public $alias = 'Document'; - public $belongsTo = array('DocumentCategory'); - public $hasMany = array('Item'); - - public $itemToUnset = null; - - public function afterDataFilter($query, $options) - { - if (!is_string($this->itemToUnset)) - { - return $query; - } - - if (isset($query['conditions'][$this->itemToUnset])) - { - unset($query['conditions'][$this->itemToUnset]); - } - - return $query; - } -} - -class Metadata extends CakeTestModel -{ - public $name = 'Metadata'; - public $hasOne = array('Document'); -} - -class Item extends CakeTestModel -{ - public $name = 'Item'; - public $belongsTo = array('Document'); -} - -class DocumentTestsController extends Controller -{ - public $name = 'DocumentTests'; - - public function index() - { - } - - // must override this or the tests never complete.. - // @TODO: mock partial? - public function redirect($url, $status = null, $exit = true) - { - } -} diff --git a/Test/Case/MockObjects/Document.php b/Test/Case/MockObjects/Document.php new file mode 100644 index 0000000..fec3818 --- /dev/null +++ b/Test/Case/MockObjects/Document.php @@ -0,0 +1,9 @@ +returnValue; + } +} diff --git a/Test/Case/MockObjects/Document3.php b/Test/Case/MockObjects/Document3.php new file mode 100644 index 0000000..a74ea53 --- /dev/null +++ b/Test/Case/MockObjects/Document3.php @@ -0,0 +1,26 @@ +itemToUnset)) + { + return $query; + } + + if (isset($query['conditions'][$this->itemToUnset])) + { + unset($query['conditions'][$this->itemToUnset]); + } + + return $query; + } +} diff --git a/Test/Case/MockObjects/DocumentCategory.php b/Test/Case/MockObjects/DocumentCategory.php new file mode 100644 index 0000000..b53814d --- /dev/null +++ b/Test/Case/MockObjects/DocumentCategory.php @@ -0,0 +1,15 @@ +find('list', $options); + } +} diff --git a/Test/Case/MockObjects/DocumentTestsController.php b/Test/Case/MockObjects/DocumentTestsController.php new file mode 100644 index 0000000..68842ce --- /dev/null +++ b/Test/Case/MockObjects/DocumentTestsController.php @@ -0,0 +1,18 @@ +