From c31c9a04c36fef7d6f8518852a506c56ab1df65f Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 10 Feb 2014 11:39:06 -0500 Subject: [PATCH] Fix isCreate() It was backwards. --- src/View/Form/ArrayContext.php | 2 +- tests/TestCase/View/Form/ArrayContextTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/View/Form/ArrayContext.php b/src/View/Form/ArrayContext.php index db82c6526b8..eb1bb50bede 100644 --- a/src/View/Form/ArrayContext.php +++ b/src/View/Form/ArrayContext.php @@ -121,7 +121,7 @@ public function primaryKey() { public function isCreate() { $primary = $this->primaryKey(); foreach ($primary as $column) { - if (!isset($this->_context['defaults'][$column])) { + if (!empty($this->_context['defaults'][$column])) { return false; } } diff --git a/tests/TestCase/View/Form/ArrayContextTest.php b/tests/TestCase/View/Form/ArrayContextTest.php index db3e114b913..f259a8ebbf3 100644 --- a/tests/TestCase/View/Form/ArrayContextTest.php +++ b/tests/TestCase/View/Form/ArrayContextTest.php @@ -79,11 +79,11 @@ public function testIsCreate() { ], ]; $context = new ArrayContext($this->request, $data); - $this->assertFalse($context->isCreate()); + $this->assertTrue($context->isCreate()); $data['defaults'] = ['id' => 2]; $context = new ArrayContext($this->request, $data); - $this->assertTrue($context->isCreate()); + $this->assertFalse($context->isCreate()); } /**