Browse Source

Use typehinting instead of throwing exception.

ADmad 11 years ago
parent
commit
1bd14cae10
2 changed files with 1 additions and 18 deletions
  1. 1 5
      src/ORM/Table.php
  2. 0 13
      tests/TestCase/ORM/TableTest.php

+ 1 - 5
src/ORM/Table.php

@@ -393,16 +393,12 @@ class Table implements RepositoryInterface, EventListenerInterface
      * @param \Cake\Database\Connection|null $conn The new connection instance
      * @return \Cake\Database\Connection
      */
-    public function connection($conn = null)
+    public function connection(Connection $conn = null)
     {
         if ($conn === null) {
             return $this->_connection;
         }
 
-        if (!($conn instanceof Connection)) {
-            throw new RuntimeException('$conn must be an instance of \Cake\Database\Connection');
-        }
-
         return $this->_connection = $conn;
     }
 

+ 0 - 13
tests/TestCase/ORM/TableTest.php

@@ -186,19 +186,6 @@ class TableTest extends TestCase
     }
 
     /**
-     * Tests exception is thrown in connection is not instance of
-     * \Cake\Database\Connection
-     *
-     * @expectedException \RuntimeException
-     * @expectedExceptionMessage $conn must be an instance of \Cake\Database\Connection
-     * @return void
-     */
-    public function testConnectionException()
-    {
-        $table = new Table(['table' => 'users', 'connection' => 'default']);
-    }
-
-    /**
      * Tests primaryKey method
      *
      * @return void