updated packages

This commit is contained in:
2019-05-18 09:06:43 +00:00
parent 901d16349e
commit e9487fa58a
2025 changed files with 30366 additions and 49653 deletions

View File

@@ -21,7 +21,7 @@ use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
*/
class AttributeBagTest extends TestCase
{
private $array = array();
private $array = [];
/**
* @var AttributeBag
@@ -30,21 +30,21 @@ class AttributeBagTest extends TestCase
protected function setUp()
{
$this->array = array(
$this->array = [
'hello' => 'world',
'always' => 'be happy',
'user.login' => 'drak',
'csrf.token' => array(
'csrf.token' => [
'a' => '1234',
'b' => '4321',
),
'category' => array(
'fishing' => array(
],
'category' => [
'fishing' => [
'first' => 'cod',
'second' => 'sole',
),
),
);
],
],
];
$this->bag = new AttributeBag('_sf');
$this->bag->initialize($this->array);
}
@@ -52,7 +52,7 @@ class AttributeBagTest extends TestCase
protected function tearDown()
{
$this->bag = null;
$this->array = array();
$this->array = [];
}
public function testInitialize()
@@ -60,7 +60,7 @@ class AttributeBagTest extends TestCase
$bag = new AttributeBag();
$bag->initialize($this->array);
$this->assertEquals($this->array, $bag->all());
$array = array('should' => 'change');
$array = ['should' => 'change'];
$bag->initialize($array);
$this->assertEquals($array, $bag->all());
}
@@ -122,7 +122,7 @@ class AttributeBagTest extends TestCase
public function testReplace()
{
$array = array();
$array = [];
$array['name'] = 'jack';
$array['foo.bar'] = 'beep';
$this->bag->replace($array);
@@ -150,22 +150,22 @@ class AttributeBagTest extends TestCase
public function testClear()
{
$this->bag->clear();
$this->assertEquals(array(), $this->bag->all());
$this->assertEquals([], $this->bag->all());
}
public function attributesProvider()
{
return array(
array('hello', 'world', true),
array('always', 'be happy', true),
array('user.login', 'drak', true),
array('csrf.token', array('a' => '1234', 'b' => '4321'), true),
array('category', array('fishing' => array('first' => 'cod', 'second' => 'sole')), true),
array('user2.login', null, false),
array('never', null, false),
array('bye', null, false),
array('bye/for/now', null, false),
);
return [
['hello', 'world', true],
['always', 'be happy', true],
['user.login', 'drak', true],
['csrf.token', ['a' => '1234', 'b' => '4321'], true],
['category', ['fishing' => ['first' => 'cod', 'second' => 'sole']], true],
['user2.login', null, false],
['never', null, false],
['bye', null, false],
['bye/for/now', null, false],
];
}
public function testGetIterator()

View File

@@ -21,7 +21,7 @@ use Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag;
*/
class NamespacedAttributeBagTest extends TestCase
{
private $array = array();
private $array = [];
/**
* @var NamespacedAttributeBag
@@ -30,21 +30,21 @@ class NamespacedAttributeBagTest extends TestCase
protected function setUp()
{
$this->array = array(
$this->array = [
'hello' => 'world',
'always' => 'be happy',
'user.login' => 'drak',
'csrf.token' => array(
'csrf.token' => [
'a' => '1234',
'b' => '4321',
),
'category' => array(
'fishing' => array(
],
'category' => [
'fishing' => [
'first' => 'cod',
'second' => 'sole',
),
),
);
],
],
];
$this->bag = new NamespacedAttributeBag('_sf2', '/');
$this->bag->initialize($this->array);
}
@@ -52,7 +52,7 @@ class NamespacedAttributeBagTest extends TestCase
protected function tearDown()
{
$this->bag = null;
$this->array = array();
$this->array = [];
}
public function testInitialize()
@@ -60,7 +60,7 @@ class NamespacedAttributeBagTest extends TestCase
$bag = new NamespacedAttributeBag();
$bag->initialize($this->array);
$this->assertEquals($this->array, $this->bag->all());
$array = array('should' => 'not stick');
$array = ['should' => 'not stick'];
$bag->initialize($array);
// should have remained the same
@@ -139,7 +139,7 @@ class NamespacedAttributeBagTest extends TestCase
public function testReplace()
{
$array = array();
$array = [];
$array['name'] = 'jack';
$array['foo.bar'] = 'beep';
$this->bag->replace($array);
@@ -177,28 +177,28 @@ class NamespacedAttributeBagTest extends TestCase
public function testClear()
{
$this->bag->clear();
$this->assertEquals(array(), $this->bag->all());
$this->assertEquals([], $this->bag->all());
}
public function attributesProvider()
{
return array(
array('hello', 'world', true),
array('always', 'be happy', true),
array('user.login', 'drak', true),
array('csrf.token', array('a' => '1234', 'b' => '4321'), true),
array('csrf.token/a', '1234', true),
array('csrf.token/b', '4321', true),
array('category', array('fishing' => array('first' => 'cod', 'second' => 'sole')), true),
array('category/fishing', array('first' => 'cod', 'second' => 'sole'), true),
array('category/fishing/missing/first', null, false),
array('category/fishing/first', 'cod', true),
array('category/fishing/second', 'sole', true),
array('category/fishing/missing/second', null, false),
array('user2.login', null, false),
array('never', null, false),
array('bye', null, false),
array('bye/for/now', null, false),
);
return [
['hello', 'world', true],
['always', 'be happy', true],
['user.login', 'drak', true],
['csrf.token', ['a' => '1234', 'b' => '4321'], true],
['csrf.token/a', '1234', true],
['csrf.token/b', '4321', true],
['category', ['fishing' => ['first' => 'cod', 'second' => 'sole']], true],
['category/fishing', ['first' => 'cod', 'second' => 'sole'], true],
['category/fishing/missing/first', null, false],
['category/fishing/first', 'cod', true],
['category/fishing/second', 'sole', true],
['category/fishing/missing/second', null, false],
['user2.login', null, false],
['never', null, false],
['bye', null, false],
['bye/for/now', null, false],
];
}
}

View File

@@ -26,13 +26,13 @@ class AutoExpireFlashBagTest extends TestCase
*/
private $bag;
protected $array = array();
protected $array = [];
protected function setUp()
{
parent::setUp();
$this->bag = new FlashBag();
$this->array = array('new' => array('notice' => array('A previous flash message')));
$this->array = ['new' => ['notice' => ['A previous flash message']]];
$this->bag->initialize($this->array);
}
@@ -45,16 +45,16 @@ class AutoExpireFlashBagTest extends TestCase
public function testInitialize()
{
$bag = new FlashBag();
$array = array('new' => array('notice' => array('A previous flash message')));
$array = ['new' => ['notice' => ['A previous flash message']]];
$bag->initialize($array);
$this->assertEquals(array('A previous flash message'), $bag->peek('notice'));
$array = array('new' => array(
'notice' => array('Something else'),
'error' => array('a'),
));
$this->assertEquals(['A previous flash message'], $bag->peek('notice'));
$array = ['new' => [
'notice' => ['Something else'],
'error' => ['a'],
]];
$bag->initialize($array);
$this->assertEquals(array('Something else'), $bag->peek('notice'));
$this->assertEquals(array('a'), $bag->peek('error'));
$this->assertEquals(['Something else'], $bag->peek('notice'));
$this->assertEquals(['a'], $bag->peek('error'));
}
public function testGetStorageKey()
@@ -73,16 +73,16 @@ class AutoExpireFlashBagTest extends TestCase
public function testPeek()
{
$this->assertEquals(array(), $this->bag->peek('non_existing'));
$this->assertEquals(array('default'), $this->bag->peek('non_existing', array('default')));
$this->assertEquals(array('A previous flash message'), $this->bag->peek('notice'));
$this->assertEquals(array('A previous flash message'), $this->bag->peek('notice'));
$this->assertEquals([], $this->bag->peek('non_existing'));
$this->assertEquals(['default'], $this->bag->peek('non_existing', ['default']));
$this->assertEquals(['A previous flash message'], $this->bag->peek('notice'));
$this->assertEquals(['A previous flash message'], $this->bag->peek('notice'));
}
public function testSet()
{
$this->bag->set('notice', 'Foo');
$this->assertEquals(array('A previous flash message'), $this->bag->peek('notice'));
$this->assertEquals(['A previous flash message'], $this->bag->peek('notice'));
}
public function testHas()
@@ -93,43 +93,43 @@ class AutoExpireFlashBagTest extends TestCase
public function testKeys()
{
$this->assertEquals(array('notice'), $this->bag->keys());
$this->assertEquals(['notice'], $this->bag->keys());
}
public function testPeekAll()
{
$array = array(
'new' => array(
$array = [
'new' => [
'notice' => 'Foo',
'error' => 'Bar',
),
);
],
];
$this->bag->initialize($array);
$this->assertEquals(array(
$this->assertEquals([
'notice' => 'Foo',
'error' => 'Bar',
), $this->bag->peekAll()
], $this->bag->peekAll()
);
$this->assertEquals(array(
$this->assertEquals([
'notice' => 'Foo',
'error' => 'Bar',
), $this->bag->peekAll()
], $this->bag->peekAll()
);
}
public function testGet()
{
$this->assertEquals(array(), $this->bag->get('non_existing'));
$this->assertEquals(array('default'), $this->bag->get('non_existing', array('default')));
$this->assertEquals(array('A previous flash message'), $this->bag->get('notice'));
$this->assertEquals(array(), $this->bag->get('notice'));
$this->assertEquals([], $this->bag->get('non_existing'));
$this->assertEquals(['default'], $this->bag->get('non_existing', ['default']));
$this->assertEquals(['A previous flash message'], $this->bag->get('notice'));
$this->assertEquals([], $this->bag->get('notice'));
}
public function testSetAll()
{
$this->bag->setAll(array('a' => 'first', 'b' => 'second'));
$this->bag->setAll(['a' => 'first', 'b' => 'second']);
$this->assertFalse($this->bag->has('a'));
$this->assertFalse($this->bag->has('b'));
}
@@ -138,17 +138,17 @@ class AutoExpireFlashBagTest extends TestCase
{
$this->bag->set('notice', 'Foo');
$this->bag->set('error', 'Bar');
$this->assertEquals(array(
'notice' => array('A previous flash message'),
), $this->bag->all()
$this->assertEquals([
'notice' => ['A previous flash message'],
], $this->bag->all()
);
$this->assertEquals(array(), $this->bag->all());
$this->assertEquals([], $this->bag->all());
}
public function testClear()
{
$this->assertEquals(array('notice' => array('A previous flash message')), $this->bag->clear());
$this->assertEquals(['notice' => ['A previous flash message']], $this->bag->clear());
}
public function testDoNotRemoveTheNewFlashesWhenDisplayingTheExistingOnes()
@@ -156,6 +156,6 @@ class AutoExpireFlashBagTest extends TestCase
$this->bag->add('success', 'Something');
$this->bag->all();
$this->assertEquals(array('new' => array('success' => array('Something')), 'display' => array()), $this->array);
$this->assertEquals(['new' => ['success' => ['Something']], 'display' => []], $this->array);
}
}

View File

@@ -26,13 +26,13 @@ class FlashBagTest extends TestCase
*/
private $bag;
protected $array = array();
protected $array = [];
protected function setUp()
{
parent::setUp();
$this->bag = new FlashBag();
$this->array = array('notice' => array('A previous flash message'));
$this->array = ['notice' => ['A previous flash message']];
$this->bag->initialize($this->array);
}
@@ -47,7 +47,7 @@ class FlashBagTest extends TestCase
$bag = new FlashBag();
$bag->initialize($this->array);
$this->assertEquals($this->array, $bag->peekAll());
$array = array('should' => array('change'));
$array = ['should' => ['change']];
$bag->initialize($array);
$this->assertEquals($array, $bag->peekAll());
}
@@ -68,49 +68,49 @@ class FlashBagTest extends TestCase
public function testPeek()
{
$this->assertEquals(array(), $this->bag->peek('non_existing'));
$this->assertEquals(array('default'), $this->bag->peek('not_existing', array('default')));
$this->assertEquals(array('A previous flash message'), $this->bag->peek('notice'));
$this->assertEquals(array('A previous flash message'), $this->bag->peek('notice'));
$this->assertEquals([], $this->bag->peek('non_existing'));
$this->assertEquals(['default'], $this->bag->peek('not_existing', ['default']));
$this->assertEquals(['A previous flash message'], $this->bag->peek('notice'));
$this->assertEquals(['A previous flash message'], $this->bag->peek('notice'));
}
public function testAdd()
{
$tab = array('bar' => 'baz');
$tab = ['bar' => 'baz'];
$this->bag->add('string_message', 'lorem');
$this->bag->add('object_message', new \stdClass());
$this->bag->add('array_message', $tab);
$this->assertEquals(array('lorem'), $this->bag->get('string_message'));
$this->assertEquals(array(new \stdClass()), $this->bag->get('object_message'));
$this->assertEquals(array($tab), $this->bag->get('array_message'));
$this->assertEquals(['lorem'], $this->bag->get('string_message'));
$this->assertEquals([new \stdClass()], $this->bag->get('object_message'));
$this->assertEquals([$tab], $this->bag->get('array_message'));
}
public function testGet()
{
$this->assertEquals(array(), $this->bag->get('non_existing'));
$this->assertEquals(array('default'), $this->bag->get('not_existing', array('default')));
$this->assertEquals(array('A previous flash message'), $this->bag->get('notice'));
$this->assertEquals(array(), $this->bag->get('notice'));
$this->assertEquals([], $this->bag->get('non_existing'));
$this->assertEquals(['default'], $this->bag->get('not_existing', ['default']));
$this->assertEquals(['A previous flash message'], $this->bag->get('notice'));
$this->assertEquals([], $this->bag->get('notice'));
}
public function testAll()
{
$this->bag->set('notice', 'Foo');
$this->bag->set('error', 'Bar');
$this->assertEquals(array(
'notice' => array('Foo'),
'error' => array('Bar'), ), $this->bag->all()
$this->assertEquals([
'notice' => ['Foo'],
'error' => ['Bar'], ], $this->bag->all()
);
$this->assertEquals(array(), $this->bag->all());
$this->assertEquals([], $this->bag->all());
}
public function testSet()
{
$this->bag->set('notice', 'Foo');
$this->bag->set('notice', 'Bar');
$this->assertEquals(array('Bar'), $this->bag->peek('notice'));
$this->assertEquals(['Bar'], $this->bag->peek('notice'));
}
public function testHas()
@@ -121,7 +121,7 @@ class FlashBagTest extends TestCase
public function testKeys()
{
$this->assertEquals(array('notice'), $this->bag->keys());
$this->assertEquals(['notice'], $this->bag->keys());
}
public function testSetAll()
@@ -130,28 +130,28 @@ class FlashBagTest extends TestCase
$this->bag->add('another_flash', 'Bar');
$this->assertTrue($this->bag->has('one_flash'));
$this->assertTrue($this->bag->has('another_flash'));
$this->bag->setAll(array('unique_flash' => 'FooBar'));
$this->bag->setAll(['unique_flash' => 'FooBar']);
$this->assertFalse($this->bag->has('one_flash'));
$this->assertFalse($this->bag->has('another_flash'));
$this->assertSame(array('unique_flash' => 'FooBar'), $this->bag->all());
$this->assertSame(array(), $this->bag->all());
$this->assertSame(['unique_flash' => 'FooBar'], $this->bag->all());
$this->assertSame([], $this->bag->all());
}
public function testPeekAll()
{
$this->bag->set('notice', 'Foo');
$this->bag->set('error', 'Bar');
$this->assertEquals(array(
'notice' => array('Foo'),
'error' => array('Bar'),
), $this->bag->peekAll()
$this->assertEquals([
'notice' => ['Foo'],
'error' => ['Bar'],
], $this->bag->peekAll()
);
$this->assertTrue($this->bag->has('notice'));
$this->assertTrue($this->bag->has('error'));
$this->assertEquals(array(
'notice' => array('Foo'),
'error' => array('Bar'),
), $this->bag->peekAll()
$this->assertEquals([
'notice' => ['Foo'],
'error' => ['Bar'],
], $this->bag->peekAll()
);
}
}

View File

@@ -127,10 +127,10 @@ class SessionTest extends TestCase
public function testReplace()
{
$this->session->replace(array('happiness' => 'be good', 'symfony' => 'awesome'));
$this->assertEquals(array('happiness' => 'be good', 'symfony' => 'awesome'), $this->session->all());
$this->session->replace(array());
$this->assertEquals(array(), $this->session->all());
$this->session->replace(['happiness' => 'be good', 'symfony' => 'awesome']);
$this->assertEquals(['happiness' => 'be good', 'symfony' => 'awesome'], $this->session->all());
$this->session->replace([]);
$this->assertEquals([], $this->session->all());
}
/**
@@ -150,16 +150,16 @@ class SessionTest extends TestCase
$this->session->set('hi', 'fabien');
$this->session->set($key, $value);
$this->session->clear();
$this->assertEquals(array(), $this->session->all());
$this->assertEquals([], $this->session->all());
}
public function setProvider()
{
return array(
array('foo', 'bar', array('foo' => 'bar')),
array('foo.bar', 'too much beer', array('foo.bar' => 'too much beer')),
array('great', 'symfony is great', array('great' => 'symfony is great')),
);
return [
['foo', 'bar', ['foo' => 'bar']],
['foo.bar', 'too much beer', ['foo.bar' => 'too much beer']],
['great', 'symfony is great', ['great' => 'symfony is great']],
];
}
/**
@@ -170,14 +170,14 @@ class SessionTest extends TestCase
$this->session->set('hi.world', 'have a nice day');
$this->session->set($key, $value);
$this->session->remove($key);
$this->assertEquals(array('hi.world' => 'have a nice day'), $this->session->all());
$this->assertEquals(['hi.world' => 'have a nice day'], $this->session->all());
}
public function testInvalidate()
{
$this->session->set('invalidate', 123);
$this->session->invalidate();
$this->assertEquals(array(), $this->session->all());
$this->assertEquals([], $this->session->all());
}
public function testMigrate()
@@ -216,7 +216,7 @@ class SessionTest extends TestCase
public function testGetIterator()
{
$attributes = array('hello' => 'world', 'symfony' => 'rocks');
$attributes = ['hello' => 'world', 'symfony' => 'rocks'];
foreach ($attributes as $key => $val) {
$this->session->set($key, $val);
}

View File

@@ -50,7 +50,7 @@ abstract class AbstractRedisSessionHandlerTestCase extends TestCase
$this->redisClient = $this->createRedisClient($host);
$this->storage = new RedisSessionHandler(
$this->redisClient,
array('prefix' => self::PREFIX)
['prefix' => self::PREFIX]
);
}
@@ -117,7 +117,7 @@ abstract class AbstractRedisSessionHandlerTestCase extends TestCase
$lowTtl = 10;
$this->redisClient->setex(self::PREFIX.'id', $lowTtl, 'foo');
$this->storage->updateTimestamp('id', array());
$this->storage->updateTimestamp('id', []);
$this->assertGreaterThan($lowTtl, $this->redisClient->ttl(self::PREFIX.'id'));
}
@@ -137,9 +137,9 @@ abstract class AbstractRedisSessionHandlerTestCase extends TestCase
public function getOptionFixtures(): array
{
return array(
array(array('prefix' => 'session'), true),
array(array('prefix' => 'sfs', 'foo' => 'bar'), false),
);
return [
[['prefix' => 'session'], true],
[['prefix' => 'sfs', 'foo' => 'bar'], false],
];
}
}

View File

@@ -19,10 +19,10 @@ class AbstractSessionHandlerTest extends TestCase
public static function setUpBeforeClass()
{
$spec = array(
1 => array('file', '/dev/null', 'w'),
2 => array('file', '/dev/null', 'w'),
);
$spec = [
1 => ['file', '/dev/null', 'w'],
2 => ['file', '/dev/null', 'w'],
];
if (!self::$server = @proc_open('exec php -S localhost:8053', $spec, $pipes, __DIR__.'/Fixtures')) {
self::markTestSkipped('PHP server unable to start.');
}
@@ -42,7 +42,7 @@ class AbstractSessionHandlerTest extends TestCase
*/
public function testSession($fixture)
{
$context = array('http' => array('header' => "Cookie: sid=123abc\r\n"));
$context = ['http' => ['header' => "Cookie: sid=123abc\r\n"]];
$context = stream_context_create($context);
$result = file_get_contents(sprintf('http://localhost:8053/%s.php', $fixture), false, $context);
@@ -52,7 +52,7 @@ class AbstractSessionHandlerTest extends TestCase
public function provideSession()
{
foreach (glob(__DIR__.'/Fixtures/*.php') as $file) {
yield array(pathinfo($file, PATHINFO_FILENAME));
yield [pathinfo($file, PATHINFO_FILENAME)];
}
}
}

View File

@@ -4,10 +4,10 @@ require __DIR__.'/common.inc';
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
$storage = new NativeSessionStorage(array('cookie_samesite' => 'lax'));
$storage = new NativeSessionStorage(['cookie_samesite' => 'lax']);
$storage->setSaveHandler(new TestSessionHandler());
$storage->start();
$_SESSION = array('foo' => 'bar');
$_SESSION = ['foo' => 'bar'];
ob_start(function ($buffer) { return str_replace(session_id(), 'random_session_id', $buffer); });

View File

@@ -4,11 +4,11 @@ require __DIR__.'/common.inc';
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
$storage = new NativeSessionStorage(array('cookie_samesite' => 'lax'));
$storage = new NativeSessionStorage(['cookie_samesite' => 'lax']);
$storage->setSaveHandler(new TestSessionHandler());
$storage->start();
$_SESSION = array('foo' => 'bar');
$_SESSION = ['foo' => 'bar'];
$storage->regenerate(true);

View File

@@ -41,7 +41,7 @@ class MemcachedSessionHandlerTest extends TestCase
$this->memcached = $this->getMockBuilder('Memcached')->getMock();
$this->storage = new MemcachedSessionHandler(
$this->memcached,
array('prefix' => self::PREFIX, 'expiretime' => self::TTL)
['prefix' => self::PREFIX, 'expiretime' => self::TTL]
);
}
@@ -59,6 +59,12 @@ class MemcachedSessionHandlerTest extends TestCase
public function testCloseSession()
{
$this->memcached
->expects($this->once())
->method('quit')
->will($this->returnValue(true))
;
$this->assertTrue($this->storage->close());
}
@@ -117,12 +123,12 @@ class MemcachedSessionHandlerTest extends TestCase
public function getOptionFixtures()
{
return array(
array(array('prefix' => 'session'), true),
array(array('expiretime' => 100), true),
array(array('prefix' => 'session', 'expiretime' => 200), true),
array(array('expiretime' => 100, 'foo' => 'bar'), false),
);
return [
[['prefix' => 'session'], true],
[['expiretime' => 100], true],
[['prefix' => 'session', 'expiretime' => 200], true],
[['expiretime' => 100, 'foo' => 'bar'], false],
];
}
public function testGetConnection()

View File

@@ -40,14 +40,14 @@ class MongoDbSessionHandlerTest extends TestCase
->disableOriginalConstructor()
->getMock();
$this->options = array(
$this->options = [
'id_field' => '_id',
'data_field' => 'data',
'time_field' => 'time',
'expiry_field' => 'expires_at',
'database' => 'sf-test',
'collection' => 'session-test',
);
];
$this->storage = new MongoDbSessionHandler($this->mongo, $this->options);
}
@@ -57,7 +57,7 @@ class MongoDbSessionHandlerTest extends TestCase
*/
public function testConstructorShouldThrowExceptionForMissingOptions()
{
new MongoDbSessionHandler($this->mongo, array());
new MongoDbSessionHandler($this->mongo, []);
}
public function testOpenMethodAlwaysReturnTrue()
@@ -95,11 +95,11 @@ class MongoDbSessionHandlerTest extends TestCase
$this->assertInstanceOf(\MongoDB\BSON\UTCDateTime::class, $criteria[$this->options['expiry_field']]['$gte']);
$this->assertGreaterThanOrEqual(round((string) $criteria[$this->options['expiry_field']]['$gte'] / 1000), $testTimeout);
return array(
return [
$this->options['id_field'] => 'foo',
$this->options['expiry_field'] => new \MongoDB\BSON\UTCDateTime(),
$this->options['data_field'] => new \MongoDB\BSON\Binary('bar', \MongoDB\BSON\Binary::TYPE_OLD_BINARY),
);
];
}));
$this->assertEquals('bar', $this->storage->read('foo'));
@@ -117,8 +117,8 @@ class MongoDbSessionHandlerTest extends TestCase
$collection->expects($this->once())
->method('updateOne')
->will($this->returnCallback(function ($criteria, $updateData, $options) {
$this->assertEquals(array($this->options['id_field'] => 'foo'), $criteria);
$this->assertEquals(array('upsert' => true), $options);
$this->assertEquals([$this->options['id_field'] => 'foo'], $criteria);
$this->assertEquals(['upsert' => true], $options);
$data = $updateData['$set'];
$expectedExpiry = time() + (int) ini_get('session.gc_maxlifetime');
@@ -141,7 +141,7 @@ class MongoDbSessionHandlerTest extends TestCase
->with($this->options['database'], $this->options['collection'])
->will($this->returnValue($collection));
$data = array();
$data = [];
$collection->expects($this->exactly(2))
->method('updateOne')
@@ -166,7 +166,7 @@ class MongoDbSessionHandlerTest extends TestCase
$collection->expects($this->once())
->method('deleteOne')
->with(array($this->options['id_field'] => 'foo'));
->with([$this->options['id_field'] => 'foo']);
$this->assertTrue($this->storage->destroy('foo'));
}

View File

@@ -27,7 +27,7 @@ class NativeFileSessionHandlerTest extends TestCase
{
public function testConstruct()
{
$storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler(sys_get_temp_dir()));
$storage = new NativeSessionStorage(['name' => 'TESTING'], new NativeFileSessionHandler(sys_get_temp_dir()));
$this->assertEquals('user', ini_get('session.save_handler'));
@@ -51,11 +51,11 @@ class NativeFileSessionHandlerTest extends TestCase
{
$base = sys_get_temp_dir();
return array(
array("$base/foo", "$base/foo", "$base/foo"),
array("5;$base/foo", "5;$base/foo", "$base/foo"),
array("5;0600;$base/foo", "5;0600;$base/foo", "$base/foo"),
);
return [
["$base/foo", "$base/foo", "$base/foo"],
["5;$base/foo", "5;$base/foo", "$base/foo"],
["5;0600;$base/foo", "5;0600;$base/foo", "$base/foo"],
];
}
/**
@@ -69,7 +69,7 @@ class NativeFileSessionHandlerTest extends TestCase
public function testConstructDefault()
{
$path = ini_get('session.save_path');
$storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler());
$storage = new NativeSessionStorage(['name' => 'TESTING'], new NativeFileSessionHandler());
$this->assertEquals($path, ini_get('session.save_path'));
}

View File

@@ -54,6 +54,6 @@ class NullSessionHandlerTest extends TestCase
public function getStorage()
{
return new NativeSessionStorage(array(), new NullSessionHandler());
return new NativeSessionStorage([], new NullSessionHandler());
}
}

View File

@@ -64,7 +64,7 @@ class PdoSessionHandlerTest extends TestCase
*/
public function testInexistentTable()
{
$storage = new PdoSessionHandler($this->getMemorySqlitePdo(), array('db_table' => 'inexistent_table'));
$storage = new PdoSessionHandler($this->getMemorySqlitePdo(), ['db_table' => 'inexistent_table']);
$storage->open('', 'sid');
$storage->read('id');
$storage->write('id', 'data');
@@ -143,7 +143,7 @@ class PdoSessionHandlerTest extends TestCase
$stream = $this->createStream($content);
$pdo->prepareResult->expects($this->once())->method('fetchAll')
->will($this->returnValue(array(array($stream, 42, time()))));
->will($this->returnValue([[$stream, 42, time()]]));
$storage = new PdoSessionHandler($pdo);
$result = $storage->read('foo');
@@ -171,7 +171,7 @@ class PdoSessionHandlerTest extends TestCase
$selectStmt->expects($this->atLeast(2))->method('fetchAll')
->will($this->returnCallback(function () use (&$exception, $stream) {
return $exception ? array(array($stream, 42, time())) : array();
return $exception ? [[$stream, 42, time()]] : [];
}));
$insertStmt->expects($this->once())->method('execute')
@@ -337,19 +337,19 @@ class PdoSessionHandlerTest extends TestCase
public function provideUrlDsnPairs()
{
yield array('mysql://localhost/test', 'mysql:host=localhost;dbname=test;');
yield array('mysql://localhost:56/test', 'mysql:host=localhost;port=56;dbname=test;');
yield array('mysql2://root:pwd@localhost/test', 'mysql:host=localhost;dbname=test;', 'root', 'pwd');
yield array('postgres://localhost/test', 'pgsql:host=localhost;dbname=test;');
yield array('postgresql://localhost:5634/test', 'pgsql:host=localhost;port=5634;dbname=test;');
yield array('postgres://root:pwd@localhost/test', 'pgsql:host=localhost;dbname=test;', 'root', 'pwd');
yield 'sqlite relative path' => array('sqlite://localhost/tmp/test', 'sqlite:tmp/test');
yield 'sqlite absolute path' => array('sqlite://localhost//tmp/test', 'sqlite:/tmp/test');
yield 'sqlite relative path without host' => array('sqlite:///tmp/test', 'sqlite:tmp/test');
yield 'sqlite absolute path without host' => array('sqlite3:////tmp/test', 'sqlite:/tmp/test');
yield array('sqlite://localhost/:memory:', 'sqlite::memory:');
yield array('mssql://localhost/test', 'sqlsrv:server=localhost;Database=test');
yield array('mssql://localhost:56/test', 'sqlsrv:server=localhost,56;Database=test');
yield ['mysql://localhost/test', 'mysql:host=localhost;dbname=test;'];
yield ['mysql://localhost:56/test', 'mysql:host=localhost;port=56;dbname=test;'];
yield ['mysql2://root:pwd@localhost/test', 'mysql:host=localhost;dbname=test;', 'root', 'pwd'];
yield ['postgres://localhost/test', 'pgsql:host=localhost;dbname=test;'];
yield ['postgresql://localhost:5634/test', 'pgsql:host=localhost;port=5634;dbname=test;'];
yield ['postgres://root:pwd@localhost/test', 'pgsql:host=localhost;dbname=test;', 'root', 'pwd'];
yield 'sqlite relative path' => ['sqlite://localhost/tmp/test', 'sqlite:tmp/test'];
yield 'sqlite absolute path' => ['sqlite://localhost//tmp/test', 'sqlite:/tmp/test'];
yield 'sqlite relative path without host' => ['sqlite:///tmp/test', 'sqlite:tmp/test'];
yield 'sqlite absolute path without host' => ['sqlite3:////tmp/test', 'sqlite:/tmp/test'];
yield ['sqlite://localhost/:memory:', 'sqlite::memory:'];
yield ['mssql://localhost/test', 'sqlsrv:server=localhost;Database=test'];
yield ['mssql://localhost:56/test', 'sqlsrv:server=localhost,56;Database=test'];
}
private function createStream($content)
@@ -387,7 +387,7 @@ class MockPdo extends \PDO
return parent::getAttribute($attribute);
}
public function prepare($statement, $driverOptions = array())
public function prepare($statement, $driverOptions = [])
{
return \is_callable($this->prepareResult)
? ($this->prepareResult)($statement, $driverOptions)

View File

@@ -17,6 +17,6 @@ class PredisClusterSessionHandlerTest extends AbstractRedisSessionHandlerTestCas
{
protected function createRedisClient(string $host): Client
{
return new Client(array(array('host' => $host)));
return new Client([['host' => $host]]);
}
}

View File

@@ -17,6 +17,6 @@ class PredisSessionHandlerTest extends AbstractRedisSessionHandlerTestCase
{
protected function createRedisClient(string $host): Client
{
return new Client(array('host' => $host));
return new Client(['host' => $host]);
}
}

View File

@@ -15,6 +15,6 @@ class RedisArraySessionHandlerTest extends AbstractRedisSessionHandlerTestCase
{
protected function createRedisClient(string $host): \RedisArray
{
return new \RedisArray(array($host));
return new \RedisArray([$host]);
}
}

View File

@@ -84,7 +84,7 @@ class StrictSessionHandlerTest extends TestCase
{
$handler = $this->getMockBuilder('SessionHandlerInterface')->getMock();
$handler->expects($this->exactly(2))->method('read')
->withConsecutive(array('id1'), array('id2'))
->withConsecutive(['id1'], ['id2'])
->will($this->onConsecutiveCalls('data1', 'data2'));
$proxy = new StrictSessionHandler($handler);

View File

@@ -26,26 +26,26 @@ class MetadataBagTest extends TestCase
*/
protected $bag;
protected $array = array();
protected $array = [];
protected function setUp()
{
parent::setUp();
$this->bag = new MetadataBag();
$this->array = array(MetadataBag::CREATED => 1234567, MetadataBag::UPDATED => 12345678, MetadataBag::LIFETIME => 0);
$this->array = [MetadataBag::CREATED => 1234567, MetadataBag::UPDATED => 12345678, MetadataBag::LIFETIME => 0];
$this->bag->initialize($this->array);
}
protected function tearDown()
{
$this->array = array();
$this->array = [];
$this->bag = null;
parent::tearDown();
}
public function testInitialize()
{
$sessionMetadata = array();
$sessionMetadata = [];
$bag1 = new MetadataBag();
$bag1->initialize($sessionMetadata);
@@ -82,7 +82,7 @@ class MetadataBagTest extends TestCase
public function testGetLifetime()
{
$bag = new MetadataBag();
$array = array(MetadataBag::CREATED => 1234567, MetadataBag::UPDATED => 12345678, MetadataBag::LIFETIME => 1000);
$array = [MetadataBag::CREATED => 1234567, MetadataBag::UPDATED => 12345678, MetadataBag::LIFETIME => 1000];
$bag->initialize($array);
$this->assertEquals(1000, $bag->getLifetime());
}
@@ -111,11 +111,11 @@ class MetadataBagTest extends TestCase
$timeStamp = time();
$created = $timeStamp - 15;
$sessionMetadata = array(
$sessionMetadata = [
MetadataBag::CREATED => $created,
MetadataBag::UPDATED => $created,
MetadataBag::LIFETIME => 1000,
);
];
$bag->initialize($sessionMetadata);
$this->assertEquals($created, $sessionMetadata[MetadataBag::UPDATED]);
@@ -127,11 +127,11 @@ class MetadataBagTest extends TestCase
$timeStamp = time();
$created = $timeStamp - 45;
$sessionMetadata = array(
$sessionMetadata = [
MetadataBag::CREATED => $created,
MetadataBag::UPDATED => $created,
MetadataBag::LIFETIME => 1000,
);
];
$bag->initialize($sessionMetadata);
$this->assertEquals($timeStamp, $sessionMetadata[MetadataBag::UPDATED]);

View File

@@ -45,10 +45,10 @@ class MockArraySessionStorageTest extends TestCase
$this->attributes = new AttributeBag();
$this->flashes = new FlashBag();
$this->data = array(
$this->attributes->getStorageKey() => array('foo' => 'bar'),
$this->flashes->getStorageKey() => array('notice' => 'hello'),
);
$this->data = [
$this->attributes->getStorageKey() => ['foo' => 'bar'],
$this->flashes->getStorageKey() => ['notice' => 'hello'],
];
$this->storage = new MockArraySessionStorage();
$this->storage->registerBag($this->flashes);
@@ -80,14 +80,14 @@ class MockArraySessionStorageTest extends TestCase
$id = $this->storage->getId();
$this->storage->regenerate();
$this->assertNotEquals($id, $this->storage->getId());
$this->assertEquals(array('foo' => 'bar'), $this->storage->getBag('attributes')->all());
$this->assertEquals(array('notice' => 'hello'), $this->storage->getBag('flashes')->peekAll());
$this->assertEquals(['foo' => 'bar'], $this->storage->getBag('attributes')->all());
$this->assertEquals(['notice' => 'hello'], $this->storage->getBag('flashes')->peekAll());
$id = $this->storage->getId();
$this->storage->regenerate(true);
$this->assertNotEquals($id, $this->storage->getId());
$this->assertEquals(array('foo' => 'bar'), $this->storage->getBag('attributes')->all());
$this->assertEquals(array('notice' => 'hello'), $this->storage->getBag('flashes')->peekAll());
$this->assertEquals(['foo' => 'bar'], $this->storage->getBag('attributes')->all());
$this->assertEquals(['notice' => 'hello'], $this->storage->getBag('flashes')->peekAll());
}
public function testGetId()
@@ -101,8 +101,8 @@ class MockArraySessionStorageTest extends TestCase
{
$this->storage->clear();
$this->assertSame(array(), $this->storage->getBag('attributes')->all());
$this->assertSame(array(), $this->storage->getBag('flashes')->peekAll());
$this->assertSame([], $this->storage->getBag('attributes')->all());
$this->assertSame([], $this->storage->getBag('flashes')->peekAll());
}
public function testClearStartsSession()

View File

@@ -91,7 +91,7 @@ class MockFileSessionStorageTest extends TestCase
$storage->start();
$this->assertEquals('108', $storage->getBag('attributes')->get('new'));
$this->assertTrue($storage->getBag('flashes')->has('newkey'));
$this->assertEquals(array('test'), $storage->getBag('flashes')->peek('newkey'));
$this->assertEquals(['test'], $storage->getBag('flashes')->peek('newkey'));
}
public function testMultipleInstances()

View File

@@ -56,7 +56,7 @@ class NativeSessionStorageTest extends TestCase
/**
* @return NativeSessionStorage
*/
protected function getStorage(array $options = array())
protected function getStorage(array $options = [])
{
$storage = new NativeSessionStorage($options);
$storage->registerBag(new AttributeBag());
@@ -157,19 +157,19 @@ class NativeSessionStorageTest extends TestCase
{
$this->iniSet('session.cache_limiter', 'nocache');
$storage = new NativeSessionStorage(array('cache_limiter' => 'public'));
$storage = new NativeSessionStorage(['cache_limiter' => 'public']);
$this->assertEquals('public', ini_get('session.cache_limiter'));
}
public function testCookieOptions()
{
$options = array(
$options = [
'cookie_lifetime' => 123456,
'cookie_path' => '/my/cookie/path',
'cookie_domain' => 'symfony.example.com',
'cookie_secure' => true,
'cookie_httponly' => false,
);
];
if (\PHP_VERSION_ID >= 70300) {
$options['cookie_samesite'] = 'lax';
@@ -177,7 +177,7 @@ class NativeSessionStorageTest extends TestCase
$this->getStorage($options);
$temp = session_get_cookie_params();
$gco = array();
$gco = [];
foreach ($temp as $key => $value) {
$gco['cookie_'.$key] = $value;
@@ -192,10 +192,10 @@ class NativeSessionStorageTest extends TestCase
$this->markTestSkipped('HHVM is not handled in this test case.');
}
$options = array(
$options = [
'url_rewriter.tags' => 'a=href',
'cache_expire' => '200',
);
];
$this->getStorage($options);
@@ -276,9 +276,9 @@ class NativeSessionStorageTest extends TestCase
public function testSetSessionOptionsOnceSessionStartedIsIgnored()
{
session_start();
$this->getStorage(array(
$this->getStorage([
'name' => 'something-else',
));
]);
// Assert no exception has been thrown by `getStorage()`
$this->addToAssertionCount(1);

View File

@@ -86,10 +86,10 @@ class PhpBridgeSessionStorageTest extends TestCase
$_SESSION['drak'] = 'loves symfony';
$storage->getBag('attributes')->set('symfony', 'greatness');
$key = $storage->getBag('attributes')->getStorageKey();
$this->assertEquals($_SESSION[$key], array('symfony' => 'greatness'));
$this->assertEquals($_SESSION[$key], ['symfony' => 'greatness']);
$this->assertEquals($_SESSION['drak'], 'loves symfony');
$storage->clear();
$this->assertEquals($_SESSION[$key], array());
$this->assertEquals($_SESSION[$key], []);
$this->assertEquals($_SESSION['drak'], 'loves symfony');
}
}

View File

@@ -127,7 +127,7 @@ class SessionHandlerProxyTest extends TestCase
*/
public function testValidateId()
{
$mock = $this->getMockBuilder(array('SessionHandlerInterface', 'SessionUpdateTimestampHandlerInterface'))->getMock();
$mock = $this->getMockBuilder(['SessionHandlerInterface', 'SessionUpdateTimestampHandlerInterface'])->getMock();
$mock->expects($this->once())
->method('validateId');
@@ -142,7 +142,7 @@ class SessionHandlerProxyTest extends TestCase
*/
public function testUpdateTimestamp()
{
$mock = $this->getMockBuilder(array('SessionHandlerInterface', 'SessionUpdateTimestampHandlerInterface'))->getMock();
$mock = $this->getMockBuilder(['SessionHandlerInterface', 'SessionUpdateTimestampHandlerInterface'])->getMock();
$mock->expects($this->once())
->method('updateTimestamp');