Merge branch 'master' into redis

* master: (179 commits)
  Fixes #312. Additional docs on IDN in EmailValidator and UrlValidator.
  bug fix.
  Added composer extension.
  Added psr-0.
  Fixed breaking test.
  Fixed iii include path.
  reorganized the main repo to satisfy PSR-0.
  Fixed bootstrap asset registration issue.
  Widget::$transition removed, bundles depency fixed
  'yii/bootstrap/popover' bundle depency optimization
  Bundle names fixes, base widget fixes, other widgets fixes
  Fixed join query for AR.
  Responsive bundle depency fix
  Bundle names and depency fixes
  YiiBase move all after class definition
  YiiBase
  Reloaded
  Additional bootstrap packages
  New approach
  minor refactoring.
  ...

Conflicts:
	tests/unit/framework/caching/ApcCacheTest.php
	tests/unit/framework/caching/CacheTest.php
This commit is contained in:
Carsten Brandt
2013-05-22 12:49:31 +02:00
320 changed files with 23153 additions and 5042 deletions

View File

@@ -31,7 +31,8 @@ class ApcCacheTest extends CacheTest
return $this->_cacheInstance;
}
// TODO there seems to be a problem with APC returning cached value even if it is expired.
// TODO makes test fail on PHP 5.3.10-1ubuntu3.6 with Suhosin-Patch (cli) -- cebe
// TODO http://drupal.org/node/1278292
public function testExpire()
{
$this->markTestSkipped("APC keys are expiring only on the next request.");
}
}

View File

@@ -1,5 +1,17 @@
<?php
namespace yii\caching;
/**
* Mock for the time() function for caching classes
* @return int
*/
function time() {
return \yiiunit\framework\caching\CacheTest::$time ?: \time();
}
namespace yiiunit\framework\caching;
use yiiunit\TestCase;
use yii\caching\Cache;
@@ -8,6 +20,12 @@ use yii\caching\Cache;
*/
abstract class CacheTest extends TestCase
{
/**
* @var int virtual time to be returned by mocked time() function.
* Null means normal time() behavior.
*/
public static $time;
/**
* @return Cache
*/
@@ -19,6 +37,11 @@ abstract class CacheTest extends TestCase
$this->mockApplication();
}
protected function tearDown()
{
static::$time = null;
}
/**
* @return Cache
*/
@@ -110,7 +133,8 @@ abstract class CacheTest extends TestCase
$this->assertTrue($cache->set('expire_test', 'expire_test', 2));
sleep(1);
$this->assertEquals('expire_test', $cache->get('expire_test'));
sleep(2);
// wait a bit more than 2 sec to avoid random test failure
usleep(2500000);
$this->assertFalse($cache->get('expire_test'));
}

View File

@@ -1,5 +1,7 @@
<?php
namespace yiiunit\framework\caching;
use yii\caching\DbCache;
use yiiunit\TestCase;
@@ -70,4 +72,16 @@ class DbCacheTest extends CacheTest
}
return $this->_cacheInstance;
}
public function testExpire()
{
$cache = $this->getCacheInstance();
static::$time = \time();
$this->assertTrue($cache->set('expire_test', 'expire_test', 2));
static::$time++;
$this->assertEquals('expire_test', $cache->get('expire_test'));
static::$time++;
$this->assertFalse($cache->get('expire_test'));
}
}

View File

@@ -22,4 +22,16 @@ class FileCacheTest extends CacheTest
}
return $this->_cacheInstance;
}
public function testExpire()
{
$cache = $this->getCacheInstance();
static::$time = \time();
$this->assertTrue($cache->set('expire_test', 'expire_test', 2));
static::$time++;
$this->assertEquals('expire_test', $cache->get('expire_test'));
static::$time++;
$this->assertFalse($cache->get('expire_test'));
}
}