mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fixes useless client helper complexity
This commit is contained in:
@@ -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}\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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", []);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user