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

@@ -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');