Change Version to non-static

This commit is contained in:
Benoît Burnichon
2015-03-19 11:28:06 +01:00
parent 36a8d555e8
commit 775552f613
10 changed files with 28 additions and 23 deletions

View File

@@ -49,6 +49,7 @@ use Alchemy\Phrasea\SearchEngine\SearchEngineInterface;
require_once __DIR__ . '/../lib/autoload.php';
$version = new Version();
$cli = new CLI("
_____ _ _ _____ _____ ______ _ _ ______ _______
| __ \| | | | __ \ /\ / ____| ____| /\ | \ | | ____|__ __|
@@ -65,7 +66,7 @@ $cli = new CLI("
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions; type `about:license' for details.\n\n"
. ' KONSOLE KOMMANDER', Version::getName() . ' ' . Version::getNumber());
. ' KONSOLE KOMMANDER', $version->getName() . ' ' . $version->getNumber());
if (!$cli['phraseanet.configuration-tester']->isInstalled()) {
throw new \RuntimeException('Phraseanet is not installed, use setup command instead');

View File

@@ -55,6 +55,7 @@ use Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand;
require_once __DIR__ . '/../lib/autoload.php';
$version = new Version();
$cli = new CLI("
___ ___ _ _ ___ __ __ ___ ___ ___ ____ __ __ __ ___
( \( _)( )( )( _)( ) / \( ,\( _)( ,) (_ _)/ \ / \( ) / __)
@@ -65,7 +66,7 @@ $cli = new CLI("
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions; type `about:license' for details.\n\n"
. ' Phraseanet Developer Tools ', Version::getName() . ' ' . Version::getNumber());
. ' Phraseanet Developer Tools ', $version->getName() . ' ' . $version->getNumber());
if ($cli['configuration.store']->isSetup()) {
$helpers = [

View File

@@ -27,6 +27,7 @@ use Alchemy\Phrasea\Core\CLIProvider\DoctrineMigrationServiceProvider;
require_once __DIR__ . '/../vendor/autoload.php';
$version = new Version();
$app = new CLI("
_____ _ _ _____ _____ ______ _ _ ______ _______
| __ \| | | | __ \ /\ / ____| ____| /\ | \ | | ____|__ __|
@@ -45,7 +46,7 @@ $app = new CLI("
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions; type `about:license' for details.\n\n"
. ' SETUP', Version::getName() . ' ' . Version::getNumber());
. ' SETUP', $version->getName() . ' ' . $version->getNumber());
$app->register(new DoctrineMigrationServiceProvider());

View File

@@ -209,10 +209,11 @@ class IniReset extends Command
}
if ($input->getOption('run-patches') || false === $this->container['phraseanet.configuration']->isUpToDate()) {
$version = new Version();
if ($input->getOption('run-patches')) {
$output->write(sprintf('Upgrading... from version <info>3.1.21</info> to <info>%s</info>', Version::getNumber()), true);
$output->write(sprintf('Upgrading... from version <info>3.1.21</info> to <info>%s</info>', $version->getNumber()), true);
} else {
$output->write(sprintf('Upgrading... from version <info>%s</info> to <info>%s</info>', $this->app['phraseanet.appbox']->get_version(), Version::getNumber()), true);
$output->write(sprintf('Upgrading... from version <info>%s</info> to <info>%s</info>', $this->app['phraseanet.appbox']->get_version(), $version->getNumber()), true);
}
$cmd = 'php ' . __DIR__ . '/../../../../../bin/setup system:upgrade -y -f -v';

View File

@@ -13,7 +13,6 @@ namespace Alchemy\Phrasea\Controller\Api;
use Alchemy\Phrasea\Authentication\Context;
use Alchemy\Phrasea\Border\Attribute\Status;
use Alchemy\Phrasea\Border\Checker\CheckerInterface;
use Alchemy\Phrasea\Border\File;
use Alchemy\Phrasea\Border\Manager as BorderManager;
use Alchemy\Phrasea\Border\Manager;

View File

@@ -13,16 +13,16 @@ namespace Alchemy\Phrasea\Core;
class Version
{
protected static $number = '3.9.0-alpha.20';
protected static $name = 'Herrerasaurus';
private $number = '3.9.0-alpha.20';
private $name = 'Herrerasaurus';
public static function getNumber()
public function getNumber()
{
return static::$number;
return $this->number;
}
public static function getName()
public function getName()
{
return static::$name;
return $this->name;
}
}

View File

@@ -38,7 +38,8 @@ class WebhookJob extends AbstractJob
parent::__construct($dispatcher, $logger, $translator);
$this->httpClient = $httpClient ?: new GuzzleClient();
$this->httpClient->setUserAgent(sprintf('Phraseanet/%s (%s)', Version::getNumber(), Version::getName()));
$version = new Version();
$this->httpClient->setUserAgent(sprintf('Phraseanet/%s (%s)', $version->getNumber(), $version->getName()));
}
/**

View File

@@ -60,7 +60,8 @@ class module_console_systemUpgrade extends Command
}
if ($continue == 'y') {
$output->write(sprintf('Upgrading... from version <info>%s</info> to <info>%s</info>', $this->container['phraseanet.appbox']->get_version(), Version::getNumber()), true);
$version = new Version();
$output->write(sprintf('Upgrading... from version <info>%s</info> to <info>%s</info>', $this->container['phraseanet.appbox']->get_version(), $version->getNumber()), true);
try {
$upgrader = new Setup_Upgrade($this->container, $input->getOption('force'));

View File

@@ -4,18 +4,20 @@ namespace Alchemy\Tests\Phrasea\Core;
use Alchemy\Phrasea\Core\Version;
class VersionTest extends \PhraseanetTestCase
class VersionTest extends \PHPUnit_Framework_TestCase
{
public function testGetNumber()
{
$this->assertTrue(is_string(Version::getNumber()));
$this->assertRegExp('/[\d]{1}\.[\d]{1,2}\.[\d]{1,2}/', Version::getNumber());
$version = new Version();
$this->assertTrue(is_string($version->getNumber()));
$this->assertRegExp('/[\d]{1}\.[\d]{1,2}\.[\d]{1,2}/', $version->getNumber());
}
public function testGetName()
{
$this->assertTrue(is_string(Version::getName()));
$this->assertTrue(strlen(Version::getName()) > 3);
$version = new Version();
$this->assertTrue(is_string($version->getName()));
$this->assertTrue(strlen($version->getName()) > 3);
}
}

View File

@@ -90,10 +90,8 @@ class ConfigurationTesterTest extends AbstractSetupTester
->disableOriginalConstructor()
->getMock();
/**
* Must return version + 1
*/
$app['phraseanet.version']::staticExpects($this->any())
// Must return version + 1
$app['phraseanet.version']->expects($this->any())
->method('getNumber')
->will($this->returnValue('3.10'));