2022-02-23 15:58:18 +00:00
< ? php declare ( strict_types = 1 );
2014-09-08 18:24:04 +00:00
/*
* 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 ;
2022-05-11 14:25:24 +00:00
use Composer\Util\Platform ;
2021-04-13 07:59:06 +00:00
use Composer\XdebugHandler\XdebugHandler ;
2022-05-11 14:25:24 +00:00
use Symfony\Component\Console\Input\ArrayInput ;
2021-12-09 16:09:07 +00:00
use Symfony\Component\Console\Output\BufferedOutput ;
2014-09-08 18:24:04 +00:00
class ApplicationTest extends TestCase
{
2021-12-09 16:09:07 +00:00
protected function tearDown () : void
2021-06-03 08:17:54 +00:00
{
parent :: tearDown ();
2022-05-11 14:25:24 +00:00
Platform :: clearEnv ( 'COMPOSER_DISABLE_XDEBUG_WARN' );
2021-06-03 08:17:54 +00:00
}
2022-05-11 14:25:24 +00:00
protected function setUp () : void
2014-09-08 18:24:04 +00:00
{
2022-05-11 14:25:24 +00:00
parent :: setUp ();
2014-09-08 18:24:04 +00:00
2022-05-11 14:25:24 +00:00
Platform :: putEnv ( 'COMPOSER_DISABLE_XDEBUG_WARN' , '1' );
}
2015-11-19 17:36:52 +00:00
2022-05-11 14:25:24 +00:00
/**
* @ runInSeparateProcess
* @ preserveGlobalState disabled
*/
public function testDevWarning () : void
{
$application = new Application ;
2014-09-08 18:24:04 +00:00
if ( ! defined ( 'COMPOSER_DEV_WARNING_TIME' )) {
define ( 'COMPOSER_DEV_WARNING_TIME' , time () - 1 );
}
2022-05-11 14:25:24 +00:00
$output = new BufferedOutput ();
$application -> doRun ( new ArrayInput ([ 'command' => 'about' ]), $output );
2021-12-09 16:09:07 +00:00
2022-05-11 14:25:24 +00:00
$expectedOutput = sprintf ( '<warning>Warning: This development build of Composer is over 60 days old. It is recommended to update it by running "%s self-update" to get the latest version.</warning>' , $_SERVER [ 'PHP_SELF' ]) . PHP_EOL ;
2021-12-09 16:09:07 +00:00
$this -> assertStringContainsString ( $expectedOutput , $output -> fetch ());
2014-09-08 18:24:04 +00:00
}
2021-11-02 13:32:09 +00:00
/**
2022-05-11 14:25:24 +00:00
* @ runInSeparateProcess
* @ preserveGlobalState disabled
2021-11-02 13:32:09 +00:00
*/
2022-05-11 14:25:24 +00:00
public function testDevWarningSuppressedForSelfUpdate () : void
2014-09-08 18:24:04 +00:00
{
2022-05-11 14:52:58 +00:00
if ( Platform :: isWindows ()) {
$this -> markTestSkipped ( 'Does not run on windows' );
}
2014-09-08 18:24:04 +00:00
$application = new Application ;
$application -> add ( new \Composer\Command\SelfUpdateCommand );
if ( ! defined ( 'COMPOSER_DEV_WARNING_TIME' )) {
define ( 'COMPOSER_DEV_WARNING_TIME' , time () - 1 );
}
2022-05-11 14:25:24 +00:00
$output = new BufferedOutput ();
$application -> doRun ( new ArrayInput ([ 'command' => 'self-update' ]), $output );
2014-09-08 18:24:04 +00:00
2022-05-11 14:25:24 +00:00
$this -> assertSame ( '' , $output -> fetch ());
2014-09-08 18:24:04 +00:00
}
}