Merge pull request #641 from romainneutron/upgrade-instructions

[3.8] Remove infinite redirection, add upgrade instructions
This commit is contained in:
Romain Neutron
2013-09-17 08:06:48 -07:00
4 changed files with 75 additions and 1 deletions

View File

@@ -31,7 +31,13 @@ return call_user_func(function($environment = PhraseaApplication::ENV_PROD) {
$app->before(function (Request $request) use ($app) {
if (0 === strpos($request->getPathInfo(), '/setup')) {
if (!$app['phraseanet.configuration-tester']->isInstalled()) {
if (!$app['phraseanet.configuration-tester']->isBlank()) {
if ('setup_upgrade_instructions' !== $app['request']->attributes->get('_route')) {
return $app->redirectPath('setup_upgrade_instructions');
}
}
} elseif (!$app['phraseanet.configuration-tester']->isBlank()) {
return $app->redirectPath('homepage');
}
} else {

View File

@@ -37,6 +37,9 @@ class Setup implements ControllerProviderInterface
$controllers->get('/installer/', 'controller.setup:rootInstaller')
->bind('install_root');
$controllers->get('/upgrade-instructions/', 'controller.setup:displayUpgradeInstructions')
->bind('setup_upgrade_instructions');
$controllers->get('/installer/step2/', 'controller.setup:getInstallForm')
->bind('install_step2');
@@ -70,6 +73,14 @@ class Setup implements ControllerProviderInterface
);
}
public function displayUpgradeInstructions(Application $app, Request $request)
{
return $app['twig']->render('/setup/upgrade-instructions.html.twig', array(
'locale' => $app['locale'],
'available_locales' => Application::getAvailableLanguages(),
));
}
public function getInstallForm(Application $app, Request $request)
{
$warnings = array();

View File

@@ -0,0 +1,38 @@
{% extends '/setup/wrapper.html.twig' %}
{% block content %}
<div class="steps" style="min-height:450px;">
<table style="width:100%;">
<tr>
<td>
<div style="height:400px;overflow:auto;">
<h2>
Upgrade Instructions
</h2>
<p>
This Phraseanet install requires an upgrade.
</p>
<table style="width:100%;margin-top:60px;">
<tr>
<td colspan="2">
Please run the following command at your application install root.
<code>
bin/setup system:upgrade
</code>
</td>
</tr>
</table>
</div>
<div>
<table style="width:100%;">
<tr>
<td style="text-align:right;">
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
{% endblock %}

View File

@@ -39,6 +39,9 @@ class SetupTest extends \Silex\WebTestCase
public function testRouteSlashWhenInstalled()
{
$this->app['phraseanet.configuration-tester']->expects($this->once())
->method('isInstalled')
->will($this->returnValue(true));
$this->app['phraseanet.configuration-tester']->expects($this->once())
->method('isBlank')
->will($this->returnValue(false));
@@ -50,6 +53,22 @@ class SetupTest extends \Silex\WebTestCase
$this->assertEquals('/login/', $response->headers->get('location'));
}
public function testRouteInstructionsWhenUpgradeRequired()
{
$this->app['phraseanet.configuration-tester']->expects($this->once())
->method('isInstalled')
->will($this->returnValue(false));
$this->app['phraseanet.configuration-tester']->expects($this->once())
->method('isBlank')
->will($this->returnValue(false));
$client = $this->createClient();
$crawler = $client->request('GET', '/setup/');
$response = $client->getResponse();
$this->assertEquals(302, $response->getStatusCode());
$this->assertEquals('/setup/upgrade-instructions/', $response->headers->get('location'));
}
public function testRouteSetupInstaller()
{
$client = $this->createClient();