Esempio n. 1
0
 /**
  * Test adding rule for update mode
  *
  * @return void
  */
 public function testAddingRuleUpdateMode()
 {
     $entity = new Entity(['name' => 'larry']);
     $rules = new RulesChecker();
     $rules->addUpdate(function () {
         return false;
     }, 'ruleName', ['errorField' => 'name']);
     $this->assertTrue($rules->check($entity, RulesChecker::CREATE));
     $this->assertEmpty($entity->errors());
     $this->assertTrue($rules->check($entity, RulesChecker::DELETE));
     $this->assertEmpty($entity->errors());
     $this->assertFalse($rules->check($entity, RulesChecker::UPDATE));
     $this->assertEquals(['ruleName' => 'invalid'], $entity->errors('name'));
 }