getRules() public method

Generate default rules checker.
public getRules ( Table $model, array $associations ) : array
$model Cake\ORM\Table The model to introspect.
$associations array The associations for the model.
return array The rules to be applied.
Exemplo n.º 1
0
 /**
  * Tests baking a table with rules
  *
  * @return void
  */
 public function testBakeWithRules()
 {
     $model = TableRegistry::get('Users');
     $associations = ['belongsTo' => [['alias' => 'Countries', 'foreignKey' => 'country_id'], ['alias' => 'Sites', 'foreignKey' => 'site_id']], 'hasMany' => [['alias' => 'BakeComments', 'foreignKey' => 'bake_user_id']]];
     $rulesChecker = $this->Task->getRules($model, $associations);
     $result = $this->Task->bakeTable($model, compact('rulesChecker'));
     $this->assertSameAsFile(__FUNCTION__ . '.php', $result);
 }