mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 13:02:24 +08:00
Raise version min PHP 7.3.
This commit is contained in:
@ -54,13 +54,13 @@ abstract class CacheTestCase extends TestCase
|
||||
*/
|
||||
abstract protected function getCacheInstance();
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->mockApplication();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
static::$time = null;
|
||||
static::$microtime = null;
|
||||
|
||||
@ -19,7 +19,7 @@ class DbCacheTest extends CacheTestCase
|
||||
private $_cacheInstance;
|
||||
private $_connection;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) {
|
||||
$this->markTestSkipped('pdo and pdo_mysql extensions are required.');
|
||||
|
||||
@ -24,7 +24,7 @@ class DbDependencyTest extends DatabaseTestCase
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ class DbQueryDependencyTest extends DatabaseTestCase
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
||||
@ -77,44 +77,9 @@ class FileCacheTest extends CacheTestCase
|
||||
$cacheFile = $refMethodGetCacheFile->invoke($cache, $normalizeKey);
|
||||
|
||||
$this->assertTrue($refMethodSet->invoke($cache, $key, $value));
|
||||
$this->assertContains($keyPrefix, basename($cacheFile));
|
||||
$this->assertStringContainsString($keyPrefix, basename($cacheFile));
|
||||
$this->assertEquals($expectedDirectoryName, basename(dirname($cacheFile)), $cacheFile);
|
||||
$this->assertTrue(is_dir(dirname($cacheFile)), 'File not found ' . $cacheFile);
|
||||
$this->assertEquals($value, $refMethodGet->invoke($cache, $key));
|
||||
}
|
||||
|
||||
public function testCacheRenewalOnDifferentOwnership()
|
||||
{
|
||||
$TRAVIS_SECOND_USER = getenv('TRAVIS_SECOND_USER');
|
||||
if (empty($TRAVIS_SECOND_USER)) {
|
||||
$this->markTestSkipped('Travis second user not found');
|
||||
}
|
||||
|
||||
$cache = $this->getCacheInstance();
|
||||
|
||||
$cacheValue = uniqid('value_');
|
||||
$cachePublicKey = uniqid('key_');
|
||||
$cacheInternalKey = $cache->buildKey($cachePublicKey);
|
||||
|
||||
static::$time = \time();
|
||||
$this->assertTrue($cache->set($cachePublicKey, $cacheValue, 2));
|
||||
$this->assertSame($cacheValue, $cache->get($cachePublicKey));
|
||||
|
||||
$refClass = new \ReflectionClass($cache);
|
||||
$refMethodGetCacheFile = $refClass->getMethod('getCacheFile');
|
||||
$refMethodGetCacheFile->setAccessible(true);
|
||||
$cacheFile = $refMethodGetCacheFile->invoke($cache, $cacheInternalKey);
|
||||
$refMethodGetCacheFile->setAccessible(false);
|
||||
|
||||
$output = array();
|
||||
$returnVar = null;
|
||||
exec(sprintf('sudo chown %s %s',
|
||||
escapeshellarg($TRAVIS_SECOND_USER),
|
||||
escapeshellarg($cacheFile)
|
||||
), $output, $returnVar);
|
||||
|
||||
$this->assertSame(0, $returnVar, 'Cannot change ownership of cache file to test cache renewal');
|
||||
|
||||
$this->assertTrue($cache->set($cachePublicKey, uniqid('value_2_'), 2), 'Cannot rebuild cache on different file ownership');
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ class MssqlCacheTest extends CacheTestCase
|
||||
private $_cacheInstance;
|
||||
private $_connection;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
if (!extension_loaded('pdo') || !extension_loaded('pdo_sqlsrv')) {
|
||||
$this->markTestSkipped('pdo and pdo_mssql extensions are required.');
|
||||
|
||||
@ -20,7 +20,7 @@ class PgSQLCacheTest extends DbCacheTest
|
||||
protected static $driverName = 'pgsql';
|
||||
private $_connection;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) {
|
||||
$this->markTestSkipped('pdo and pdo_pgsql extensions are required.');
|
||||
|
||||
Reference in New Issue
Block a user