|
@@ -29,18 +29,52 @@ class ConsoleOptionParserTest extends TestCase
|
|
|
/**
|
|
/**
|
|
|
* test setting the console description
|
|
* test setting the console description
|
|
|
*
|
|
*
|
|
|
|
|
+ * @group deprecated
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ */
|
|
|
|
|
+ public function testDescriptionDeprecated()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->deprecated(function() {
|
|
|
|
|
+ $parser = new ConsoleOptionParser('test', false);
|
|
|
|
|
+ $result = $parser->description('A test');
|
|
|
|
|
+
|
|
|
|
|
+ $this->assertEquals($parser, $result, 'Setting description is not chainable');
|
|
|
|
|
+ $this->assertEquals('A test', $parser->description(), 'getting value is wrong.');
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * test setting the console description
|
|
|
|
|
+ *
|
|
|
* @return void
|
|
* @return void
|
|
|
*/
|
|
*/
|
|
|
public function testDescription()
|
|
public function testDescription()
|
|
|
{
|
|
{
|
|
|
$parser = new ConsoleOptionParser('test', false);
|
|
$parser = new ConsoleOptionParser('test', false);
|
|
|
- $result = $parser->description('A test');
|
|
|
|
|
|
|
+ $result = $parser->setDescription('A test');
|
|
|
|
|
|
|
|
$this->assertEquals($parser, $result, 'Setting description is not chainable');
|
|
$this->assertEquals($parser, $result, 'Setting description is not chainable');
|
|
|
- $this->assertEquals('A test', $parser->description(), 'getting value is wrong.');
|
|
|
|
|
|
|
+ $this->assertEquals('A test', $parser->getDescription(), 'getting value is wrong.');
|
|
|
|
|
+
|
|
|
|
|
+ $result = $parser->setDescription(['A test', 'something']);
|
|
|
|
|
+ $this->assertEquals("A test\nsomething", $parser->getDescription(), 'getting value is wrong.');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * test setting the console description
|
|
|
|
|
+ *
|
|
|
|
|
+ * @group deprecated
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ */
|
|
|
|
|
+ public function testEplilogDeprecated()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->deprecated(function() {
|
|
|
|
|
+ $parser = new ConsoleOptionParser('test', false);
|
|
|
|
|
+ $result = $parser->epilog('A test');
|
|
|
|
|
|
|
|
- $result = $parser->description(['A test', 'something']);
|
|
|
|
|
- $this->assertEquals("A test\nsomething", $parser->description(), 'getting value is wrong.');
|
|
|
|
|
|
|
+ $this->assertEquals($parser, $result, 'Setting epilog is not chainable');
|
|
|
|
|
+ $this->assertEquals('A test', $parser->epilog(), 'getting value is wrong.');
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -51,13 +85,13 @@ class ConsoleOptionParserTest extends TestCase
|
|
|
public function testEpilog()
|
|
public function testEpilog()
|
|
|
{
|
|
{
|
|
|
$parser = new ConsoleOptionParser('test', false);
|
|
$parser = new ConsoleOptionParser('test', false);
|
|
|
- $result = $parser->epilog('A test');
|
|
|
|
|
|
|
+ $result = $parser->setEpilog('A test');
|
|
|
|
|
|
|
|
$this->assertEquals($parser, $result, 'Setting epilog is not chainable');
|
|
$this->assertEquals($parser, $result, 'Setting epilog is not chainable');
|
|
|
- $this->assertEquals('A test', $parser->epilog(), 'getting value is wrong.');
|
|
|
|
|
|
|
+ $this->assertEquals('A test', $parser->getEpilog(), 'getting value is wrong.');
|
|
|
|
|
|
|
|
- $result = $parser->epilog(['A test', 'something']);
|
|
|
|
|
- $this->assertEquals("A test\nsomething", $parser->epilog(), 'getting value is wrong.');
|
|
|
|
|
|
|
+ $result = $parser->setEpilog(['A test', 'something']);
|
|
|
|
|
+ $this->assertEquals("A test\nsomething", $parser->getEpilog(), 'getting value is wrong.');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -789,7 +823,7 @@ TEXT;
|
|
|
public function testHelpWithRootName()
|
|
public function testHelpWithRootName()
|
|
|
{
|
|
{
|
|
|
$parser = new ConsoleOptionParser('sample', false);
|
|
$parser = new ConsoleOptionParser('sample', false);
|
|
|
- $parser->description('A command!')
|
|
|
|
|
|
|
+ $parser->setDescription('A command!')
|
|
|
->setRootName('tool')
|
|
->setRootName('tool')
|
|
|
->addOption('test', ['help' => 'A test option.']);
|
|
->addOption('test', ['help' => 'A test option.']);
|
|
|
|
|
|
|
@@ -874,8 +908,8 @@ TEXT;
|
|
|
];
|
|
];
|
|
|
$parser = ConsoleOptionParser::buildFromArray($spec);
|
|
$parser = ConsoleOptionParser::buildFromArray($spec);
|
|
|
|
|
|
|
|
- $this->assertEquals($spec['description'], $parser->description());
|
|
|
|
|
- $this->assertEquals($spec['epilog'], $parser->epilog());
|
|
|
|
|
|
|
+ $this->assertEquals($spec['description'], $parser->getDescription());
|
|
|
|
|
+ $this->assertEquals($spec['epilog'], $parser->getEpilog());
|
|
|
|
|
|
|
|
$options = $parser->options();
|
|
$options = $parser->options();
|
|
|
$this->assertTrue(isset($options['name']));
|
|
$this->assertTrue(isset($options['name']));
|
|
@@ -897,7 +931,7 @@ TEXT;
|
|
|
{
|
|
{
|
|
|
$parser = ConsoleOptionParser::create('factory', false);
|
|
$parser = ConsoleOptionParser::create('factory', false);
|
|
|
$this->assertInstanceOf('Cake\Console\ConsoleOptionParser', $parser);
|
|
$this->assertInstanceOf('Cake\Console\ConsoleOptionParser', $parser);
|
|
|
- $this->assertEquals('factory', $parser->command());
|
|
|
|
|
|
|
+ $this->assertEquals('factory', $parser->getCommand());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -908,7 +942,7 @@ TEXT;
|
|
|
public function testCommandInflection()
|
|
public function testCommandInflection()
|
|
|
{
|
|
{
|
|
|
$parser = new ConsoleOptionParser('CommandLine');
|
|
$parser = new ConsoleOptionParser('CommandLine');
|
|
|
- $this->assertEquals('command_line', $parser->command());
|
|
|
|
|
|
|
+ $this->assertEquals('command_line', $parser->getCommand());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|