Esempio n. 1
0
 public function testConstructor()
 {
     $argument = new InputArgument('foo');
     $this->assertEquals($argument->getName(), 'foo', '__construct() takes a name as its first argument');
     // mode argument
     $argument = new InputArgument('foo');
     $this->assertEquals($argument->isRequired(), false, '__construct() gives a "Argument::OPTIONAL" mode by default');
     $argument = new InputArgument('foo', null);
     $this->assertEquals($argument->isRequired(), false, '__construct() can take "Argument::OPTIONAL" as its mode');
     $argument = new InputArgument('foo', InputArgument::OPTIONAL);
     $this->assertEquals($argument->isRequired(), false, '__construct() can take "Argument::PARAMETER_OPTIONAL" as its mode');
     $argument = new InputArgument('foo', InputArgument::REQUIRED);
     $this->assertEquals($argument->isRequired(), true, '__construct() can take "Argument::PARAMETER_REQUIRED" as its mode');
     try {
         $argument = new InputArgument('foo', 'ANOTHER_ONE');
         $this->fail('__construct() throws an Exception if the mode is not valid');
     } catch (\Exception $e) {
     }
 }
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

require_once __DIR__.'/../../../../bootstrap.php';

use Symfony\Components\Console\Input\InputArgument;
use Symfony\Components\Console\Exception;

$t = new LimeTest(16);

// __construct()
$t->diag('__construct()');
$argument = new InputArgument('foo');
$t->is($argument->getName(), 'foo', '__construct() takes a name as its first argument');

// mode argument
$argument = new InputArgument('foo');
$t->is($argument->isRequired(), false, '__construct() gives a "Argument::OPTIONAL" mode by default');

$argument = new InputArgument('foo', null);
$t->is($argument->isRequired(), false, '__construct() can take "Argument::OPTIONAL" as its mode');

$argument = new InputArgument('foo', InputArgument::OPTIONAL);
$t->is($argument->isRequired(), false, '__construct() can take "Argument::PARAMETER_OPTIONAL" as its mode');

$argument = new InputArgument('foo', InputArgument::REQUIRED);
$t->is($argument->isRequired(), true, '__construct() can take "Argument::PARAMETER_REQUIRED" as its mode');

try