From 0a3960db0abf8b705baea8e3ddc02d650fbbaeef Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Wed, 13 Nov 2013 20:38:59 +0100 Subject: [PATCH] Adding a default scope --- Cake/ORM/Validator.php | 3 +++ Cake/Test/TestCase/ORM/ValidatorTest.php | 2 ++ 2 files changed, 5 insertions(+) diff --git a/Cake/ORM/Validator.php b/Cake/ORM/Validator.php index 19261604850..f9879ded77a 100644 --- a/Cake/ORM/Validator.php +++ b/Cake/ORM/Validator.php @@ -109,6 +109,9 @@ public function scope($name, $object = null) { if (isset($this->_scopes[$name])) { return $this->_scopes[$name]; } + if ($name === 'default') { + return $this->_scopes[$name] = '\Cake\Utility\Validation'; + } return null; } $this->_scopes[$name] = $object; diff --git a/Cake/Test/TestCase/ORM/ValidatorTest.php b/Cake/Test/TestCase/ORM/ValidatorTest.php index ce28eeca5d5..2c0777bf2a7 100644 --- a/Cake/Test/TestCase/ORM/ValidatorTest.php +++ b/Cake/Test/TestCase/ORM/ValidatorTest.php @@ -221,6 +221,8 @@ public function testScope() { $another = new \stdClass; $this->assertSame($validator, $validator->scope('bar', $another)); $this->assertSame($another, $validator->scope('bar')); + + $this->assertEquals('\Cake\Utility\Validation', $validator->scope('default')); } }