Add init command

This commit is contained in:
Nicolas Le Goff
2014-07-25 14:35:23 +02:00
parent 26190331ed
commit 9e2083dfe4
13 changed files with 297 additions and 111 deletions

View File

@@ -41,10 +41,10 @@ class SetupTest extends \Silex\WebTestCase
public function testRouteSlashWhenInstalled()
{
$this->app['phraseanet.configuration-tester']->expects($this->once())
$this->app['phraseanet.configuration-tester']->expects($this->any())
->method('isInstalled')
->will($this->returnValue(true));
$this->app['phraseanet.configuration-tester']->expects($this->once())
$this->app['phraseanet.configuration-tester']->expects($this->any())
->method('isBlank')
->will($this->returnValue(false));
@@ -57,10 +57,10 @@ class SetupTest extends \Silex\WebTestCase
public function testRouteInstructionsWhenUpgradeRequired()
{
$this->app['phraseanet.configuration-tester']->expects($this->once())
$this->app['phraseanet.configuration-tester']->expects($this->any())
->method('isInstalled')
->will($this->returnValue(false));
$this->app['phraseanet.configuration-tester']->expects($this->once())
$this->app['phraseanet.configuration-tester']->expects($this->any())
->method('isBlank')
->will($this->returnValue(false));
@@ -75,7 +75,7 @@ class SetupTest extends \Silex\WebTestCase
{
$client = $this->createClient();
$this->app['phraseanet.configuration-tester']->expects($this->once())
$this->app['phraseanet.configuration-tester']->expects($this->any())
->method('isBlank')
->will($this->returnValue(true));
@@ -88,7 +88,7 @@ class SetupTest extends \Silex\WebTestCase
{
$client = $this->createClient();
$this->app['phraseanet.configuration-tester']->expects($this->once())
$this->app['phraseanet.configuration-tester']->expects($this->any())
->method('isBlank')
->will($this->returnValue(true));
@@ -111,37 +111,32 @@ class SetupTest extends \Silex\WebTestCase
->disableOriginalConstructor()
->getMock();
$user->expects($this->exactly(2))
->method('get_id')
->will($this->returnValue(4));
$acl = $this->getMockBuilder('ACL')
->disableOriginalConstructor()
->getMock();
$acl->expects($this->once())
->method('get_granted_sbas')
->will($this->returnValue(array()));
$user->expects($this->once())
->method('ACL')
->will($this->returnValue($acl));
$this->app['phraseanet.installer']->expects($this->once())
->method('install')
->will($this->returnValue($user));
$authenticator = $this->getMockBuilder('Alchemy\Phrasea\Authentication\Authenticator')
->disableOriginalConstructor()
->getMock();
$session = $this->getMock('Entities\Session');
$authenticator->expects($this->once())
->method('openAccount')
->with($this->equalTo($user))
->will($this->returnValue($session));
$this->app['authentication'] = $authenticator;
$client = $this->createClient();
$settings = Yaml::parse(file_get_contents(__DIR__ . '/../../../../../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;
$dataDir = sys_get_temp_dir() . '/datainstall/';
$user = isset($settings['user']) ? $settings['user'] : 'root';
$password = isset($settings['password']) ? $settings['password'] : '';
$abName = isset($settings['ab_name']) ? $settings['ab_name'] : null;
$dbName = isset($settings['db_name']) ? $settings['db_name'] : null;
$params = array(
'email' => 'user@example.org',
@@ -158,23 +153,22 @@ class SetupTest extends \Silex\WebTestCase
'binary_composite' => '/path/to/composite',
'binary_convert' => '/path/to/convert',
'binary_php' => '/path/to/php',
'datapath_noweb' => $dataDir . 'noweb',
'datapath_noweb' => sys_get_temp_dir() . '/datainstall/noweb',
'ab_hostname' => $host,
'ab_port' => $port,
'ab_user' => $MySQLuser,
'ab_password' => $MySQLpassword,
'ab_user' => $user,
'ab_password' => $password,
'ab_name' => $abName,
'db_name' => $dbName,
'db_template' => 'en-simple',
'db_template' => 'en',
'create_task' => array(),
'binary_phraseanet_indexer' => '/path/to/phraseanet_indexer',
);
$crawler = $client->request('POST', '/setup/installer/install/', $params);
$client->request('POST', '/setup/installer/install/', $params);
$response = $client->getResponse();
$this->assertEquals(302, $response->getStatusCode());
$this->assertTrue(false === strpos($response->headers->get('location'), '/setup/installer/'));
$this->assertTrue(false === strpos($response->headers->get('location'), '/setup/installer/'), $response);
}
public function testSetupProvidesPathTest()