Skip to content
Permalink
Browse files

Add buildValidator event hook to Table.

While I don't think this will be frequently used, it does round out the
method listener options at the Table class. I've included some more
tests as well.

Refs #9099
  • Loading branch information...
markstory committed Jul 13, 2016
1 parent e6e3ca7 commit c678bff7cc5ac33dc7d975997da4c3ab9b70729b
Showing with 15 additions and 1 deletion.
  1. +2 −0 src/ORM/Table.php
  2. +13 −1 tests/TestCase/ORM/TableTest.php
@@ -2252,6 +2252,7 @@ public function validateUnique($value, array $options, array $context = null)
* The conventional method map is:
*
* - Model.beforeMarshal => beforeMarshal
* - Model.buildValidator => buildValidator
* - Model.beforeFind => beforeFind
* - Model.beforeSave => beforeSave
* - Model.afterSave => afterSave
@@ -2268,6 +2269,7 @@ public function implementedEvents()
{
$eventMap = [
'Model.beforeMarshal' => 'beforeMarshal',
'Model.buildValidator' => 'buildValidator',
'Model.beforeFind' => 'beforeFind',
'Model.beforeSave' => 'beforeSave',
'Model.afterSave' => 'afterSave',
@@ -1673,15 +1673,27 @@ public function testCallBehaviorAliasedFinder()
public function testImplementedEvents()
{
$table = $this->getMockBuilder('Cake\ORM\Table')
->setMethods(['beforeFind', 'beforeSave', 'afterSave', 'beforeDelete', 'afterDelete'])
->setMethods([
'buildValidator',
'beforeMarshal',
'beforeFind',
'beforeSave',
'afterSave',
'beforeDelete',
'afterDelete',
'afterRules'
])
->getMock();
$result = $table->implementedEvents();
$expected = [
'Model.beforeMarshal' => 'beforeMarshal',
'Model.buildValidator' => 'buildValidator',
'Model.beforeFind' => 'beforeFind',
'Model.beforeSave' => 'beforeSave',
'Model.afterSave' => 'afterSave',
'Model.beforeDelete' => 'beforeDelete',
'Model.afterDelete' => 'afterDelete',
'Model.afterRules' => 'afterRules',
];
$this->assertEquals($expected, $result, 'Events do not match.');
}

0 comments on commit c678bff

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.