Upgrade 1-11.38

This commit is contained in:
xesmyd
2026-03-30 14:10:30 +02:00
parent f2a7e6d1fc
commit ac648ef29d
24665 changed files with 69682 additions and 2205004 deletions
+41 -76
View File
@@ -23,44 +23,44 @@ class ParameterBagTest extends TestCase
public function testAll()
{
$bag = new ParameterBag(array('foo' => 'bar'));
$this->assertEquals(array('foo' => 'bar'), $bag->all(), '->all() gets all the input');
$bag = new ParameterBag(['foo' => 'bar']);
$this->assertEquals(['foo' => 'bar'], $bag->all(), '->all() gets all the input');
}
public function testKeys()
{
$bag = new ParameterBag(array('foo' => 'bar'));
$this->assertEquals(array('foo'), $bag->keys());
$bag = new ParameterBag(['foo' => 'bar']);
$this->assertEquals(['foo'], $bag->keys());
}
public function testAdd()
{
$bag = new ParameterBag(array('foo' => 'bar'));
$bag->add(array('bar' => 'bas'));
$this->assertEquals(array('foo' => 'bar', 'bar' => 'bas'), $bag->all());
$bag = new ParameterBag(['foo' => 'bar']);
$bag->add(['bar' => 'bas']);
$this->assertEquals(['foo' => 'bar', 'bar' => 'bas'], $bag->all());
}
public function testRemove()
{
$bag = new ParameterBag(array('foo' => 'bar'));
$bag->add(array('bar' => 'bas'));
$this->assertEquals(array('foo' => 'bar', 'bar' => 'bas'), $bag->all());
$bag = new ParameterBag(['foo' => 'bar']);
$bag->add(['bar' => 'bas']);
$this->assertEquals(['foo' => 'bar', 'bar' => 'bas'], $bag->all());
$bag->remove('bar');
$this->assertEquals(array('foo' => 'bar'), $bag->all());
$this->assertEquals(['foo' => 'bar'], $bag->all());
}
public function testReplace()
{
$bag = new ParameterBag(array('foo' => 'bar'));
$bag = new ParameterBag(['foo' => 'bar']);
$bag->replace(array('FOO' => 'BAR'));
$this->assertEquals(array('FOO' => 'BAR'), $bag->all(), '->replace() replaces the input with the argument');
$bag->replace(['FOO' => 'BAR']);
$this->assertEquals(['FOO' => 'BAR'], $bag->all(), '->replace() replaces the input with the argument');
$this->assertFalse($bag->has('foo'), '->replace() overrides previously set the input');
}
public function testGet()
{
$bag = new ParameterBag(array('foo' => 'bar', 'null' => null));
$bag = new ParameterBag(['foo' => 'bar', 'null' => null]);
$this->assertEquals('bar', $bag->get('foo'), '->get() gets the value of a parameter');
$this->assertEquals('default', $bag->get('unknown', 'default'), '->get() returns second argument as default if a parameter is not defined');
@@ -69,49 +69,14 @@ class ParameterBagTest extends TestCase
public function testGetDoesNotUseDeepByDefault()
{
$bag = new ParameterBag(array('foo' => array('bar' => 'moo')));
$bag = new ParameterBag(['foo' => ['bar' => 'moo']]);
$this->assertNull($bag->get('foo[bar]'));
}
/**
* @group legacy
* @dataProvider getInvalidPaths
* @expectedException \InvalidArgumentException
*/
public function testGetDeepWithInvalidPaths($path)
{
$bag = new ParameterBag(array('foo' => array('bar' => 'moo')));
$bag->get($path, null, true);
}
public function getInvalidPaths()
{
return array(
array('foo[['),
array('foo[d'),
array('foo[bar]]'),
array('foo[bar]d'),
);
}
/**
* @group legacy
*/
public function testGetDeep()
{
$bag = new ParameterBag(array('foo' => array('bar' => array('moo' => 'boo'))));
$this->assertEquals(array('moo' => 'boo'), $bag->get('foo[bar]', null, true));
$this->assertEquals('boo', $bag->get('foo[bar][moo]', null, true));
$this->assertEquals('default', $bag->get('foo[bar][foo]', 'default', true));
$this->assertEquals('default', $bag->get('bar[moo][foo]', 'default', true));
}
public function testSet()
{
$bag = new ParameterBag(array());
$bag = new ParameterBag([]);
$bag->set('foo', 'bar');
$this->assertEquals('bar', $bag->get('foo'), '->set() sets the value of parameter');
@@ -122,7 +87,7 @@ class ParameterBagTest extends TestCase
public function testHas()
{
$bag = new ParameterBag(array('foo' => 'bar'));
$bag = new ParameterBag(['foo' => 'bar']);
$this->assertTrue($bag->has('foo'), '->has() returns true if a parameter is defined');
$this->assertFalse($bag->has('unknown'), '->has() return false if a parameter is not defined');
@@ -130,7 +95,7 @@ class ParameterBagTest extends TestCase
public function testGetAlpha()
{
$bag = new ParameterBag(array('word' => 'foo_BAR_012'));
$bag = new ParameterBag(['word' => 'foo_BAR_012']);
$this->assertEquals('fooBAR', $bag->getAlpha('word'), '->getAlpha() gets only alphabetic characters');
$this->assertEquals('', $bag->getAlpha('unknown'), '->getAlpha() returns empty string if a parameter is not defined');
@@ -138,7 +103,7 @@ class ParameterBagTest extends TestCase
public function testGetAlnum()
{
$bag = new ParameterBag(array('word' => 'foo_BAR_012'));
$bag = new ParameterBag(['word' => 'foo_BAR_012']);
$this->assertEquals('fooBAR012', $bag->getAlnum('word'), '->getAlnum() gets only alphanumeric characters');
$this->assertEquals('', $bag->getAlnum('unknown'), '->getAlnum() returns empty string if a parameter is not defined');
@@ -146,7 +111,7 @@ class ParameterBagTest extends TestCase
public function testGetDigits()
{
$bag = new ParameterBag(array('word' => 'foo_BAR_012'));
$bag = new ParameterBag(['word' => 'foo_BAR_012']);
$this->assertEquals('012', $bag->getDigits('word'), '->getDigits() gets only digits as string');
$this->assertEquals('', $bag->getDigits('unknown'), '->getDigits() returns empty string if a parameter is not defined');
@@ -154,7 +119,7 @@ class ParameterBagTest extends TestCase
public function testGetInt()
{
$bag = new ParameterBag(array('digits' => '0123'));
$bag = new ParameterBag(['digits' => '0123']);
$this->assertEquals(123, $bag->getInt('digits'), '->getInt() gets a value of parameter as integer');
$this->assertEquals(0, $bag->getInt('unknown'), '->getInt() returns zero if a parameter is not defined');
@@ -162,42 +127,42 @@ class ParameterBagTest extends TestCase
public function testFilter()
{
$bag = new ParameterBag(array(
$bag = new ParameterBag([
'digits' => '0123ab',
'email' => 'example@example.com',
'url' => 'http://example.com/foo',
'dec' => '256',
'hex' => '0x100',
'array' => array('bang'),
));
'array' => ['bang'],
]);
$this->assertEmpty($bag->filter('nokey'), '->filter() should return empty by default if no key is found');
$this->assertEquals('0123', $bag->filter('digits', '', FILTER_SANITIZE_NUMBER_INT), '->filter() gets a value of parameter as integer filtering out invalid characters');
$this->assertEquals('0123', $bag->filter('digits', '', \FILTER_SANITIZE_NUMBER_INT), '->filter() gets a value of parameter as integer filtering out invalid characters');
$this->assertEquals('example@example.com', $bag->filter('email', '', FILTER_VALIDATE_EMAIL), '->filter() gets a value of parameter as email');
$this->assertEquals('example@example.com', $bag->filter('email', '', \FILTER_VALIDATE_EMAIL), '->filter() gets a value of parameter as email');
$this->assertEquals('http://example.com/foo', $bag->filter('url', '', FILTER_VALIDATE_URL, array('flags' => FILTER_FLAG_PATH_REQUIRED)), '->filter() gets a value of parameter as URL with a path');
$this->assertEquals('http://example.com/foo', $bag->filter('url', '', \FILTER_VALIDATE_URL, ['flags' => \FILTER_FLAG_PATH_REQUIRED]), '->filter() gets a value of parameter as URL with a path');
// This test is repeated for code-coverage
$this->assertEquals('http://example.com/foo', $bag->filter('url', '', FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED), '->filter() gets a value of parameter as URL with a path');
$this->assertEquals('http://example.com/foo', $bag->filter('url', '', \FILTER_VALIDATE_URL, \FILTER_FLAG_PATH_REQUIRED), '->filter() gets a value of parameter as URL with a path');
$this->assertFalse($bag->filter('dec', '', FILTER_VALIDATE_INT, array(
'flags' => FILTER_FLAG_ALLOW_HEX,
'options' => array('min_range' => 1, 'max_range' => 0xff),
)), '->filter() gets a value of parameter as integer between boundaries');
$this->assertFalse($bag->filter('dec', '', \FILTER_VALIDATE_INT, [
'flags' => \FILTER_FLAG_ALLOW_HEX,
'options' => ['min_range' => 1, 'max_range' => 0xff],
]), '->filter() gets a value of parameter as integer between boundaries');
$this->assertFalse($bag->filter('hex', '', FILTER_VALIDATE_INT, array(
'flags' => FILTER_FLAG_ALLOW_HEX,
'options' => array('min_range' => 1, 'max_range' => 0xff),
)), '->filter() gets a value of parameter as integer between boundaries');
$this->assertFalse($bag->filter('hex', '', \FILTER_VALIDATE_INT, [
'flags' => \FILTER_FLAG_ALLOW_HEX,
'options' => ['min_range' => 1, 'max_range' => 0xff],
]), '->filter() gets a value of parameter as integer between boundaries');
$this->assertEquals(array('bang'), $bag->filter('array', ''), '->filter() gets a value of parameter as an array');
$this->assertEquals(['bang'], $bag->filter('array', ''), '->filter() gets a value of parameter as an array');
}
public function testGetIterator()
{
$parameters = array('foo' => 'bar', 'hello' => 'world');
$parameters = ['foo' => 'bar', 'hello' => 'world'];
$bag = new ParameterBag($parameters);
$i = 0;
@@ -211,7 +176,7 @@ class ParameterBagTest extends TestCase
public function testCount()
{
$parameters = array('foo' => 'bar', 'hello' => 'world');
$parameters = ['foo' => 'bar', 'hello' => 'world'];
$bag = new ParameterBag($parameters);
$this->assertCount(\count($parameters), $bag);
@@ -219,7 +184,7 @@ class ParameterBagTest extends TestCase
public function testGetBoolean()
{
$parameters = array('string_true' => 'true', 'string_false' => 'false');
$parameters = ['string_true' => 'true', 'string_false' => 'false'];
$bag = new ParameterBag($parameters);
$this->assertTrue($bag->getBoolean('string_true'), '->getBoolean() gets the string true as boolean true');