PHP Classes

File: Console/Tests/Command/HelpCommandTest.php

Recommend this page to a friend!
  Classes of Mukhamad Ikhsan   Redmine PHP Console Tools   Console/Tests/Command/HelpCommandTest.php   Download  
File: Console/Tests/Command/HelpCommandTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: Redmine PHP Console Tools
Manage projects hosted in a Redmine installation
Author: By
Last change: Update of Console/Tests/Command/HelpCommandTest.php
Date: 4 months ago
Size: 1,735 bytes
 

Contents

Class file image Download
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Console\Tests\Command;

use
Symfony\Component\Console\Tester\CommandTester;
use
Symfony\Component\Console\Command\HelpCommand;
use
Symfony\Component\Console\Command\ListCommand;
use
Symfony\Component\Console\Application;

class
HelpCommandTest extends \PHPUnit_Framework_TestCase
{
    public function
testExecute()
    {
       
$command = new HelpCommand();

       
$commandTester = new CommandTester($command);
       
$command->setCommand(new ListCommand());
       
$commandTester->execute(array());
       
$this->assertRegExp('/list \[--xml\] \[--raw\] \[namespace\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command');

       
$command->setCommand(new ListCommand());
       
$commandTester->execute(array('--xml' => true));
       
$this->assertRegExp('/<command/', $commandTester->getDisplay(), '->execute() returns an XML help text if --xml is passed');

       
$application = new Application();
       
$commandTester = new CommandTester($application->get('help'));
       
$commandTester->execute(array('command_name' => 'list'));
       
$this->assertRegExp('/list \[--xml\] \[--raw\] \[namespace\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command');

       
$commandTester->execute(array('command_name' => 'list', '--xml' => true));
       
$this->assertRegExp('/<command/', $commandTester->getDisplay(), '->execute() returns an XML help text if --xml is passed');
    }
}