mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
add connection_test tests
This commit is contained in:
@@ -17,6 +17,7 @@ class ControllerConnectionTestTest extends \PhraseanetWebTestCaseAbstract
|
||||
* As controllers use WebTestCase, it requires a client
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* If the controller tests require some records, specify it her
|
||||
*
|
||||
@@ -35,7 +36,7 @@ class ControllerConnectionTestTest extends \PhraseanetWebTestCaseAbstract
|
||||
{
|
||||
return require __DIR__ . '/../../../../../Alchemy/Phrasea/Application/Admin.php';
|
||||
}
|
||||
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -50,12 +51,98 @@ class ControllerConnectionTestTest extends \PhraseanetWebTestCaseAbstract
|
||||
/**
|
||||
* Default route test
|
||||
*/
|
||||
public function testRouteSlash()
|
||||
public function testRouteMysql()
|
||||
{
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
$handler = new \Alchemy\Phrasea\Core\Configuration\Handler(
|
||||
new \Alchemy\Phrasea\Core\Configuration\Application(),
|
||||
new \Alchemy\Phrasea\Core\Configuration\Parser\Yaml()
|
||||
);
|
||||
$configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
|
||||
|
||||
$chooseConnexion = $configuration->getPhraseanet()->get('database');
|
||||
|
||||
$connexion = $configuration->getConnexion($chooseConnexion);
|
||||
|
||||
$params = array(
|
||||
"hostname" => $connexion->get('host'),
|
||||
"port" => $connexion->get('port'),
|
||||
"user" => $connexion->get('user'),
|
||||
"password" => $connexion->get('password'),
|
||||
"dbname" => $connexion->get('dbname')
|
||||
);
|
||||
|
||||
$this->client->request("GET", "/tests/connection/mysql/", $params);
|
||||
$response = $this->client->getResponse();
|
||||
$this->assertTrue($response->isOk());
|
||||
}
|
||||
|
||||
public function testRouteMysqlFailed()
|
||||
{
|
||||
$handler = new \Alchemy\Phrasea\Core\Configuration\Handler(
|
||||
new \Alchemy\Phrasea\Core\Configuration\Application(),
|
||||
new \Alchemy\Phrasea\Core\Configuration\Parser\Yaml()
|
||||
);
|
||||
$configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
|
||||
|
||||
$chooseConnexion = $configuration->getPhraseanet()->get('database');
|
||||
|
||||
$connexion = $configuration->getConnexion($chooseConnexion);
|
||||
|
||||
$params = array(
|
||||
"hostname" => $connexion->get('host'),
|
||||
"port" => $connexion->get('port'),
|
||||
"user" => $connexion->get('user'),
|
||||
"password" => "fakepassword",
|
||||
"dbname" => $connexion->get('dbname')
|
||||
);
|
||||
|
||||
$this->client->request("GET", "/tests/connection/mysql/", $params);
|
||||
$response = $this->client->getResponse();
|
||||
$content = json_decode($this->client->getResponse()->getContent());
|
||||
$this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type"));
|
||||
$this->assertTrue($response->isOk());
|
||||
$this->assertTrue(is_object($content));
|
||||
$this->assertObjectHasAttribute('connection', $content);
|
||||
$this->assertObjectHasAttribute('database', $content);
|
||||
$this->assertObjectHasAttribute('is_empty', $content);
|
||||
$this->assertObjectHasAttribute('is_appbox', $content);
|
||||
$this->assertObjectHasAttribute('is_databox', $content);
|
||||
$this->assertFalse($content->connection);
|
||||
}
|
||||
|
||||
public function testRouteMysqlDbFailed()
|
||||
{
|
||||
$handler = new \Alchemy\Phrasea\Core\Configuration\Handler(
|
||||
new \Alchemy\Phrasea\Core\Configuration\Application(),
|
||||
new \Alchemy\Phrasea\Core\Configuration\Parser\Yaml()
|
||||
);
|
||||
$configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
|
||||
|
||||
$chooseConnexion = $configuration->getPhraseanet()->get('database');
|
||||
|
||||
$connexion = $configuration->getConnexion($chooseConnexion);
|
||||
|
||||
$params = array(
|
||||
"hostname" => $connexion->get('host'),
|
||||
"port" => $connexion->get('port'),
|
||||
"user" => $connexion->get('user'),
|
||||
"password" => $connexion->get('password'),
|
||||
"dbname" => "fake-DTABASE-name"
|
||||
);
|
||||
|
||||
$this->client->request("GET", "/tests/connection/mysql/", $params);
|
||||
$response = $this->client->getResponse();
|
||||
$content = json_decode($this->client->getResponse()->getContent());
|
||||
$this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type"));
|
||||
$this->assertTrue($response->isOk());
|
||||
$this->assertTrue(is_object($content));
|
||||
$this->assertObjectHasAttribute('connection', $content);
|
||||
$this->assertObjectHasAttribute('database', $content);
|
||||
$this->assertObjectHasAttribute('is_empty', $content);
|
||||
$this->assertObjectHasAttribute('is_appbox', $content);
|
||||
$this->assertObjectHasAttribute('is_databox', $content);
|
||||
$this->assertFalse($content->database);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user