Permalink
Browse files

Merge pull request #32 from Phally/failing-test

Failing test in the ArraySource test case
  • Loading branch information...
predominant committed Apr 3, 2012
2 parents 5485ecb + ae2b4a7 commit 62e2370c7a60e5ea3e370b408858770f20a97d1a
Showing with 46 additions and 37 deletions.
  1. +9 −0 Model/Datasource/ArraySource.php
  2. +37 −37 Test/Case/Model/Datasource/ArraySourceTest.php
@@ -295,6 +295,15 @@ public function calculate(&$model, $type, $params = array()) {
return 'COUNT';
}
+/**
+ * Implemented to make the datasource work with Model::find('count').
+ *
+ * @return boolean Always false;
+ */
+ public function expression() {
+ return false;
+ }
+
/**
* Queries associations. Used to fetch results on recursive models.
*
@@ -36,31 +36,31 @@ class ArrayModel extends CakeTestModel {
* @var string
* @access public
*/
- var $name = 'ArrayModel';
+ public $name = 'ArrayModel';
/**
* Database Configuration
*
* @var string
* @access public
*/
- var $useDbConfig = 'test_array';
+ public $useDbConfig = 'test_array';
/**
* Set recursive
*
* @var integer
* @access public
*/
- var $recursive = -1;
+ public $recursive = -1;
/**
* Records
*
* @var array
* @access public
*/
- var $records = array(
+ public $records = array(
array(
'id' => 1,
'name' => 'USA',
@@ -91,23 +91,23 @@ class ArraysRelateModel extends CakeTestModel {
* @var string
* @access public
*/
- var $name = 'ArraysRelateModel';
+ public $name = 'ArraysRelateModel';
/**
* Database Configuration
*
* @var string
* @access public
*/
- var $useDbConfig = 'test_array';
+ public $useDbConfig = 'test_array';
/**
* Records
*
* @var array
* @access public
*/
- var $records = array(
+ public $records = array(
array('array_model_id' => 1, 'relate_id' => 1),
array('array_model_id' => 1, 'relate_id' => 2),
array('array_model_id' => 1, 'relate_id' => 3),
@@ -130,31 +130,31 @@ class UserModel extends CakeTestModel {
* @var string
* @access public
*/
- var $name = 'UserModel';
+ public $name = 'UserModel';
/**
* Use DB Config
*
* @var string
* @access public
*/
- var $useDbConfig = 'test';
+ public $useDbConfig = 'test';
/**
* Use Table
*
* @var string
* @access public
*/
- var $useTable = 'users';
+ public $useTable = 'users';
/**
* Belongs To
*
* @var array
* @access public
*/
- var $belongsTo = array(
+ public $belongsTo = array(
'Born' => array(
'className' => 'ArrayModel',
'foreignKey' => 'born_id',
@@ -174,15 +174,15 @@ class ArraySourceTest extends CakeTestCase {
* @var ArraySource
* @access public
*/
- var $Model = null;
+ public $Model = null;
/**
* Set up for Tests
*
* @return void
* @access public
*/
- function setUp() {
+ public function setUp() {
parent::setUp();
$this->Model =& ClassRegistry::init('ArrayModel');
}
@@ -193,7 +193,7 @@ function setUp() {
* @return void
* @access public
*/
- function testFindAll() {
+ public function testFindAll() {
$result = $this->Model->find('all');
$expected = array(
array('ArrayModel' => array('id' => 1, 'name' => 'USA', 'relate_id' => 1)),
@@ -209,7 +209,7 @@ function testFindAll() {
* @return void
* @access public
*/
- function testFindFields() {
+ public function testFindFields() {
$expected = array(
array('ArrayModel' => array('id' => 1)),
array('ArrayModel' => array('id' => 2)),
@@ -231,7 +231,7 @@ function testFindFields() {
* @return void
* @access public
*/
- function testField() {
+ public function testField() {
$expected = 2;
$result = $this->Model->field('id', array('name' => 'Brazil'));
$this->assertEqual($result, $expected);
@@ -251,7 +251,7 @@ function testField() {
* @return void
* @access public
*/
- function testFindLimit() {
+ public function testFindLimit() {
$result = $this->Model->find('all', array('limit' => 2));
$expected = array(
array('ArrayModel' => array('id' => 1, 'name' => 'USA', 'relate_id' => 1)),
@@ -272,7 +272,7 @@ function testFindLimit() {
* @return void
* @access public
*/
- function testFindOrder() {
+ public function testFindOrder() {
$result = $this->Model->find('all', array('order' => 'ArrayModel.name'));
$expected = array(
array('ArrayModel' => array('id' => 2, 'name' => 'Brazil', 'relate_id' => 1)),
@@ -302,7 +302,7 @@ function testFindOrder() {
* @return void
* @access public
*/
- function testFindConditions() {
+ public function testFindConditions() {
$result = $this->Model->find('all', array('conditions' => array('ArrayModel.name' => 'USA')));
$expected = array(array('ArrayModel' => array('id' => 1, 'name' => 'USA', 'relate_id' => 1)));
$this->assertEqual($result, $expected);
@@ -329,10 +329,10 @@ function testFindConditions() {
$result = $this->Model->find('all', array('conditions' => array('ArrayModel.name LIKE _r%')));
$this->assertEqual($result, $expected);
-
+
$result = $this->Model->find('all', array('conditions' => array('ArrayModel.name LIKE %b%')));
$this->assertEqual($result, $expected);
-
+
$result = $this->Model->find('all', array('conditions' => array('ArrayModel.name LIKE %a%')));
$expected = array(array('ArrayModel' => array('id' => 1, 'name' => 'USA', 'relate_id' => 1)), array('ArrayModel' => array('id' => 2, 'name' => 'Brazil', 'relate_id' => 1)), array('ArrayModel' => array('id' => 3, 'name' => 'Germany', 'relate_id' => 2)));
$this->assertEqual($result, $expected);
@@ -355,7 +355,7 @@ function testFindConditions() {
* @return void
* @access public
*/
- function testFindConditionsRecursive() {
+ public function testFindConditionsRecursive() {
$result = $this->Model->find('all', array('conditions' => array('AND' => array('ArrayModel.name' => 'USA', 'ArrayModel.id' => 2))));
$expected = array();
$this->assertIdentical($result, $expected);
@@ -381,7 +381,7 @@ function testFindConditionsRecursive() {
* @return void
* @access public
*/
- function testFindFirst() {
+ public function testFindFirst() {
$result = $this->Model->find('first');
$expected = array('ArrayModel' => array('id' => 1, 'name' => 'USA', 'relate_id' => 1));
$this->assertEqual($result, $expected);
@@ -397,7 +397,7 @@ function testFindFirst() {
* @return void
* @access public
*/
- function testFindCount() {
+ public function testFindCount() {
$result = $this->Model->find('count');
$this->assertEqual($result, 3);
@@ -417,7 +417,7 @@ function testFindCount() {
* @return void
* @access public
*/
- function testFindList() {
+ public function testFindList() {
$result = $this->Model->find('list');
$expected = array(1 => 1, 2 => 2, 3 => 3);
$this->assertEqual($result, $expected);
@@ -434,7 +434,7 @@ function testFindList() {
* @return void
* @access public
*/
- function testRead() {
+ public function testRead() {
$result = $this->Model->read(null, 1);
$expected = array('ArrayModel' => array('id' => 1, 'name' => 'USA', 'relate_id' => 1));
$this->assertEqual($result, $expected);
@@ -457,15 +457,15 @@ class IntractModelTest extends CakeTestCase {
* @var array
* @access public
*/
- var $fixtures = array('plugin.datasources.user');
+ public $fixtures = array('plugin.datasources.user');
/**
* skip
*
* @return void
* @access public
*/
- function skip() {
+ public function skip() {
$db =& ConnectionManager::getDataSource('test');
$this->skipUnless(is_subclass_of($db, 'DboSource'), '%s because database test not extends one DBO driver.');
}
@@ -476,7 +476,7 @@ function skip() {
* @return void
* @access public
*/
- function testDboToArrayBelongsTo() {
+ public function testDboToArrayBelongsTo() {
ClassRegistry::config(array());
$model = ClassRegistry::init('UserModel');
@@ -510,7 +510,7 @@ function testDboToArrayBelongsTo() {
* @return void
* @access public
*/
- function testDboToArrayBelongsToWithoutForeignKey() {
+ public function testDboToArrayBelongsToWithoutForeignKey() {
ClassRegistry::config(array());
$model = ClassRegistry::init('UserModel');
@@ -545,7 +545,7 @@ function testDboToArrayBelongsToWithoutForeignKey() {
* @return void
* @access public
*/
- function testDboToArrayHasMany() {
+ public function testDboToArrayHasMany() {
ClassRegistry::config(array());
$model = ClassRegistry::init('UserModel');
$model->unBindModel(array('belongsTo' => array('Born')), false);
@@ -583,7 +583,7 @@ function testDboToArrayHasMany() {
* @return void
* @access public
*/
- function testDboToArrayHasOne() {
+ public function testDboToArrayHasOne() {
ClassRegistry::config(array());
$model = ClassRegistry::init('UserModel');
$model->unBindModel(array('hasMany' => array('Relate')), false);
@@ -616,7 +616,7 @@ function testDboToArrayHasOne() {
* @return void
* @access public
*/
- function testArrayToArrayBelongsTo() {
+ public function testArrayToArrayBelongsTo() {
ClassRegistry::config(array());
$model = ClassRegistry::init('ArrayModel');
$model->recursive = 0;
@@ -672,7 +672,7 @@ function testArrayToArrayBelongsTo() {
* @return void
* @access public
*/
- function testArrayToArrayBelongsToWithoutForeignKey() {
+ public function testArrayToArrayBelongsToWithoutForeignKey() {
ClassRegistry::config(array());
$model = ClassRegistry::init('ArrayModel');
@@ -702,7 +702,7 @@ function testArrayToArrayBelongsToWithoutForeignKey() {
* @return void
* @access public
*/
- function testArrayToArrayHasMany() {
+ public function testArrayToArrayHasMany() {
ClassRegistry::config(array());
$model = ClassRegistry::init('ArrayModel');
$model->unBindModel(array('belongsTo' => array('Relate')), false);
@@ -735,7 +735,7 @@ function testArrayToArrayHasMany() {
* @return void
* @access public
*/
- function testArrayToArrayHasOne() {
+ public function testArrayToArrayHasOne() {
ClassRegistry::config(array());
$model = ClassRegistry::init('ArrayModel');
$model->unBindModel(array('hasMany' => array('Relate')), false);
@@ -765,7 +765,7 @@ function testArrayToArrayHasOne() {
* @return void
* @access public
*/
- function testArrayToArrayHasAndBelongsToMany() {
+ public function testArrayToArrayHasAndBelongsToMany() {
ClassRegistry::config(array());
$model = ClassRegistry::init('ArrayModel');
$model->unBindModel(array('hasOne' => array('Relate')), false);

0 comments on commit 62e2370

Please sign in to comment.