Merge pull request #3264 from duncan3dc/remove-self-update-warning
Don't display the dev warning time when running self-updatepull/3178/merge
commit
96955dd23b
|
@ -94,9 +94,17 @@ class Application extends BaseApplication
|
||||||
$output->writeln('<warning>Composer only officially supports PHP 5.3.2 and above, you will most likely encounter problems with your PHP '.PHP_VERSION.', upgrading is strongly recommended.</warning>');
|
$output->writeln('<warning>Composer only officially supports PHP 5.3.2 and above, you will most likely encounter problems with your PHP '.PHP_VERSION.', upgrading is strongly recommended.</warning>');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined('COMPOSER_DEV_WARNING_TIME') && $this->getCommandName($input) !== 'self-update' && $this->getCommandName($input) !== 'selfupdate') {
|
if (defined('COMPOSER_DEV_WARNING_TIME')) {
|
||||||
if (time() > COMPOSER_DEV_WARNING_TIME) {
|
$commandName = '';
|
||||||
$output->writeln(sprintf('<warning>Warning: This development build of composer is over 30 days old. It is recommended to update it by running "%s self-update" to get the latest version.</warning>', $_SERVER['PHP_SELF']));
|
if ($name = $this->getCommandName($input)) {
|
||||||
|
try {
|
||||||
|
$commandName = $this->find($name)->getName();
|
||||||
|
} catch (\InvalidArgumentException $e) {}
|
||||||
|
}
|
||||||
|
if ($commandName !== 'self-update' && $commandName !== 'selfupdate') {
|
||||||
|
if (time() > COMPOSER_DEV_WARNING_TIME) {
|
||||||
|
$output->writeln(sprintf('<warning>Warning: This development build of composer is over 30 days old. It is recommended to update it by running "%s self-update" to get the latest version.</warning>', $_SERVER['PHP_SELF']));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Composer.
|
||||||
|
*
|
||||||
|
* (c) Nils Adermann <naderman@naderman.de>
|
||||||
|
* Jordi Boggiano <j.boggiano@seld.be>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Composer\Test;
|
||||||
|
|
||||||
|
use Composer\Console\Application;
|
||||||
|
use Composer\TestCase;
|
||||||
|
|
||||||
|
class ApplicationTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testDevWarning()
|
||||||
|
{
|
||||||
|
$application = new Application;
|
||||||
|
|
||||||
|
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
||||||
|
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
|
||||||
|
|
||||||
|
$inputMock->expects($this->once())
|
||||||
|
->method('getFirstArgument')
|
||||||
|
->will($this->returnValue('list'));
|
||||||
|
|
||||||
|
$outputMock->expects($this->once())
|
||||||
|
->method("writeln")
|
||||||
|
->with($this->equalTo(sprintf('<warning>Warning: This development build of composer is over 30 days old. It is recommended to update it by running "%s self-update" to get the latest version.</warning>', $_SERVER['PHP_SELF'])));
|
||||||
|
|
||||||
|
if (!defined('COMPOSER_DEV_WARNING_TIME')) {
|
||||||
|
define('COMPOSER_DEV_WARNING_TIME', time() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->setExpectedException('RuntimeException');
|
||||||
|
$application->doRun($inputMock, $outputMock);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function ensureNoDevWarning($command)
|
||||||
|
{
|
||||||
|
$application = new Application;
|
||||||
|
|
||||||
|
$application->add(new \Composer\Command\SelfUpdateCommand);
|
||||||
|
|
||||||
|
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
||||||
|
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
|
||||||
|
|
||||||
|
$inputMock->expects($this->once())
|
||||||
|
->method('getFirstArgument')
|
||||||
|
->will($this->returnValue($command));
|
||||||
|
|
||||||
|
$outputMock->expects($this->never())
|
||||||
|
->method("writeln");
|
||||||
|
|
||||||
|
if (!defined('COMPOSER_DEV_WARNING_TIME')) {
|
||||||
|
define('COMPOSER_DEV_WARNING_TIME', time() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->setExpectedException('RuntimeException');
|
||||||
|
$application->doRun($inputMock, $outputMock);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDevWarningPrevented()
|
||||||
|
{
|
||||||
|
$this->ensureNoDevWarning('self-update');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDevWarningPreventedAlias()
|
||||||
|
{
|
||||||
|
$this->ensureNoDevWarning('self-up');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue