Laravel version update

Laravel version update
This commit is contained in:
Manish Verma
2018-08-06 18:48:58 +05:30
parent d143048413
commit 126fbb0255
13678 changed files with 1031482 additions and 778530 deletions

View File

@@ -11,12 +11,13 @@
namespace Symfony\Component\Console\Tests\Input;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;
class ArgvInputTest extends \PHPUnit_Framework_TestCase
class ArgvInputTest extends TestCase
{
public function testConstructor()
{
@@ -47,7 +48,7 @@ class ArgvInputTest extends \PHPUnit_Framework_TestCase
$input = new ArgvInput($input);
$input->bind(new InputDefinition($options));
$this->assertEquals($expectedOptions, $input->getOptions(), $message);
$this->assertSame($expectedOptions, $input->getOptions(), $message);
}
public function provideOptions()
@@ -71,6 +72,36 @@ class ArgvInputTest extends \PHPUnit_Framework_TestCase
array('foo' => 'bar'),
'->parse() parses long options with a required value (with a space separator)',
),
array(
array('cli.php', '--foo='),
array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)),
array('foo' => ''),
'->parse() parses long options with optional value which is empty (with a = separator) as empty string',
),
array(
array('cli.php', '--foo=', 'bar'),
array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('name', InputArgument::REQUIRED)),
array('foo' => ''),
'->parse() parses long options with optional value without value specified or an empty string (with a = separator) followed by an argument as empty string',
),
array(
array('cli.php', 'bar', '--foo'),
array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('name', InputArgument::REQUIRED)),
array('foo' => null),
'->parse() parses long options with optional value which is empty (with a = separator) preceded by an argument',
),
array(
array('cli.php', '--foo', '', 'bar'),
array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('name', InputArgument::REQUIRED)),
array('foo' => ''),
'->parse() parses long options with optional value which is empty as empty string even followed by an argument',
),
array(
array('cli.php', '--foo'),
array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)),
array('foo' => null),
'->parse() parses long options with optional value specified with no separator and no value as null',
),
array(
array('cli.php', '-f'),
array(new InputOption('foo', 'f')),
@@ -151,7 +182,12 @@ class ArgvInputTest extends \PHPUnit_Framework_TestCase
*/
public function testInvalidInput($argv, $definition, $expectedExceptionMessage)
{
$this->setExpectedException('RuntimeException', $expectedExceptionMessage);
if (method_exists($this, 'expectException')) {
$this->expectException('RuntimeException');
$this->expectExceptionMessage($expectedExceptionMessage);
} else {
$this->setExpectedException('RuntimeException', $expectedExceptionMessage);
}
$input = new ArgvInput($argv);
$input->bind($definition);
@@ -234,14 +270,14 @@ class ArgvInputTest extends \PHPUnit_Framework_TestCase
$input = new ArgvInput(array('cli.php', '--name=foo', '--name=bar', '--name='));
$input->bind(new InputDefinition(array(new InputOption('name', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY))));
$this->assertSame(array('name' => array('foo', 'bar', null)), $input->getOptions(), '->parse() parses empty array options as null ("--option=value" syntax)');
$this->assertSame(array('name' => array('foo', 'bar', '')), $input->getOptions(), '->parse() parses empty array options as null ("--option=value" syntax)');
$input = new ArgvInput(array('cli.php', '--name', 'foo', '--name', 'bar', '--name', '--anotherOption'));
$input->bind(new InputDefinition(array(
new InputOption('name', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY),
new InputOption('anotherOption', null, InputOption::VALUE_NONE),
)));
$this->assertSame(array('name' => array('foo', 'bar', null), 'anotherOption' => true), $input->getOptions(), '->parse() parses empty array options as null ("--option value" syntax)');
$this->assertSame(array('name' => array('foo', 'bar', null), 'anotherOption' => true), $input->getOptions(), '->parse() parses empty array options ("--option value" syntax)');
}
public function testParseNegativeNumberAfterDoubleDash()
@@ -278,6 +314,10 @@ class ArgvInputTest extends \PHPUnit_Framework_TestCase
$input = new ArgvInput(array('cli.php', '-f', 'foo'));
$this->assertTrue($input->hasParameterOption('-f'), '->hasParameterOption() returns true if the given short option is in the raw input');
$input = new ArgvInput(array('cli.php', '-etest'));
$this->assertTrue($input->hasParameterOption('-e'), '->hasParameterOption() returns true if the given short option is in the raw input');
$this->assertFalse($input->hasParameterOption('-s'), '->hasParameterOption() returns true if the given short option is in the raw input');
$input = new ArgvInput(array('cli.php', '--foo', 'foo'));
$this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if the given short option is in the raw input');
@@ -303,6 +343,46 @@ class ArgvInputTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($input->hasParameterOption('--foo', true), '->hasParameterOption() returns false if the given option is in the raw input but after an end of options signal');
}
public function testHasParameterOptionEdgeCasesAndLimitations()
{
$input = new ArgvInput(array('cli.php', '-fh'));
// hasParameterOption does not know if the previous short option, -f,
// takes a value or not. If -f takes a value, then -fh does NOT include
// -h; Otherwise it does. Since we do not know which short options take
// values, hasParameterOption does not support this use-case.
$this->assertFalse($input->hasParameterOption('-h'), '->hasParameterOption() returns true if the given short option is in the raw input');
// hasParameterOption does detect that `-fh` contains `-f`, since
// `-f` is the first short option in the set.
$this->assertTrue($input->hasParameterOption('-f'), '->hasParameterOption() returns true if the given short option is in the raw input');
// The test below happens to pass, although it might make more sense
// to disallow it, and require the use of
// $input->hasParameterOption('-f') && $input->hasParameterOption('-h')
// instead.
$this->assertTrue($input->hasParameterOption('-fh'), '->hasParameterOption() returns true if the given short option is in the raw input');
// In theory, if -fh is supported, then -hf should also work.
// However, this is not supported.
$this->assertFalse($input->hasParameterOption('-hf'), '->hasParameterOption() returns true if the given short option is in the raw input');
$input = new ArgvInput(array('cli.php', '-f', '-h'));
// If hasParameterOption('-fh') is supported for 'cli.php -fh', then
// one might also expect that it should also be supported for
// 'cli.php -f -h'. However, this is not supported.
$this->assertFalse($input->hasParameterOption('-fh'), '->hasParameterOption() returns true if the given short option is in the raw input');
}
public function testNoWarningOnInvalidParameterOption()
{
$input = new ArgvInput(array('cli.php', '-edev'));
$this->assertTrue($input->hasParameterOption(array('-e', '')));
// No warning thrown
$this->assertFalse($input->hasParameterOption(array('-m', '')));
$this->assertEquals('dev', $input->getParameterOption(array('-e', '')));
// No warning thrown
$this->assertFalse($input->getParameterOption(array('-m', '')));
}
public function testToString()
{
$input = new ArgvInput(array('cli.php', '-f', 'foo'));
@@ -315,25 +395,26 @@ class ArgvInputTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider provideGetParameterOptionValues
*/
public function testGetParameterOptionEqualSign($argv, $key, $onlyParams, $expected)
public function testGetParameterOptionEqualSign($argv, $key, $default, $onlyParams, $expected)
{
$input = new ArgvInput($argv);
$this->assertEquals($expected, $input->getParameterOption($key, false, $onlyParams), '->getParameterOption() returns the expected value');
$this->assertEquals($expected, $input->getParameterOption($key, $default, $onlyParams), '->getParameterOption() returns the expected value');
}
public function provideGetParameterOptionValues()
{
return array(
array(array('app/console', 'foo:bar', '-e', 'dev'), '-e', false, 'dev'),
array(array('app/console', 'foo:bar', '--env=dev'), '--env', false, 'dev'),
array(array('app/console', 'foo:bar', '-e', 'dev'), array('-e', '--env'), false, 'dev'),
array(array('app/console', 'foo:bar', '--env=dev'), array('-e', '--env'), false, 'dev'),
array(array('app/console', 'foo:bar', '--env=dev', '--en=1'), array('--en'), false, '1'),
array(array('app/console', 'foo:bar', '--env=dev', '', '--en=1'), array('--en'), false, '1'),
array(array('app/console', 'foo:bar', '--env', 'val'), '--env', false, 'val'),
array(array('app/console', 'foo:bar', '--env', 'val', '--dummy'), '--env', false, 'val'),
array(array('app/console', 'foo:bar', '--', '--env=dev'), '--env', false, 'dev'),
array(array('app/console', 'foo:bar', '--', '--env=dev'), '--env', true, false),
array(array('app/console', 'foo:bar'), '-e', 'default', false, 'default'),
array(array('app/console', 'foo:bar', '-e', 'dev'), '-e', 'default', false, 'dev'),
array(array('app/console', 'foo:bar', '--env=dev'), '--env', 'default', false, 'dev'),
array(array('app/console', 'foo:bar', '-e', 'dev'), array('-e', '--env'), 'default', false, 'dev'),
array(array('app/console', 'foo:bar', '--env=dev'), array('-e', '--env'), 'default', false, 'dev'),
array(array('app/console', 'foo:bar', '--env=dev', '--en=1'), array('--en'), 'default', false, '1'),
array(array('app/console', 'foo:bar', '--env=dev', '', '--en=1'), array('--en'), 'default', false, '1'),
array(array('app/console', 'foo:bar', '--env', 'val'), '--env', 'default', false, 'val'),
array(array('app/console', 'foo:bar', '--env', 'val', '--dummy'), '--env', 'default', false, 'val'),
array(array('app/console', 'foo:bar', '--', '--env=dev'), '--env', 'default', false, 'dev'),
array(array('app/console', 'foo:bar', '--', '--env=dev'), '--env', 'default', true, 'default'),
);
}
@@ -343,4 +424,30 @@ class ArgvInputTest extends \PHPUnit_Framework_TestCase
$input->bind(new InputDefinition(array(new InputArgument('file'))));
$this->assertEquals(array('file' => '-'), $input->getArguments(), '->parse() parses single dash as an argument');
}
public function testParseOptionWithValueOptionalGivenEmptyAndRequiredArgument()
{
$input = new ArgvInput(array('cli.php', '--foo=', 'bar'));
$input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('name', InputArgument::REQUIRED))));
$this->assertEquals(array('foo' => null), $input->getOptions(), '->parse() parses optional options with empty value as null');
$this->assertEquals(array('name' => 'bar'), $input->getArguments(), '->parse() parses required arguments');
$input = new ArgvInput(array('cli.php', '--foo=0', 'bar'));
$input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('name', InputArgument::REQUIRED))));
$this->assertEquals(array('foo' => '0'), $input->getOptions(), '->parse() parses optional options with empty value as null');
$this->assertEquals(array('name' => 'bar'), $input->getArguments(), '->parse() parses required arguments');
}
public function testParseOptionWithValueOptionalGivenEmptyAndOptionalArgument()
{
$input = new ArgvInput(array('cli.php', '--foo=', 'bar'));
$input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('name', InputArgument::OPTIONAL))));
$this->assertEquals(array('foo' => null), $input->getOptions(), '->parse() parses optional options with empty value as null');
$this->assertEquals(array('name' => 'bar'), $input->getArguments(), '->parse() parses optional arguments');
$input = new ArgvInput(array('cli.php', '--foo=0', 'bar'));
$input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('name', InputArgument::OPTIONAL))));
$this->assertEquals(array('foo' => '0'), $input->getOptions(), '->parse() parses optional options with empty value as null');
$this->assertEquals(array('name' => 'bar'), $input->getArguments(), '->parse() parses optional arguments');
}
}

View File

@@ -11,12 +11,13 @@
namespace Symfony\Component\Console\Tests\Input;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;
class ArrayInputTest extends \PHPUnit_Framework_TestCase
class ArrayInputTest extends TestCase
{
public function testGetFirstArgument()
{
@@ -46,14 +47,14 @@ class ArrayInputTest extends \PHPUnit_Framework_TestCase
{
$input = new ArrayInput(array('name' => 'Fabien', '--foo' => 'bar'));
$this->assertEquals('bar', $input->getParameterOption('--foo'), '->getParameterOption() returns the option of specified name');
$this->assertFalse($input->getParameterOption('--bar'), '->getParameterOption() returns the default if an option is not present in the passed parameters');
$this->assertEquals('default', $input->getParameterOption('--bar', 'default'), '->getParameterOption() returns the default value if an option is not present in the passed parameters');
$input = new ArrayInput(array('Fabien', '--foo' => 'bar'));
$this->assertEquals('bar', $input->getParameterOption('--foo'), '->getParameterOption() returns the option of specified name');
$input = new ArrayInput(array('--foo', '--', '--bar' => 'woop'));
$this->assertEquals('woop', $input->getParameterOption('--bar'), '->getParameterOption() returns the correct value if an option is present in the passed parameters');
$this->assertFalse($input->getParameterOption('--bar', false, true), '->getParameterOption() returns false if an option is present in the passed parameters after an end of options signal');
$this->assertEquals('default', $input->getParameterOption('--bar', 'default', true), '->getParameterOption() returns the default value if an option is present in the passed parameters after an end of options signal');
}
public function testParseArguments()
@@ -89,9 +90,15 @@ class ArrayInputTest extends \PHPUnit_Framework_TestCase
'->parse() parses long options with a default value',
),
array(
array('--foo' => null),
array(),
array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')),
array('foo' => 'default'),
'->parse() uses the default value for long options with value optional which are not passed',
),
array(
array('--foo' => null),
array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')),
array('foo' => null),
'->parse() parses long options with a default value',
),
array(
@@ -120,7 +127,12 @@ class ArrayInputTest extends \PHPUnit_Framework_TestCase
*/
public function testParseInvalidInput($parameters, $definition, $expectedExceptionMessage)
{
$this->setExpectedException('InvalidArgumentException', $expectedExceptionMessage);
if (method_exists($this, 'expectException')) {
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage($expectedExceptionMessage);
} else {
$this->setExpectedException('InvalidArgumentException', $expectedExceptionMessage);
}
new ArrayInput($parameters, $definition);
}
@@ -155,5 +167,11 @@ class ArrayInputTest extends \PHPUnit_Framework_TestCase
{
$input = new ArrayInput(array('-f' => null, '-b' => 'bar', '--foo' => 'b a z', '--lala' => null, 'test' => 'Foo', 'test2' => "A\nB'C"));
$this->assertEquals('-f -b=bar --foo='.escapeshellarg('b a z').' --lala Foo '.escapeshellarg("A\nB'C"), (string) $input);
$input = new ArrayInput(array('-b' => array('bval_1', 'bval_2'), '--f' => array('fval_1', 'fval_2')));
$this->assertSame('-b=bval_1 -b=bval_2 --f=fval_1 --f=fval_2', (string) $input);
$input = new ArrayInput(array('array_arg' => array('val_1', 'val_2')));
$this->assertSame('val_1 val_2', (string) $input);
}
}

View File

@@ -11,9 +11,10 @@
namespace Symfony\Component\Console\Tests\Input;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\InputArgument;
class InputArgumentTest extends \PHPUnit_Framework_TestCase
class InputArgumentTest extends TestCase
{
public function testConstructor()
{
@@ -41,7 +42,12 @@ class InputArgumentTest extends \PHPUnit_Framework_TestCase
*/
public function testInvalidModes($mode)
{
$this->setExpectedException('InvalidArgumentException', sprintf('Argument mode "%s" is not valid.', $mode));
if (method_exists($this, 'expectException')) {
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage(sprintf('Argument mode "%s" is not valid.', $mode));
} else {
$this->setExpectedException('InvalidArgumentException', sprintf('Argument mode "%s" is not valid.', $mode));
}
new InputArgument('foo', $mode);
}

View File

@@ -11,11 +11,12 @@
namespace Symfony\Component\Console\Tests\Input;
use Symfony\Component\Console\Input\InputDefinition;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;
class InputDefinitionTest extends \PHPUnit_Framework_TestCase
class InputDefinitionTest extends TestCase
{
protected static $fixtures;

View File

@@ -11,9 +11,10 @@
namespace Symfony\Component\Console\Tests\Input;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\InputOption;
class InputOptionTest extends \PHPUnit_Framework_TestCase
class InputOptionTest extends TestCase
{
public function testConstructor()
{
@@ -77,7 +78,12 @@ class InputOptionTest extends \PHPUnit_Framework_TestCase
*/
public function testInvalidModes($mode)
{
$this->setExpectedException('InvalidArgumentException', sprintf('Option mode "%s" is not valid.', $mode));
if (method_exists($this, 'expectException')) {
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage(sprintf('Option mode "%s" is not valid.', $mode));
} else {
$this->setExpectedException('InvalidArgumentException', sprintf('Option mode "%s" is not valid.', $mode));
}
new InputOption('foo', 'f', $mode);
}

View File

@@ -11,12 +11,13 @@
namespace Symfony\Component\Console\Tests\Input;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;
class InputTest extends \PHPUnit_Framework_TestCase
class InputTest extends TestCase
{
public function testConstructor()
{
@@ -36,6 +37,14 @@ class InputTest extends \PHPUnit_Framework_TestCase
$input = new ArrayInput(array('--name' => 'foo'), new InputDefinition(array(new InputOption('name'), new InputOption('bar', '', InputOption::VALUE_OPTIONAL, '', 'default'))));
$this->assertEquals('default', $input->getOption('bar'), '->getOption() returns the default value for optional options');
$this->assertEquals(array('name' => 'foo', 'bar' => 'default'), $input->getOptions(), '->getOptions() returns all option values, even optional ones');
$input = new ArrayInput(array('--name' => 'foo', '--bar' => ''), new InputDefinition(array(new InputOption('name'), new InputOption('bar', '', InputOption::VALUE_OPTIONAL, '', 'default'))));
$this->assertEquals('', $input->getOption('bar'), '->getOption() returns null for options explicitly passed without value (or an empty value)');
$this->assertEquals(array('name' => 'foo', 'bar' => ''), $input->getOptions(), '->getOptions() returns all option values.');
$input = new ArrayInput(array('--name' => 'foo', '--bar' => null), new InputDefinition(array(new InputOption('name'), new InputOption('bar', '', InputOption::VALUE_OPTIONAL, '', 'default'))));
$this->assertNull($input->getOption('bar'), '->getOption() returns null for options explicitly passed without value (or an empty value)');
$this->assertEquals(array('name' => 'foo', 'bar' => null), $input->getOptions(), '->getOptions() returns all option values');
}
/**
@@ -129,4 +138,12 @@ class InputTest extends \PHPUnit_Framework_TestCase
$input->setInteractive(false);
$this->assertFalse($input->isInteractive(), '->setInteractive() changes the interactive flag');
}
public function testSetGetStream()
{
$input = new ArrayInput(array());
$stream = fopen('php://memory', 'r+', false);
$input->setStream($stream);
$this->assertSame($stream, $input->getStream());
}
}

View File

@@ -11,11 +11,12 @@
namespace Symfony\Component\Console\Tests\Input;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\StringInput;
class StringInputTest extends \PHPUnit_Framework_TestCase
class StringInputTest extends TestCase
{
/**
* @dataProvider getTokenizeData