浏览代码

fix failing tests

euromark 12 年之前
父节点
当前提交
76e96989c8
共有 3 个文件被更改,包括 16 次插入6 次删除
  1. 1 1
      Model/MyModel.php
  2. 12 2
      Test/Case/Model/Behavior/KeyValueBehaviorTest.php
  3. 3 3
      Test/Case/Model/SubqueryTest.php

+ 1 - 1
Model/MyModel.php

@@ -412,7 +412,7 @@ class MyModel extends Model {
 	 * Note: You might have to set `autoFields` to false in order to retrieve only the fields you request:
 	 * http://book.cakephp.org/2.0/en/core-libraries/behaviors/containable.html#containablebehavior-options
 	 *
-	 * @param string $type The type o the query ('count'/'all'/'first' - first only works with some mysql versions)
+	 * @param string $type The type of the query ('count'/'all'/'first' - first only works with some mysql versions)
 	 * @param array $options The options array
 	 * @param string $alias You can use this intead of $options['alias'] if you want
 	 * @param bool $parenthesise Add parenthesis before and after

+ 12 - 2
Test/Case/Model/Behavior/KeyValueBehaviorTest.php

@@ -49,11 +49,21 @@ class KeyValueBehaviorTest extends MyCakeTestCase {
 		$this->assertEquals('z', $res['User']['y']);
 
 
-		$this->Model->saveSection(2, array('User'=>array('x'=>1, 'y'=>'z')), 'Profile');
+		$res = $this->Model->saveSection(2, array('User' => array('x' => 1, 'y' => 'z')), 'Profile');
+		$this->assertTrue($res);
 
 		$res = $this->Model->getSection(2);
+		$this->assertTrue(empty($res));
+
+		$res = $this->Model->saveSection(2, array('User' => array('e' => 'f'), 'Profile'=>array('x' => 3, 'y' => 'abc')), 'Profile');
+		$this->assertTrue($res);
+
+		$res = $this->Model->getSection(2);
+		$this->debug($res);
 		$this->assertTrue(!empty($res['Profile']));
-		//debug($res);
+
+		$res = $this->Model->getSection(2, 'Profile');
+		$this->assertIdentical(array('x' => '3', 'y' => 'abc'), $res);
 	}
 
 	public function testDefaults() {

+ 3 - 3
Test/Case/Model/SubqueryTest.php

@@ -63,9 +63,11 @@ class SubqueryTest extends MyCakeTestCase {
 	public function testSubqueryPaginated() {
 		$Controller = new CountriesTestsController(new CakeRequest(null, false), new CakeResponse());
 		$Controller->constructClasses();
+		$source = $Controller->Country->getDataSource();
+		$database = $source->config['database'];
 
 		$subquery = $Controller->Country->subquery('list', array('conditions' => array('NOT' => array('SubCountry.id' => array(1, 2, 3)))));
-		$expected = '(SELECT SubCountry.id FROM `cake_test`.`countries` AS `SubCountry`   WHERE NOT (`SubCountry`.`id` IN (1, 2, 3)))';
+		$expected = '(SELECT SubCountry.id FROM `' . $database . '`.`countries` AS `SubCountry`   WHERE NOT (`SubCountry`.`id` IN (1, 2, 3)))';
 		$this->assertEquals($expected, $subquery);
 
 		$res = $Controller->Country->query($subquery);
@@ -86,6 +88,4 @@ class CountriesTestsController extends Controller {
 
 	public $uses = array('Tools.Country');
 
-	//public $components = array('Paginator');
-
 }