Browse Source

Merge pull request #3036 from tigrang/bug-fix-validate

Check `validate` option before validating
Mark Story 12 years ago
parent
commit
2ab9febcbd
2 changed files with 2 additions and 10 deletions
  1. 1 1
      src/ORM/Table.php
  2. 1 9
      tests/TestCase/ORM/TableTest.php

+ 1 - 1
src/ORM/Table.php

@@ -1125,7 +1125,7 @@ class Table implements RepositoryInterface, EventListener {
 		$associated = $options['associated'];
 		$options['associated'] = [];
 
-		if (!$this->validate($entity, $options)) {
+		if ($options['validate'] && !$this->validate($entity, $options)) {
 			return false;
 		}
 

+ 1 - 9
tests/TestCase/ORM/TableTest.php

@@ -2778,15 +2778,7 @@ class TableTest extends \Cake\TestSuite\TestCase {
 			->with($entity->author->supervisor, ['name' => 'Marc'])
 			->will($this->returnValue($entity->author->supervisor));
 
-		$options = new \ArrayObject([
-			'validate' => false,
-			'atomic' => false,
-			'associated' => []
-		]);
-		$supervisors->expects($this->once())
-			->method('validate')
-			->with($entity->author->supervisor, $options)
-			->will($this->returnValue(true));
+		$supervisors->expects($this->never())->method('validate');
 
 		$tags->expects($this->never())->method('_insert');