From 8b3676974e2ef57da8c4389fb5abb00f8f9a8689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Mon, 25 Apr 2016 23:23:13 +0200 Subject: [PATCH] Removing the useless string callback from the findOrCreate --- src/ORM/Table.php | 6 ------ tests/TestCase/ORM/TableTest.php | 11 ----------- 2 files changed, 17 deletions(-) diff --git a/src/ORM/Table.php b/src/ORM/Table.php index 0705acac55a..029e54f4bd3 100644 --- a/src/ORM/Table.php +++ b/src/ORM/Table.php @@ -1245,12 +1245,6 @@ protected function _getFindOrCreateQuery($search) if ($search instanceof Query) { return $search; } - if (is_string($search)) { - if (method_exists($this, $search)) { - return $this->{$search}(); - } - throw new InvalidArgumentException('Method `' . $search . '` does not exist!'); - } return $this->find()->where($search); } diff --git a/tests/TestCase/ORM/TableTest.php b/tests/TestCase/ORM/TableTest.php index 1be756960bd..e608354473f 100644 --- a/tests/TestCase/ORM/TableTest.php +++ b/tests/TestCase/ORM/TableTest.php @@ -5390,17 +5390,6 @@ function ($article) { $this->assertEquals(2, $article->author_id); } - /** - * Test that exceptions from the findOrCreate are thrown. - * - * @expectedException \InvalidArgumentException - */ - public function testFindOrCreateException() - { - $articles = TableRegistry::get('Articles'); - $articles->findOrCreate('doesNotExist'); - } - /** * Test that creating a table fires the initialize event. *