mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
Add setup tests
Fix setup process
This commit is contained in:
7
hudson/InstallDBs.yml
Normal file
7
hudson/InstallDBs.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
database:
|
||||
host: localhost
|
||||
port: port
|
||||
user: phraseaUnitTests
|
||||
password: iWvGxPE8
|
||||
applicationBox: ab_unitTests
|
||||
dataBox: db_unitTests
|
@@ -263,9 +263,13 @@ class Installer implements ControllerProviderInterface
|
||||
|
||||
$user = \User_Adapter::create($appbox, $request->get('email'), $request->get('password'), $request->get('email'), true);
|
||||
|
||||
if (!\p4string::hasAccent($databox_name))
|
||||
{
|
||||
if ($databox_name)
|
||||
\phrasea::start($app['Core']);
|
||||
|
||||
$auth = new \Session_Authentication_None($user);
|
||||
|
||||
$appbox->get_session()->authenticate($auth);
|
||||
|
||||
if ($databox_name && !\p4string::hasAccent($databox_name))
|
||||
{
|
||||
$template = new \system_file(__DIR__ . '/../../../../conf.d/data_templates/' . $request->get('db_template') . '.xml');
|
||||
$databox = \databox::create($appbox, $connbas, $template, $registry);
|
||||
@@ -330,13 +334,6 @@ class Installer implements ControllerProviderInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\phrasea::start($app['Core']);
|
||||
|
||||
$auth = new \Session_Authentication_None($user);
|
||||
|
||||
$appbox->get_session()->authenticate($auth);
|
||||
|
||||
$redirection = '/admin/?section=taskmanager¬ice=install_success';
|
||||
|
||||
|
@@ -162,6 +162,19 @@ abstract class base implements cache_cacheableInterface
|
||||
return $this->connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the connection
|
||||
*
|
||||
* @param \connection_pdo $connection
|
||||
* @return \base
|
||||
*/
|
||||
public function set_connection(\connection_pdo $connection)
|
||||
{
|
||||
$this->connection = $connection;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get_cache()
|
||||
{
|
||||
if (!$this->cache)
|
||||
|
@@ -121,7 +121,7 @@ class phrasea
|
||||
printf("Missing Extension php-phrasea");
|
||||
|
||||
if (function_exists('phrasea_conn'))
|
||||
if (phrasea_conn($hostname, $port, $user, $password, $dbname) !== true)
|
||||
if (phrasea_conn($hostname, (int) $port, $user, $password, $dbname) !== true)
|
||||
self::headers(500);
|
||||
}
|
||||
|
||||
|
@@ -1,17 +1,16 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
|
||||
|
||||
require_once __DIR__ . '/../../../../Alchemy/Phrasea/Application/Setup.php';
|
||||
require_once __DIR__ . '/../../../PhraseanetWebTestCaseAbstract.class.inc';
|
||||
|
||||
use Silex\WebTestCase;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class ApplicationSetupTest extends PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
class ApplicationSetupTest extends PhraseanetWebTestCaseAbstract
|
||||
{
|
||||
|
||||
protected $client;
|
||||
protected static $need_records = false;
|
||||
protected $root;
|
||||
protected $appbox;
|
||||
protected $connection;
|
||||
|
||||
public function createApplication()
|
||||
{
|
||||
@@ -21,15 +20,142 @@ class ApplicationSetupTest extends PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->root = __DIR__ . '/../../../../../';
|
||||
$this->client = $this->createClient();
|
||||
$this->temporaryUnInstall();
|
||||
$this->appbox = appbox::get_instance(\bootstrap::getCore());
|
||||
$this->connection = $this->appbox->get_connection();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
$this->temporaryReInstall();
|
||||
$this->appbox->set_connection($this->connection);
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Setup\Installer::connect
|
||||
*/
|
||||
public function testRouteSlash()
|
||||
{
|
||||
$crawler = $this->client->request('GET', '/');
|
||||
$response = $this->client->getResponse();
|
||||
$this->assertEquals(302, $response->getStatusCode());
|
||||
$this->assertEquals('/setup/installer/', $response->headers->get('location'));
|
||||
|
||||
$this->temporaryReInstall();
|
||||
|
||||
$crawler = $this->client->request('GET', '/');
|
||||
$response = $this->client->getResponse();
|
||||
$this->assertEquals(302, $response->getStatusCode());
|
||||
$this->assertEquals('/login/', $response->headers->get('location'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Setup\Installer::connect
|
||||
*/
|
||||
public function testRouteSetupInstaller()
|
||||
{
|
||||
$crawler = $this->client->request('GET', '/installer/');
|
||||
$response = $this->client->getResponse();
|
||||
$this->assertEquals(302, $response->getStatusCode());
|
||||
$this->assertEquals('/setup/installer/step2/', $response->headers->get('location'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Setup\Installer::connect
|
||||
*/
|
||||
public function testRouteSetupInstallerStep2()
|
||||
{
|
||||
$crawler = $this->client->request('GET', '/installer/step2/');
|
||||
$response = $this->client->getResponse();
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Setup\Installer::connect
|
||||
*/
|
||||
public function testRouteSetupInstallerInstall()
|
||||
{
|
||||
|
||||
$settings = Symfony\Component\Yaml\Yaml::parse(file_get_contents($this->root . 'hudson/InstallDBs.yml'));
|
||||
|
||||
$settings = $settings['database'];
|
||||
|
||||
$host = isset($settings['host']) ? $settings['host'] : 'localhost';
|
||||
$port = isset($settings['port']) ? $settings['port'] : '3306';
|
||||
$MySQLuser = isset($settings['user']) ? $settings['user'] : 'root';
|
||||
$MySQLpassword = isset($settings['password']) ? $settings['password'] : '';
|
||||
$abName = isset($settings['applicationBox']) ? $settings['applicationBox'] : null;
|
||||
$dbName = isset($settings['dataBox']) ? $settings['dataBox'] : null;
|
||||
|
||||
|
||||
$connection = new connection_pdo('unitTestsAB', $host, $port, $MySQLuser, $MySQLpassword, $abName);
|
||||
|
||||
$this->appbox->set_connection($connection);
|
||||
|
||||
$dataDir = sys_get_temp_dir() . '/datainstall/';
|
||||
|
||||
$params = array(
|
||||
'email' => 'user@example.org',
|
||||
'password' => 'prètty%%password',
|
||||
'binary_xpdf' => '/path/to/xpdf',
|
||||
'binary_mplayer' => '/path/to/mplayer',
|
||||
'binary_MP4Box' => '/path/to/MP4Box',
|
||||
'binary_ffmpeg' => '/path/to/ffmpeg',
|
||||
'binary_unoconv' => '/path/to/unoconv',
|
||||
'binary_swfrender' => '/path/to/swfrender',
|
||||
'binary_pdf2swf' => '/path/to/pdf2swf',
|
||||
'binary_swfextract' => '/path/to/swfextract',
|
||||
'binary_exiftool' => '/path/to/exiftool',
|
||||
'binary_composite' => '/path/to/composite',
|
||||
'binary_convert' => '/path/to/convert',
|
||||
'binary_php' => '/path/to/php',
|
||||
'mount_point_web' => 'web',
|
||||
'datapath_web' => $dataDir . 'web',
|
||||
'datapath_noweb' => $dataDir . 'noweb',
|
||||
'ab_hostname' => $host,
|
||||
'ab_port' => $port,
|
||||
'ab_user' => $MySQLuser,
|
||||
'ab_password' => $MySQLpassword,
|
||||
'ab_name' => $abName,
|
||||
'db_name' => $dbName,
|
||||
'db_template' => 'en-simple',
|
||||
'create_task' => array(),
|
||||
'binary_phraseanet_indexer' => '/path/to/phraseanet_indexer',
|
||||
);
|
||||
|
||||
$crawler = $this->client->request('POST', '/installer/install/', $params);
|
||||
$response = $this->client->getResponse();
|
||||
|
||||
$this->assertEquals(302, $response->getStatusCode());
|
||||
$this->assertTrue(false === strpos($response->headers->get('location'), '/setup/installer/'));
|
||||
}
|
||||
|
||||
public function temporaryUnInstall()
|
||||
{
|
||||
if (file_exists($this->root . 'config/config.yml')) {
|
||||
rename($this->root . 'config/config.yml', $this->root . 'config/config.yml.unitTests');
|
||||
}
|
||||
if (file_exists($this->root . 'config/services.yml')) {
|
||||
rename($this->root . 'config/services.yml', $this->root . 'config/services.yml.unitTests');
|
||||
}
|
||||
if (file_exists($this->root . 'config/connexions.yml')) {
|
||||
rename($this->root . 'config/connexions.yml', $this->root . 'config/connexions.yml.unitTests');
|
||||
}
|
||||
}
|
||||
|
||||
public function temporaryReInstall()
|
||||
{
|
||||
if (file_exists($this->root . 'config/config.yml.unitTests')) {
|
||||
rename($this->root . 'config/config.yml.unitTests', $this->root . 'config/config.yml');
|
||||
}
|
||||
if (file_exists($this->root . 'config/services.yml.unitTests')) {
|
||||
rename($this->root . 'config/services.yml.unitTests', $this->root . 'config/services.yml');
|
||||
}
|
||||
if (file_exists($this->root . 'config/connexions.yml.unitTests')) {
|
||||
rename($this->root . 'config/connexions.yml.unitTests', $this->root . 'config/connexions.yml');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user