Browse Source

Fix RC1 broken stuff.

euromark 11 years ago
parent
commit
cf88cf5a02

+ 4 - 3
src/Model/Behavior/BitmaskedBehavior.php

@@ -36,7 +36,7 @@ class BitmaskedBehavior extends Behavior {
 		'field' => 'status',
 		'mappedField' => null, // NULL = same as above
 		'bits' => null, // Method or callback to get the bits data
-		'on' => 'beforeValidate', // beforeSave or beforeValidate
+		'on' => 'beforeRules', // beforeSave or beforeRules
 		'defaultValue' => null, // NULL = auto (use empty string to trigger "notEmpty" rule for "default NOT NULL" db fields)
 	);
 
@@ -98,8 +98,9 @@ class BitmaskedBehavior extends Behavior {
 	 * @param \ArrayObject $options
 	 * @return void
 	 */
-	public function beforeValidate(Event $event, Entity $entity, \ArrayObject $options) {
-		if ($this->_config['on'] !== 'beforeValidate' || !$options['validate']) {
+	public function beforeRules(Event $event, Entity $entity, \ArrayObject $options) {
+		//throw new \Exception();
+		if ($this->_config['on'] !== 'beforeRules' || !$options['checkRules']) {
 			return;
 		}
 		$this->encodeBitmaskData($entity);

+ 1 - 1
src/Model/Behavior/PasswordableBehavior.php

@@ -202,7 +202,7 @@ class PasswordableBehavior extends Behavior {
 	 *
 	 * @return void
 	 */
-	public function beforeValidate(Event $event, Entity $entity) {
+	public function beforeRules(Event $event, Entity $entity) {
 		$formField = $this->_config['formField'];
 		$formFieldRepeat = $this->_config['formFieldRepeat'];
 		$formFieldCurrent = $this->_config['formFieldCurrent'];

+ 7 - 4
tests/TestCase/Model/Behavior/BitmaskedBehaviorTest.php

@@ -73,8 +73,8 @@ class BitmaskedBehaviorTest extends TestCase {
 		);
 
 		$entity = $this->Comments->newEntity($data);
-		$res = $this->Comments->validate($entity);
-		$this->assertTrue($res);
+		$this->assertEmpty($entity->errors());
+		//debug($entity);die();
 		$this->assertSame('0', $entity->get('status'));
 
 		$data = array(
@@ -82,14 +82,15 @@ class BitmaskedBehaviorTest extends TestCase {
 			'statuses' => array(BitmaskedComment::STATUS_PUBLISHED, BitmaskedComment::STATUS_APPROVED),
 		);
 		$entity = $this->Comments->newEntity($data);
-		$res = $this->Comments->validate($entity);
-		$this->assertTrue($res);
+		$this->assertEmpty($entity->errors());
 
 		$is = $entity->get('status');
 		$this->assertSame(BitmaskedComment::STATUS_PUBLISHED | BitmaskedComment::STATUS_APPROVED, $is);
 
 		// save + find
 		$entity = $this->Comments->newEntity($data);
+		$this->assertEmpty($entity->errors());
+
 		$res = $this->Comments->save($entity);
 		$this->assertTrue((bool)$res);
 
@@ -165,6 +166,8 @@ class BitmaskedBehaviorTest extends TestCase {
 			'statuses' => array(BitmaskedComment::STATUS_PUBLISHED, BitmaskedComment::STATUS_APPROVED),
 		);
 		$entity = $this->Comments->newEntity($data);
+		$this->assertEmpty($entity->errors());
+
 		$res = $this->Comments->save($entity);
 		$this->assertTrue((bool)$res);
 		$this->assertSame(BitmaskedComment::STATUS_PUBLISHED | BitmaskedComment::STATUS_APPROVED, $res['status']);