/**
  * testBehaviorValidateAfterCallback method
  *
  * @return void
  */
 public function testBehaviorValidateAfterCallback()
 {
     $Apple = new Apple();
     $Apple->Behaviors->attach('Test');
     $this->assertSame($Apple->validates(), true);
     $Apple->Behaviors->attach('Test', array('afterValidate' => 'on'));
     $this->assertSame($Apple->validates(), true);
     $this->assertSame($Apple->validationErrors, array());
     $Apple->Behaviors->attach('Test', array('afterValidate' => 'test'));
     $Apple->data = array('bar');
     $Apple->validates();
     $this->assertEquals(array('foo'), $Apple->data);
 }
Example #2
0
 /**
  * testBehaviorValidateCallback method
  *
  * @access public
  * @return void
  */
 function testBehaviorValidateCallback()
 {
     $Apple = new Apple();
     $Apple->Behaviors->attach('Test');
     $this->assertIdentical($Apple->validates(), true);
     $Apple->Behaviors->attach('Test', array('validate' => 'on'));
     $this->assertIdentical($Apple->validates(), false);
     $this->assertIdentical($Apple->validationErrors, array('name' => true));
     $Apple->Behaviors->attach('Test', array('validate' => 'stop'));
     $this->assertIdentical($Apple->validates(), false);
     $this->assertIdentical($Apple->validationErrors, array('name' => true));
     $Apple->Behaviors->attach('Test', array('validate' => 'whitelist'));
     $Apple->validates();
     $this->assertIdentical($Apple->whitelist, array());
     $Apple->whitelist = array('unknown');
     $Apple->validates();
     $this->assertIdentical($Apple->whitelist, array('unknown', 'name'));
 }