Skip to content

Commit

Permalink
Merge branch '3.1'
Browse files Browse the repository at this point in the history
* 3.1:
  Minor fixes
  [Cache] Fix abstract AdapterTestCase cache property
  [Console] Overcomplete argument exception message tweak.
  fixed bad auto merge
  Console table cleanup
  undefined offset fix (#19406)
  [EventDispatcher] Removed unused variable
  • Loading branch information
fabpot committed Jul 30, 2016
2 parents ad85c79 + 273eb48 commit 851a0a1
Show file tree
Hide file tree
Showing 19 changed files with 72 additions and 51 deletions.
Expand Up @@ -30,7 +30,6 @@
use Symfony\Component\Serializer\Normalizer\DataUriNormalizer;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
use Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer;
use Symfony\Component\Validator\Validation;
use Symfony\Component\Workflow;

/**
Expand Down
Expand Up @@ -45,7 +45,7 @@ public function welcomeAction(Request $request, $name = null)

public function logoutAction(Request $request)
{
$request->getSession('session')->invalidate();
$request->getSession()->invalidate();

return new Response('Session cleared.');
}
Expand Down
Expand Up @@ -105,7 +105,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

return 1;
}
$passwordQuestion = $this->createPasswordQuestion($input, $output);
$passwordQuestion = $this->createPasswordQuestion();
$password = $io->askQuestion($passwordQuestion);
}

Expand Down
10 changes: 5 additions & 5 deletions src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php
Expand Up @@ -23,18 +23,18 @@ public function testDefaultLifeTime()
return;
}

$this->cache = $this->createCachePool(2);
$cache = $this->createCachePool(2);

$item = $this->cache->getItem('key.dlt');
$item = $cache->getItem('key.dlt');
$item->set('value');
$this->cache->save($item);
$cache->save($item);
sleep(1);

$item = $this->cache->getItem('key.dlt');
$item = $cache->getItem('key.dlt');
$this->assertTrue($item->isHit());

sleep(2);
$item = $this->cache->getItem('key.dlt');
$item = $cache->getItem('key.dlt');
$this->assertFalse($item->isHit());
}
}
35 changes: 18 additions & 17 deletions src/Symfony/Component/Console/Helper/Table.php
Expand Up @@ -115,11 +115,11 @@ public static function getStyleDefinition($name)
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));
}

/**
Expand All @@ -131,13 +131,7 @@ public static function getStyleDefinition($name)
*/
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;
}
Expand All @@ -164,13 +158,7 @@ public function setColumnStyle($columnIndex, $name)
{
$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;
}
Expand Down Expand Up @@ -701,4 +689,17 @@ private static function initStyles()
'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));
}
}
7 changes: 6 additions & 1 deletion src/Symfony/Component/Console/Input/ArgvInput.php
Expand Up @@ -176,7 +176,12 @@ private function parseArgument($token)

// 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));
}
}

Expand Down
19 changes: 19 additions & 0 deletions src/Symfony/Component/Console/Tests/Helper/TableTest.php
Expand Up @@ -694,6 +694,25 @@ public function testColumnWiths()
$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);
Expand Down
12 changes: 11 additions & 1 deletion src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php
Expand Up @@ -183,7 +183,17 @@ public function provideInvalidInput()
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'),
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php
Expand Up @@ -13,7 +13,6 @@

use Symfony\Component\Debug\DebugClassLoader;
use Symfony\Component\Debug\ErrorHandler;
use Symfony\Component\Debug\Exception\ContextErrorException;

class DebugClassLoaderTest extends \PHPUnit_Framework_TestCase
{
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -48,7 +48,7 @@ public function testProcess()

$this->assertTrue($container->has('container'));

$resolvedFactory = $aDefinition->getFactory(false);
$resolvedFactory = $aDefinition->getFactory();
$this->assertSame('b_alias', (string) $resolvedFactory[0]);
}

Expand Down
Expand Up @@ -14,7 +14,6 @@
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;
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Component/DomCrawler/Tests/FormTest.php
Expand Up @@ -13,7 +13,6 @@

use Symfony\Component\DomCrawler\Form;
use Symfony\Component\DomCrawler\FormFieldRegistry;
use Symfony\Component\DomCrawler\Field;

class FormTest extends \PHPUnit_Framework_TestCase
{
Expand Down
Expand Up @@ -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.
Expand Down
Expand Up @@ -656,7 +656,7 @@ public function testParseTypeInt32($value, $expected, $message = '')
{
$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()
Expand Down
Expand Up @@ -81,6 +81,6 @@ public function testIsReadable($collection, $path)
*/
public function testIsWritable($collection, $path)
{
$this->assertTrue($this->propertyAccessor->isWritable($collection, $path, 'Updated'));
$this->assertTrue($this->propertyAccessor->isWritable($collection, $path));
}
}
Expand Up @@ -166,33 +166,25 @@ public function testSetValueFailsIfNoAdderNorRemoverFound()
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'));
}

/**
Expand Down
Expand Up @@ -121,7 +121,7 @@ public function testGetInvalidEngine()
$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)
Expand Down
Expand Up @@ -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);
}

Expand All @@ -46,7 +46,7 @@ public function testFailedLangcodes($nplural, $langCodes)
*/
public function testLangcodes($nplural, $langCodes)
{
$matrix = $this->generateTestData($nplural, $langCodes);
$matrix = $this->generateTestData($langCodes);
$this->validateMatrix($nplural, $matrix);
}

Expand Down Expand Up @@ -108,7 +108,7 @@ protected function validateMatrix($nplural, $matrix, $expectSuccess = true)
}
}

protected function generateTestData($plural, $langCodes)
protected function generateTestData($langCodes)
{
$matrix = array();
foreach ($langCodes as $langCode) {
Expand Down

0 comments on commit 851a0a1

Please sign in to comment.