mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-19 07:53:14 +00:00
[SearchEngine] Add SearchEngine admin panel tests
This commit is contained in:
44
tests/Alchemy/Phrasea/Controller/Admin/SearchEngineTest.php
Normal file
44
tests/Alchemy/Phrasea/Controller/Admin/SearchEngineTest.php
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Application;
|
||||||
|
use Alchemy\Phrasea\SearchEngine\Phrasea\PhraseaEngine;
|
||||||
|
use Alchemy\Phrasea\SearchEngine\SphinxSearch\SphinxSearchEngine;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
|
||||||
|
|
||||||
|
class SearchEngineTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider getSearchEngines
|
||||||
|
*/
|
||||||
|
public function testGetConfiguration($searchEngine)
|
||||||
|
{
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $searchEngine;
|
||||||
|
|
||||||
|
self::$DI['client']->request('GET', '/admin/search-engine/');
|
||||||
|
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider getSearchEngines
|
||||||
|
*/
|
||||||
|
public function testPostConfiguration($searchEngine)
|
||||||
|
{
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $searchEngine;
|
||||||
|
|
||||||
|
self::$DI['client']->request('POST', '/admin/search-engine/');
|
||||||
|
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSearchEngines()
|
||||||
|
{
|
||||||
|
$app = new Application('test');
|
||||||
|
|
||||||
|
return array(
|
||||||
|
array(new PhraseaEngine($app)),
|
||||||
|
array(new SphinxSearchEngine($app, 'localhost', 9306, 'localhost', 9308)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -1,43 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
|
|
||||||
|
|
||||||
class SphinxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|
||||||
{
|
|
||||||
protected $client;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Controller\Admin\Sphinx::getConfiguration
|
|
||||||
* @covers Alchemy\Phrasea\Controller\Admin\Sphinx::connect
|
|
||||||
*/
|
|
||||||
public function testGetConfiguration()
|
|
||||||
{
|
|
||||||
$this->setAdmin(true);
|
|
||||||
|
|
||||||
self::$DI['client']->request('GET', '/admin/sphinx/configuration/');
|
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Controller\Admin\Sphinx::getConfiguration
|
|
||||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
|
||||||
*/
|
|
||||||
public function testGetConfigurationUnauthorizedException()
|
|
||||||
{
|
|
||||||
$this->setAdmin(false);
|
|
||||||
|
|
||||||
self::$DI['client']->request('GET', '/admin/sphinx/configuration/');
|
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Controller\Admin\Sphinx::submitConfiguration
|
|
||||||
*/
|
|
||||||
public function testPostConfiguration()
|
|
||||||
{
|
|
||||||
$this->setAdmin(true);
|
|
||||||
|
|
||||||
self::$DI['client']->request('POST', '/admin/sphinx/configuration/');
|
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user