Fixes useless client helper complexity

This commit is contained in:
Walter Dal Mut
2015-06-23 20:45:31 +02:00
parent 113f1167c3
commit 13a419f4f5
2 changed files with 18 additions and 9 deletions
-9
View File
@@ -52,25 +52,16 @@ class Client
public function getDatabases()
{
if (!($this->getAdapter() instanceOf QueryableInterface)) {
throw new \BadMethodCallException("You can query the database only if the adapter supports it!");
}
return $this->getAdapter()->query("show databases");
}
public function createDatabase($name)
{
if (!($this->getAdapter() instanceOf QueryableInterface)) {
throw new \BadMethodCallException("You can query the database only if the adapter supports it!");
}
return $this->getAdapter()->query("create database \"{$name}\"");
}
public function deleteDatabase($name)
{
if (!($this->getAdapter() instanceOf QueryableInterface)) {
throw new \BadMethodCallException("You can query the database only if the adapter supports it!");
}
return $this->getAdapter()->query("drop database \"{$name}\"");
}
}
+18
View File
@@ -62,4 +62,22 @@ class ClientTest extends \PHPUnit_Framework_TestCase
]
]);
}
/**
* @expectedException BadMethodCallException
*/
public function testNeedWritableInterfaceDuringMark()
{
$client = new Client(new \stdClass());
$client->mark("OK", []);
}
/**
* @expectedException BadMethodCallException
*/
public function testNeedQueryableInterfaceDuringQuery()
{
$client = new Client(new \stdClass());
$client->query("OK", []);
}
}