Browse Source

fix tests

Mark Scherer 10 years ago
parent
commit
0835130971

+ 13 - 1
Model/MyModel.php

@@ -1336,8 +1336,9 @@ class MyModel extends ShimModel {
 
 	/**
 	 * Shim wrapper for 2.6 to allow 2.7 notBlank validation rule to work already.
+	 * This is only there to avoid the deprecation errors in 2.6 test runs.
 	 *
-	 * @param $data
+	 * @param array $data
 	 * @return bool
 	 */
 	public function notBlank($data) {
@@ -1349,6 +1350,17 @@ class MyModel extends ShimModel {
 	}
 
 	/**
+	 * Shim wrapper for 2.6 to allow 2.7 notBlank validation rule to work already.
+	 * This is only there to avoid the deprecation errors in 2.6 test runs.
+	 *
+	 * @param array $data
+	 * @return bool
+	 */
+	public function notEmpty($data) {
+		return $this->notBlank($data);
+	}
+
+	/**
 	 * Recursive Dropdown Lists
 	 * NEEDS tree behavior, NEEDS lft, rght, parent_id (!)
 	 * //FIXME

+ 7 - 30
Test/Case/Model/Behavior/BitmaskedBehaviorTest.php

@@ -16,7 +16,11 @@ class BitmaskedBehaviorTest extends MyCakeTestCase {
 	public function setUp() {
 		parent::setUp();
 
-		$this->Comment = new BitmaskedComment();
+		App::build([
+			'Model' => [CakePlugin::path('Tools') . 'Test' . DS . 'test_app' . DS . 'Model' . DS],
+		], App::RESET);
+
+		$this->Comment = ClassRegistry::init('BitmaskedComment');
 		$this->Comment->Behaviors->load('Tools.Bitmasked', ['mappedField' => 'statuses']);
 	}
 
@@ -48,6 +52,8 @@ class BitmaskedBehaviorTest extends MyCakeTestCase {
 		];
 		$this->Comment->create();
 		$this->Comment->set($data);
+		debug($this->Comment->validate);
+		debug($this->Comment->data); ob_flush();
 		$res = $this->Comment->validates();
 		$this->assertTrue($res);
 
@@ -174,32 +180,3 @@ class BitmaskedBehaviorTest extends MyCakeTestCase {
 	}
 
 }
-
-class BitmaskedComment extends CakeTestModel {
-
-	public $validate = [
-		'status' => [
-			'notBlank' => [
-				'rule' => 'notBlank',
-				'last' => true
-			]
-		]
-	];
-
-	public static function statuses($value = null) {
-		$options = [
-			static::STATUS_ACTIVE => __d('tools', 'Active'),
-			static::STATUS_PUBLISHED => __d('tools', 'Published'),
-			static::STATUS_APPROVED => __d('tools', 'Approved'),
-			static::STATUS_FLAGGED => __d('tools', 'Flagged'),
-		];
-
-		return MyModel::enum($value, $options);
-	}
-
-	const STATUS_NONE = 0;
-	const STATUS_ACTIVE = 1;
-	const STATUS_PUBLISHED = 2;
-	const STATUS_APPROVED = 4;
-	const STATUS_FLAGGED = 8;
-}

+ 32 - 0
Test/test_app/Model/BitmaskedComment.php

@@ -0,0 +1,32 @@
+<?php
+App::uses('MyModel', 'Tools.Model');
+
+class BitmaskedComment extends MyModel {
+
+	public $validate = [
+		'status' => [
+			'notBlank' => [
+				'rule' => 'notBlank',
+				'last' => true
+			]
+		]
+	];
+
+	public static function statuses($value = null) {
+		$options = [
+			static::STATUS_ACTIVE => __d('tools', 'Active'),
+			static::STATUS_PUBLISHED => __d('tools', 'Published'),
+			static::STATUS_APPROVED => __d('tools', 'Approved'),
+			static::STATUS_FLAGGED => __d('tools', 'Flagged'),
+		];
+
+		return static::enum($value, $options);
+	}
+
+	const STATUS_NONE = 0;
+	const STATUS_ACTIVE = 1;
+	const STATUS_PUBLISHED = 2;
+	const STATUS_APPROVED = 4;
+	const STATUS_FLAGGED = 8;
+
+}