Skip to content

Commit

Permalink
Use typehinting instead of throwing exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Mar 30, 2015
1 parent a3bbb12 commit 1bd14ca
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
6 changes: 1 addition & 5 deletions src/ORM/Table.php
Expand Up @@ -393,16 +393,12 @@ public function registryAlias($registryAlias = null)
* @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;
}

Expand Down
13 changes: 0 additions & 13 deletions tests/TestCase/ORM/TableTest.php
Expand Up @@ -185,19 +185,6 @@ public function testConnection()
$this->assertSame($this->connection, $table->connection());
}

/**
* 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
*
Expand Down

0 comments on commit 1bd14ca

Please sign in to comment.