Merge branch '3.0' into 3.1

* 3.0:
  Minor fixes
  [Console] Overcomplete argument exception message tweak.
  fixed bad auto merge
  Console table cleanup
  undefined offset fix (#19406)
  [EventDispatcher] Removed unused variable
This commit is contained in:
Fabien Potencier 2016-07-30 03:24:41 -04:00
commit 273eb480f8
19 changed files with 68 additions and 47 deletions

View File

@ -28,7 +28,6 @@ use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory;
use Symfony\Component\Serializer\Normalizer\DataUriNormalizer;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
use Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer;
use Symfony\Component\Validator\Validation;
/**
* FrameworkExtension.

View File

@ -45,7 +45,7 @@ class SessionController implements ContainerAwareInterface
public function logoutAction(Request $request)
{
$request->getSession('session')->invalidate();
$request->getSession()->invalidate();
return new Response('Session cleared.');
}

View File

@ -105,7 +105,7 @@ EOF
return 1;
}
$passwordQuestion = $this->createPasswordQuestion($input, $output);
$passwordQuestion = $this->createPasswordQuestion();
$password = $io->askQuestion($passwordQuestion);
}

View File

@ -115,11 +115,11 @@ class Table
self::$styles = self::initStyles();
}
if (!self::$styles[$name]) {
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
if (isset(self::$styles[$name])) {
return self::$styles[$name];
}
return self::$styles[$name];
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
}
/**
@ -131,13 +131,7 @@ class Table
*/
public function setStyle($name)
{
if ($name instanceof TableStyle) {
$this->style = $name;
} elseif (isset(self::$styles[$name])) {
$this->style = self::$styles[$name];
} else {
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
}
$this->style = $this->resolveStyle($name);
return $this;
}
@ -164,13 +158,7 @@ class Table
{
$columnIndex = intval($columnIndex);
if ($name instanceof TableStyle) {
$this->columnStyles[$columnIndex] = $name;
} elseif (isset(self::$styles[$name])) {
$this->columnStyles[$columnIndex] = self::$styles[$name];
} else {
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
}
$this->columnStyles[$columnIndex] = $this->resolveStyle($name);
return $this;
}
@ -701,4 +689,17 @@ class Table
'symfony-style-guide' => $styleGuide,
);
}
private function resolveStyle($name)
{
if ($name instanceof TableStyle) {
return $name;
}
if (isset(self::$styles[$name])) {
return self::$styles[$name];
}
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
}
}

View File

@ -176,7 +176,12 @@ class ArgvInput extends Input
// unexpected argument
} else {
throw new RuntimeException('Too many arguments.');
$all = $this->definition->getArguments();
if (count($all)) {
throw new RuntimeException(sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all))));
}
throw new RuntimeException(sprintf('No arguments expected, got "%s".', $token));
}
}

View File

@ -694,6 +694,25 @@ TABLE;
$this->assertEquals($expected, $this->getOutputContent($output));
}
/**
* @expectedException Symfony\Component\Console\Exception\InvalidArgumentException
* @expectedExceptionMessage Style "absent" is not defined.
*/
public function testIsNotDefinedStyleException()
{
$table = new Table($this->getOutputStream());
$table->setStyle('absent');
}
/**
* @expectedException \Symfony\Component\Console\Exception\InvalidArgumentException
* @expectedExceptionMessage Style "absent" is not defined.
*/
public function testGetStyleDefinition()
{
Table::getStyleDefinition('absent');
}
protected function getOutputStream()
{
return new StreamOutput($this->stream, StreamOutput::VERBOSITY_NORMAL, false);

View File

@ -183,7 +183,17 @@ class ArgvInputTest extends \PHPUnit_Framework_TestCase
array(
array('cli.php', 'foo', 'bar'),
new InputDefinition(),
'Too many arguments.',
'No arguments expected, got "foo".',
),
array(
array('cli.php', 'foo', 'bar'),
new InputDefinition(array(new InputArgument('number'))),
'Too many arguments, expected arguments "number".',
),
array(
array('cli.php', 'foo', 'bar', 'zzz'),
new InputDefinition(array(new InputArgument('number'), new InputArgument('county'))),
'Too many arguments, expected arguments "number" "county".',
),
array(
array('cli.php', '--foo'),

View File

@ -13,7 +13,6 @@ namespace Symfony\Component\Debug\Tests;
use Symfony\Component\Debug\DebugClassLoader;
use Symfony\Component\Debug\ErrorHandler;
use Symfony\Component\Debug\Exception\ContextErrorException;
class DebugClassLoaderTest extends \PHPUnit_Framework_TestCase
{

View File

@ -12,7 +12,6 @@
namespace Symfony\Component\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerBuilder;

View File

@ -48,7 +48,7 @@ class ReplaceAliasByActualDefinitionPassTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($container->has('container'));
$resolvedFactory = $aDefinition->getFactory(false);
$resolvedFactory = $aDefinition->getFactory();
$this->assertSame('b_alias', (string) $resolvedFactory[0]);
}

View File

@ -114,7 +114,7 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
try {
@$builder->get('baz');
$this->fail('->get() throws a ServiceCircularReferenceException if the service has a circular reference to itself');
} catch (\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException $e) {
} catch (ServiceCircularReferenceException $e) {
$this->assertEquals('Circular reference detected for service "baz", path: "baz".', $e->getMessage(), '->get() throws a LogicException if the service has a circular reference to itself');
}

View File

@ -14,7 +14,6 @@ namespace Symfony\Component\DependencyInjection\Tests\Loader;
use Symfony\Bridge\PhpUnit\ErrorAssert;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;

View File

@ -13,7 +13,6 @@ namespace Symfony\Component\DomCrawler\Tests;
use Symfony\Component\DomCrawler\Form;
use Symfony\Component\DomCrawler\FormFieldRegistry;
use Symfony\Component\DomCrawler\Field;
class FormTest extends \PHPUnit_Framework_TestCase
{

View File

@ -3,7 +3,6 @@
namespace Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\HttpKernel\Bundle;
/**
* This command has a required parameter on the constructor and will be ignored by the default Bundle implementation.

View File

@ -656,7 +656,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
{
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$parsedValue = $formatter->parse($value, NumberFormatter::TYPE_INT32);
$this->assertSame($expected, $parsedValue);
$this->assertSame($expected, $parsedValue, $message);
}
public function parseTypeInt32Provider()

View File

@ -81,6 +81,6 @@ abstract class PropertyAccessorArrayAccessTest extends \PHPUnit_Framework_TestCa
*/
public function testIsWritable($collection, $path)
{
$this->assertTrue($this->propertyAccessor->isWritable($collection, $path, 'Updated'));
$this->assertTrue($this->propertyAccessor->isWritable($collection, $path));
}
}

View File

@ -166,33 +166,25 @@ abstract class PropertyAccessorCollectionTest extends PropertyAccessorArrayAcces
public function testIsWritableReturnsTrueIfAdderAndRemoverExists()
{
$car = $this->getMock(__CLASS__.'_Car');
$axes = $this->getContainer(array(1 => 'first', 2 => 'second', 3 => 'third'));
$this->assertTrue($this->propertyAccessor->isWritable($car, 'axes', $axes));
$this->assertTrue($this->propertyAccessor->isWritable($car, 'axes'));
}
public function testIsWritableReturnsFalseIfOnlyAdderExists()
{
$car = $this->getMock(__CLASS__.'_CarOnlyAdder');
$axes = $this->getContainer(array(1 => 'first', 2 => 'second', 3 => 'third'));
$this->assertFalse($this->propertyAccessor->isWritable($car, 'axes', $axes));
$this->assertFalse($this->propertyAccessor->isWritable($car, 'axes'));
}
public function testIsWritableReturnsFalseIfOnlyRemoverExists()
{
$car = $this->getMock(__CLASS__.'_CarOnlyRemover');
$axes = $this->getContainer(array(1 => 'first', 2 => 'second', 3 => 'third'));
$this->assertFalse($this->propertyAccessor->isWritable($car, 'axes', $axes));
$this->assertFalse($this->propertyAccessor->isWritable($car, 'axes'));
}
public function testIsWritableReturnsFalseIfNoAdderNorRemoverExists()
{
$car = $this->getMock(__CLASS__.'_CarNoAdderAndRemover');
$axes = $this->getContainer(array(1 => 'first', 2 => 'second', 3 => 'third'));
$this->assertFalse($this->propertyAccessor->isWritable($car, 'axes', $axes));
$this->assertFalse($this->propertyAccessor->isWritable($car, 'axes'));
}
/**

View File

@ -121,7 +121,7 @@ class DelegatingEngineTest extends \PHPUnit_Framework_TestCase
$secondEngine = $this->getEngineMock('template.php', false);
$delegatingEngine = new DelegatingEngine(array($firstEngine, $secondEngine));
$delegatingEngine->getEngine('template.php', array('foo' => 'bar'));
$delegatingEngine->getEngine('template.php');
}
private function getEngineMock($template, $supports)

View File

@ -37,7 +37,7 @@ class PluralizationRulesTest extends \PHPUnit_Framework_TestCase
*/
public function testFailedLangcodes($nplural, $langCodes)
{
$matrix = $this->generateTestData($nplural, $langCodes);
$matrix = $this->generateTestData($langCodes);
$this->validateMatrix($nplural, $matrix, false);
}
@ -46,7 +46,7 @@ class PluralizationRulesTest extends \PHPUnit_Framework_TestCase
*/
public function testLangcodes($nplural, $langCodes)
{
$matrix = $this->generateTestData($nplural, $langCodes);
$matrix = $this->generateTestData($langCodes);
$this->validateMatrix($nplural, $matrix);
}
@ -108,7 +108,7 @@ class PluralizationRulesTest extends \PHPUnit_Framework_TestCase
}
}
protected function generateTestData($plural, $langCodes)
protected function generateTestData($langCodes)
{
$matrix = array();
foreach ($langCodes as $langCode) {