mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-29 13:57:50 +08:00
Merge branch 'master' of github.com:yiisoft/yii2 into mssql
This commit is contained in:
@@ -15,52 +15,54 @@ class DictionaryTest extends \yiiunit\TestCase
|
||||
* @var \yii\base\Dictionary
|
||||
*/
|
||||
protected $dictionary;
|
||||
protected $item1,$item2,$item3;
|
||||
protected $item1;
|
||||
protected $item2;
|
||||
protected $item3;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->dictionary=new Dictionary;
|
||||
$this->item1=new MapItem;
|
||||
$this->item2=new MapItem;
|
||||
$this->item3=new MapItem;
|
||||
$this->dictionary->add('key1',$this->item1);
|
||||
$this->dictionary->add('key2',$this->item2);
|
||||
$this->dictionary = new Dictionary;
|
||||
$this->item1 = new MapItem;
|
||||
$this->item2 = new MapItem;
|
||||
$this->item3 = new MapItem;
|
||||
$this->dictionary->add('key1', $this->item1);
|
||||
$this->dictionary->add('key2', $this->item2);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
$this->dictionary=null;
|
||||
$this->item1=null;
|
||||
$this->item2=null;
|
||||
$this->item3=null;
|
||||
$this->dictionary = null;
|
||||
$this->item1 = null;
|
||||
$this->item2 = null;
|
||||
$this->item3 = null;
|
||||
}
|
||||
|
||||
public function testConstruct()
|
||||
{
|
||||
$a=array(1,2,'key3'=>3);
|
||||
$dictionary=new Dictionary($a);
|
||||
$this->assertEquals(3,$dictionary->getCount());
|
||||
$a = array(1, 2, 'key3' => 3);
|
||||
$dictionary = new Dictionary($a);
|
||||
$this->assertEquals(3, $dictionary->getCount());
|
||||
$dictionary2=new Dictionary($this->dictionary);
|
||||
$this->assertEquals(2,$dictionary2->getCount());
|
||||
$this->assertEquals(2, $dictionary2->getCount());
|
||||
}
|
||||
|
||||
public function testGetCount()
|
||||
{
|
||||
$this->assertEquals(2,$this->dictionary->getCount());
|
||||
$this->assertEquals(2, $this->dictionary->getCount());
|
||||
}
|
||||
|
||||
public function testGetKeys()
|
||||
{
|
||||
$keys=$this->dictionary->getKeys();
|
||||
$this->assertEquals(2,count($keys));
|
||||
$this->assertEquals('key1',$keys[0]);
|
||||
$this->assertEquals('key2',$keys[1]);
|
||||
$keys = $this->dictionary->getKeys();
|
||||
$this->assertEquals(2, count($keys));
|
||||
$this->assertEquals('key1', $keys[0]);
|
||||
$this->assertEquals('key2', $keys[1]);
|
||||
}
|
||||
|
||||
public function testAdd()
|
||||
{
|
||||
$this->dictionary->add('key3',$this->item3);
|
||||
$this->assertEquals(3,$this->dictionary->getCount());
|
||||
$this->dictionary->add('key3', $this->item3);
|
||||
$this->assertEquals(3, $this->dictionary->getCount());
|
||||
$this->assertTrue($this->dictionary->has('key3'));
|
||||
|
||||
$this->dictionary[] = 'test';
|
||||
@@ -69,21 +71,21 @@ class DictionaryTest extends \yiiunit\TestCase
|
||||
public function testRemove()
|
||||
{
|
||||
$this->dictionary->remove('key1');
|
||||
$this->assertEquals(1,$this->dictionary->getCount());
|
||||
$this->assertEquals(1, $this->dictionary->getCount());
|
||||
$this->assertTrue(!$this->dictionary->has('key1'));
|
||||
$this->assertTrue($this->dictionary->remove('unknown key')===null);
|
||||
$this->assertTrue($this->dictionary->remove('unknown key') === null);
|
||||
}
|
||||
|
||||
public function testRemoveAll()
|
||||
{
|
||||
$this->dictionary->add('key3',$this->item3);
|
||||
$this->dictionary->add('key3', $this->item3);
|
||||
$this->dictionary->removeAll();
|
||||
$this->assertEquals(0,$this->dictionary->getCount());
|
||||
$this->assertEquals(0, $this->dictionary->getCount());
|
||||
$this->assertTrue(!$this->dictionary->has('key1') && !$this->dictionary->has('key2'));
|
||||
|
||||
$this->dictionary->add('key3',$this->item3);
|
||||
$this->dictionary->add('key3', $this->item3);
|
||||
$this->dictionary->removeAll(true);
|
||||
$this->assertEquals(0,$this->dictionary->getCount());
|
||||
$this->assertEquals(0, $this->dictionary->getCount());
|
||||
$this->assertTrue(!$this->dictionary->has('key1') && !$this->dictionary->has('key2'));
|
||||
}
|
||||
|
||||
@@ -96,7 +98,7 @@ class DictionaryTest extends \yiiunit\TestCase
|
||||
|
||||
public function testFromArray()
|
||||
{
|
||||
$array=array('key3'=>$this->item3,'key4'=>$this->item1);
|
||||
$array = array('key3' => $this->item3, 'key4' => $this->item1);
|
||||
$this->dictionary->copyFrom($array);
|
||||
|
||||
$this->assertEquals(2, $this->dictionary->getCount());
|
||||
@@ -109,21 +111,21 @@ class DictionaryTest extends \yiiunit\TestCase
|
||||
|
||||
public function testMergeWith()
|
||||
{
|
||||
$a=array('a'=>'v1','v2',array('2'),'c'=>array('3','c'=>'a'));
|
||||
$b=array('v22','a'=>'v11',array('2'),'c'=>array('c'=>'3','a'));
|
||||
$c=array('a'=>'v11','v2',array('2'),'c'=>array('3','c'=>'3','a'),'v22',array('2'));
|
||||
$dictionary=new Dictionary($a);
|
||||
$dictionary2=new Dictionary($b);
|
||||
$a = array('a' => 'v1', 'v2', array('2'), 'c' => array('3', 'c' => 'a'));
|
||||
$b = array('v22', 'a' => 'v11', array('2'), 'c' => array('c' => '3', 'a'));
|
||||
$c = array('a' => 'v11', 'v2', array('2'), 'c' => array('3', 'c' => '3', 'a'), 'v22', array('2'));
|
||||
$dictionary = new Dictionary($a);
|
||||
$dictionary2 = new Dictionary($b);
|
||||
$dictionary->mergeWith($dictionary2);
|
||||
$this->assertTrue($dictionary->toArray()===$c);
|
||||
$this->assertTrue($dictionary->toArray() === $c);
|
||||
|
||||
$array=array('key2'=>$this->item1,'key3'=>$this->item3);
|
||||
$this->dictionary->mergeWith($array,false);
|
||||
$this->assertEquals(3,$this->dictionary->getCount());
|
||||
$this->assertEquals($this->item1,$this->dictionary['key2']);
|
||||
$this->assertEquals($this->item3,$this->dictionary['key3']);
|
||||
$array = array('key2' => $this->item1, 'key3' => $this->item3);
|
||||
$this->dictionary->mergeWith($array, false);
|
||||
$this->assertEquals(3, $this->dictionary->getCount());
|
||||
$this->assertEquals($this->item1, $this->dictionary['key2']);
|
||||
$this->assertEquals($this->item3, $this->dictionary['key3']);
|
||||
$this->setExpectedException('yii\base\InvalidParamException');
|
||||
$this->dictionary->mergeWith($this,false);
|
||||
$this->dictionary->mergeWith($this, false);
|
||||
}
|
||||
|
||||
public function testRecursiveMergeWithTraversable(){
|
||||
@@ -135,7 +137,7 @@ class DictionaryTest extends \yiiunit\TestCase
|
||||
'k4' => $this->item3,
|
||||
))
|
||||
));
|
||||
$dictionary->mergeWith($obj,true);
|
||||
$dictionary->mergeWith($obj, true);
|
||||
|
||||
$this->assertEquals(3, $dictionary->getCount());
|
||||
$this->assertEquals($this->item1, $dictionary['k1']);
|
||||
@@ -145,23 +147,23 @@ class DictionaryTest extends \yiiunit\TestCase
|
||||
|
||||
public function testArrayRead()
|
||||
{
|
||||
$this->assertEquals($this->item1,$this->dictionary['key1']);
|
||||
$this->assertEquals($this->item2,$this->dictionary['key2']);
|
||||
$this->assertEquals(null,$this->dictionary['key3']);
|
||||
$this->assertEquals($this->item1, $this->dictionary['key1']);
|
||||
$this->assertEquals($this->item2, $this->dictionary['key2']);
|
||||
$this->assertEquals(null, $this->dictionary['key3']);
|
||||
}
|
||||
|
||||
public function testArrayWrite()
|
||||
{
|
||||
$this->dictionary['key3']=$this->item3;
|
||||
$this->assertEquals(3,$this->dictionary->getCount());
|
||||
$this->assertEquals($this->item3,$this->dictionary['key3']);
|
||||
$this->dictionary['key3'] = $this->item3;
|
||||
$this->assertEquals(3, $this->dictionary->getCount());
|
||||
$this->assertEquals($this->item3, $this->dictionary['key3']);
|
||||
|
||||
$this->dictionary['key1']=$this->item3;
|
||||
$this->assertEquals(3,$this->dictionary->getCount());
|
||||
$this->assertEquals($this->item3,$this->dictionary['key1']);
|
||||
$this->dictionary['key1'] = $this->item3;
|
||||
$this->assertEquals(3, $this->dictionary->getCount());
|
||||
$this->assertEquals($this->item3, $this->dictionary['key1']);
|
||||
|
||||
unset($this->dictionary['key2']);
|
||||
$this->assertEquals(2,$this->dictionary->getCount());
|
||||
$this->assertEquals(2, $this->dictionary->getCount());
|
||||
$this->assertTrue(!$this->dictionary->has('key2'));
|
||||
|
||||
unset($this->dictionary['unknown key']);
|
||||
@@ -169,22 +171,23 @@ class DictionaryTest extends \yiiunit\TestCase
|
||||
|
||||
public function testArrayForeach()
|
||||
{
|
||||
$n=0;
|
||||
$found=0;
|
||||
foreach($this->dictionary as $index=>$item)
|
||||
{
|
||||
$n = 0;
|
||||
$found = 0;
|
||||
foreach ($this->dictionary as $index => $item) {
|
||||
$n++;
|
||||
if($index==='key1' && $item===$this->item1)
|
||||
if ($index === 'key1' && $item === $this->item1) {
|
||||
$found++;
|
||||
if($index==='key2' && $item===$this->item2)
|
||||
}
|
||||
if ($index === 'key2' && $item === $this->item2) {
|
||||
$found++;
|
||||
}
|
||||
}
|
||||
$this->assertTrue($n==2 && $found==2);
|
||||
$this->assertTrue($n == 2 && $found == 2);
|
||||
}
|
||||
|
||||
public function testArrayMisc()
|
||||
{
|
||||
$this->assertEquals($this->dictionary->Count,count($this->dictionary));
|
||||
$this->assertEquals($this->dictionary->Count, count($this->dictionary));
|
||||
$this->assertTrue(isset($this->dictionary['key1']));
|
||||
$this->assertFalse(isset($this->dictionary['unknown key']));
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ class ModelTest extends TestCase
|
||||
|
||||
// iteration
|
||||
$attributes = array();
|
||||
foreach($speaker as $key => $attribute) {
|
||||
foreach ($speaker as $key => $attribute) {
|
||||
$attributes[$key] = $attribute;
|
||||
}
|
||||
$this->assertEquals(array(
|
||||
|
||||
@@ -15,39 +15,41 @@ class VectorTest extends \yiiunit\TestCase
|
||||
* @var Vector
|
||||
*/
|
||||
protected $vector;
|
||||
protected $item1, $item2, $item3;
|
||||
protected $item1;
|
||||
protected $item2;
|
||||
protected $item3;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->vector=new Vector;
|
||||
$this->item1=new ListItem;
|
||||
$this->item2=new ListItem;
|
||||
$this->item3=new ListItem;
|
||||
$this->vector = new Vector;
|
||||
$this->item1 = new ListItem;
|
||||
$this->item2 = new ListItem;
|
||||
$this->item3 = new ListItem;
|
||||
$this->vector->add($this->item1);
|
||||
$this->vector->add($this->item2);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
$this->vector=null;
|
||||
$this->item1=null;
|
||||
$this->item2=null;
|
||||
$this->item3=null;
|
||||
$this->vector = null;
|
||||
$this->item1 = null;
|
||||
$this->item2 = null;
|
||||
$this->item3 = null;
|
||||
}
|
||||
|
||||
public function testConstruct()
|
||||
{
|
||||
$a=array(1,2,3);
|
||||
$vector=new Vector($a);
|
||||
$this->assertEquals(3,$vector->getCount());
|
||||
$vector2=new Vector($this->vector);
|
||||
$this->assertEquals(2,$vector2->getCount());
|
||||
$a = array(1, 2, 3);
|
||||
$vector = new Vector($a);
|
||||
$this->assertEquals(3, $vector->getCount());
|
||||
$vector2 = new Vector($this->vector);
|
||||
$this->assertEquals(2, $vector2->getCount());
|
||||
}
|
||||
|
||||
public function testItemAt()
|
||||
{
|
||||
$a=array(1, 2, null, 4);
|
||||
$vector=new Vector($a);
|
||||
$a = array(1, 2, null, 4);
|
||||
$vector = new Vector($a);
|
||||
$this->assertEquals(1, $vector->itemAt(0));
|
||||
$this->assertEquals(2, $vector->itemAt(1));
|
||||
$this->assertNull($vector->itemAt(2));
|
||||
@@ -56,37 +58,37 @@ class VectorTest extends \yiiunit\TestCase
|
||||
|
||||
public function testGetCount()
|
||||
{
|
||||
$this->assertEquals(2,$this->vector->getCount());
|
||||
$this->assertEquals(2,$this->vector->Count);
|
||||
$this->assertEquals(2, $this->vector->getCount());
|
||||
$this->assertEquals(2, $this->vector->Count);
|
||||
}
|
||||
|
||||
public function testAdd()
|
||||
{
|
||||
$this->vector->add(null);
|
||||
$this->vector->add($this->item3);
|
||||
$this->assertEquals(4,$this->vector->getCount());
|
||||
$this->assertEquals(3,$this->vector->indexOf($this->item3));
|
||||
$this->assertEquals(4, $this->vector->getCount());
|
||||
$this->assertEquals(3, $this->vector->indexOf($this->item3));
|
||||
}
|
||||
|
||||
public function testInsertAt()
|
||||
{
|
||||
$this->vector->insertAt(0,$this->item3);
|
||||
$this->assertEquals(3,$this->vector->getCount());
|
||||
$this->assertEquals(2,$this->vector->indexOf($this->item2));
|
||||
$this->assertEquals(0,$this->vector->indexOf($this->item3));
|
||||
$this->assertEquals(1,$this->vector->indexOf($this->item1));
|
||||
$this->vector->insertAt(0, $this->item3);
|
||||
$this->assertEquals(3, $this->vector->getCount());
|
||||
$this->assertEquals(2, $this->vector->indexOf($this->item2));
|
||||
$this->assertEquals(0, $this->vector->indexOf($this->item3));
|
||||
$this->assertEquals(1, $this->vector->indexOf($this->item1));
|
||||
$this->setExpectedException('yii\base\InvalidParamException');
|
||||
$this->vector->insertAt(4,$this->item3);
|
||||
$this->vector->insertAt(4, $this->item3);
|
||||
}
|
||||
|
||||
public function testRemove()
|
||||
{
|
||||
$this->vector->remove($this->item1);
|
||||
$this->assertEquals(1,$this->vector->getCount());
|
||||
$this->assertEquals(-1,$this->vector->indexOf($this->item1));
|
||||
$this->assertEquals(0,$this->vector->indexOf($this->item2));
|
||||
$this->assertEquals(1, $this->vector->getCount());
|
||||
$this->assertEquals(-1, $this->vector->indexOf($this->item1));
|
||||
$this->assertEquals(0, $this->vector->indexOf($this->item2));
|
||||
|
||||
$this->assertEquals(false,$this->vector->remove($this->item1));
|
||||
$this->assertEquals(false, $this->vector->remove($this->item1));
|
||||
|
||||
}
|
||||
|
||||
@@ -94,9 +96,9 @@ class VectorTest extends \yiiunit\TestCase
|
||||
{
|
||||
$this->vector->add($this->item3);
|
||||
$this->vector->removeAt(1);
|
||||
$this->assertEquals(-1,$this->vector->indexOf($this->item2));
|
||||
$this->assertEquals(1,$this->vector->indexOf($this->item3));
|
||||
$this->assertEquals(0,$this->vector->indexOf($this->item1));
|
||||
$this->assertEquals(-1, $this->vector->indexOf($this->item2));
|
||||
$this->assertEquals(1, $this->vector->indexOf($this->item3));
|
||||
$this->assertEquals(0, $this->vector->indexOf($this->item1));
|
||||
$this->setExpectedException('yii\base\InvalidParamException');
|
||||
$this->vector->removeAt(2);
|
||||
}
|
||||
@@ -105,15 +107,15 @@ class VectorTest extends \yiiunit\TestCase
|
||||
{
|
||||
$this->vector->add($this->item3);
|
||||
$this->vector->removeAll();
|
||||
$this->assertEquals(0,$this->vector->getCount());
|
||||
$this->assertEquals(-1,$this->vector->indexOf($this->item1));
|
||||
$this->assertEquals(-1,$this->vector->indexOf($this->item2));
|
||||
$this->assertEquals(0, $this->vector->getCount());
|
||||
$this->assertEquals(-1, $this->vector->indexOf($this->item1));
|
||||
$this->assertEquals(-1, $this->vector->indexOf($this->item2));
|
||||
|
||||
$this->vector->add($this->item3);
|
||||
$this->vector->removeAll(true);
|
||||
$this->assertEquals(0,$this->vector->getCount());
|
||||
$this->assertEquals(-1,$this->vector->indexOf($this->item1));
|
||||
$this->assertEquals(-1,$this->vector->indexOf($this->item2));
|
||||
$this->assertEquals(0, $this->vector->getCount());
|
||||
$this->assertEquals(-1, $this->vector->indexOf($this->item1));
|
||||
$this->assertEquals(-1, $this->vector->indexOf($this->item2));
|
||||
}
|
||||
|
||||
public function testHas()
|
||||
@@ -125,30 +127,32 @@ class VectorTest extends \yiiunit\TestCase
|
||||
|
||||
public function testIndexOf()
|
||||
{
|
||||
$this->assertEquals(0,$this->vector->indexOf($this->item1));
|
||||
$this->assertEquals(1,$this->vector->indexOf($this->item2));
|
||||
$this->assertEquals(-1,$this->vector->indexOf($this->item3));
|
||||
$this->assertEquals(0, $this->vector->indexOf($this->item1));
|
||||
$this->assertEquals(1, $this->vector->indexOf($this->item2));
|
||||
$this->assertEquals(-1, $this->vector->indexOf($this->item3));
|
||||
}
|
||||
|
||||
public function testFromArray()
|
||||
{
|
||||
$array=array($this->item3,$this->item1);
|
||||
$array = array($this->item3, $this->item1);
|
||||
$this->vector->copyFrom($array);
|
||||
$this->assertTrue(count($array)==2 && $this->vector[0]===$this->item3 && $this->vector[1]===$this->item1);
|
||||
$this->assertTrue(count($array) == 2 && $this->vector[0] === $this->item3 && $this->vector[1] === $this->item1);
|
||||
$this->setExpectedException('yii\base\InvalidParamException');
|
||||
$this->vector->copyFrom($this);
|
||||
}
|
||||
|
||||
public function testMergeWith()
|
||||
{
|
||||
$array=array($this->item3,$this->item1);
|
||||
$array = array($this->item3, $this->item1);
|
||||
$this->vector->mergeWith($array);
|
||||
$this->assertTrue($this->vector->getCount()==4 && $this->vector[0]===$this->item1 && $this->vector[3]===$this->item1);
|
||||
$this->assertTrue($this->vector->getCount() == 4 && $this->vector[0] === $this->item1 &&
|
||||
$this->vector[3] === $this->item1);
|
||||
|
||||
$a=array(1);
|
||||
$vector=new Vector($a);
|
||||
$a = array(1);
|
||||
$vector = new Vector($a);
|
||||
$this->vector->mergeWith($vector);
|
||||
$this->assertTrue($this->vector->getCount()==5 && $this->vector[0]===$this->item1 && $this->vector[3]===$this->item1 && $this->vector[4]===1);
|
||||
$this->assertTrue($this->vector->getCount() == 5 && $this->vector[0] === $this->item1 &&
|
||||
$this->vector[3] === $this->item1 && $this->vector[4] === 1);
|
||||
|
||||
$this->setExpectedException('yii\base\InvalidParamException');
|
||||
$this->vector->mergeWith($this);
|
||||
@@ -156,37 +160,40 @@ class VectorTest extends \yiiunit\TestCase
|
||||
|
||||
public function testToArray()
|
||||
{
|
||||
$array=$this->vector->toArray();
|
||||
$this->assertTrue(count($array)==2 && $array[0]===$this->item1 && $array[1]===$this->item2);
|
||||
$array = $this->vector->toArray();
|
||||
$this->assertTrue(count($array) == 2 && $array[0] === $this->item1 && $array[1] === $this->item2);
|
||||
}
|
||||
|
||||
public function testArrayRead()
|
||||
{
|
||||
$this->assertTrue($this->vector[0]===$this->item1);
|
||||
$this->assertTrue($this->vector[1]===$this->item2);
|
||||
$this->assertTrue($this->vector[0] === $this->item1);
|
||||
$this->assertTrue($this->vector[1] === $this->item2);
|
||||
$this->setExpectedException('yii\base\InvalidParamException');
|
||||
$a=$this->vector[2];
|
||||
$a = $this->vector[2];
|
||||
}
|
||||
|
||||
public function testGetIterator()
|
||||
{
|
||||
$n=0;
|
||||
$found=0;
|
||||
foreach($this->vector as $index=>$item)
|
||||
{
|
||||
foreach($this->vector as $a=>$b); // test of iterator
|
||||
$n = 0;
|
||||
$found = 0;
|
||||
foreach ($this->vector as $index => $item) {
|
||||
foreach ($this->vector as $a => $b) {
|
||||
// test of iterator
|
||||
}
|
||||
$n++;
|
||||
if($index===0 && $item===$this->item1)
|
||||
if ($index === 0 && $item === $this->item1) {
|
||||
$found++;
|
||||
if($index===1 && $item===$this->item2)
|
||||
}
|
||||
if ($index === 1 && $item === $this->item2) {
|
||||
$found++;
|
||||
}
|
||||
}
|
||||
$this->assertTrue($n==2 && $found==2);
|
||||
$this->assertTrue($n == 2 && $found == 2);
|
||||
}
|
||||
|
||||
public function testArrayMisc()
|
||||
{
|
||||
$this->assertEquals($this->vector->Count,count($this->vector));
|
||||
$this->assertEquals($this->vector->Count, count($this->vector));
|
||||
$this->assertTrue(isset($this->vector[1]));
|
||||
$this->assertFalse(isset($this->vector[2]));
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class DbCacheTest extends CacheTest
|
||||
*/
|
||||
function getConnection($reset = true)
|
||||
{
|
||||
if($this->_connection === null) {
|
||||
if ($this->_connection === null) {
|
||||
$databases = $this->getParam('databases');
|
||||
$params = $databases['mysql'];
|
||||
$db = new \yii\db\Connection;
|
||||
@@ -61,7 +61,7 @@ class DbCacheTest extends CacheTest
|
||||
*/
|
||||
protected function getCacheInstance()
|
||||
{
|
||||
if($this->_cacheInstance === null) {
|
||||
if ($this->_cacheInstance === null) {
|
||||
$this->_cacheInstance = new DbCache(array(
|
||||
'db' => $this->getConnection(),
|
||||
));
|
||||
|
||||
@@ -15,7 +15,7 @@ class FileCacheTest extends CacheTest
|
||||
*/
|
||||
protected function getCacheInstance()
|
||||
{
|
||||
if($this->_cacheInstance === null) {
|
||||
if ($this->_cacheInstance === null) {
|
||||
$this->_cacheInstance = new FileCache(array(
|
||||
'cachePath' => '@yiiunit/runtime/cache',
|
||||
));
|
||||
|
||||
@@ -15,11 +15,11 @@ class MemCacheTest extends CacheTest
|
||||
*/
|
||||
protected function getCacheInstance()
|
||||
{
|
||||
if(!extension_loaded("memcache")) {
|
||||
if (!extension_loaded("memcache")) {
|
||||
$this->markTestSkipped("memcache not installed. Skipping.");
|
||||
}
|
||||
|
||||
if($this->_cacheInstance === null) {
|
||||
if ($this->_cacheInstance === null) {
|
||||
$this->_cacheInstance = new MemCache();
|
||||
}
|
||||
return $this->_cacheInstance;
|
||||
|
||||
@@ -15,11 +15,11 @@ class MemCachedTest extends CacheTest
|
||||
*/
|
||||
protected function getCacheInstance()
|
||||
{
|
||||
if(!extension_loaded("memcached")) {
|
||||
if (!extension_loaded("memcached")) {
|
||||
$this->markTestSkipped("memcached not installed. Skipping.");
|
||||
}
|
||||
|
||||
if($this->_cacheInstance === null) {
|
||||
if ($this->_cacheInstance === null) {
|
||||
$this->_cacheInstance = new MemCache(array(
|
||||
'useMemcached' => true,
|
||||
));
|
||||
|
||||
@@ -15,15 +15,15 @@ class WinCacheTest extends CacheTest
|
||||
*/
|
||||
protected function getCacheInstance()
|
||||
{
|
||||
if(!extension_loaded('wincache')) {
|
||||
if (!extension_loaded('wincache')) {
|
||||
$this->markTestSkipped("Wincache not installed. Skipping.");
|
||||
}
|
||||
|
||||
if(!ini_get('wincache.ucenabled')) {
|
||||
if (!ini_get('wincache.ucenabled')) {
|
||||
$this->markTestSkipped("Wincache user cache disabled. Skipping.");
|
||||
}
|
||||
|
||||
if($this->_cacheInstance === null) {
|
||||
if ($this->_cacheInstance === null) {
|
||||
$this->_cacheInstance = new WinCache();
|
||||
}
|
||||
return $this->_cacheInstance;
|
||||
|
||||
@@ -15,11 +15,11 @@ class XCacheTest extends CacheTest
|
||||
*/
|
||||
protected function getCacheInstance()
|
||||
{
|
||||
if(!function_exists("xcache_isset")) {
|
||||
if (!function_exists("xcache_isset")) {
|
||||
$this->markTestSkipped("XCache not installed. Skipping.");
|
||||
}
|
||||
|
||||
if($this->_cacheInstance === null) {
|
||||
if ($this->_cacheInstance === null) {
|
||||
$this->_cacheInstance = new XCache();
|
||||
}
|
||||
return $this->_cacheInstance;
|
||||
|
||||
@@ -15,11 +15,11 @@ class ZendDataCacheTest extends CacheTest
|
||||
*/
|
||||
protected function getCacheInstance()
|
||||
{
|
||||
if(!function_exists("zend_shm_cache_store")) {
|
||||
if (!function_exists("zend_shm_cache_store")) {
|
||||
$this->markTestSkipped("Zend Data cache not installed. Skipping.");
|
||||
}
|
||||
|
||||
if($this->_cacheInstance === null) {
|
||||
if ($this->_cacheInstance === null) {
|
||||
$this->_cacheInstance = new ZendDataCache();
|
||||
}
|
||||
return $this->_cacheInstance;
|
||||
|
||||
@@ -140,7 +140,7 @@ class CommandTest extends \yiiunit\DatabaseTestCase
|
||||
$db = $this->getConnection();
|
||||
|
||||
// bindParam
|
||||
$sql = 'INSERT INTO tbl_customer(email,name,address) VALUES (:email, :name, :address)';
|
||||
$sql = 'INSERT INTO tbl_customer(email, name, address) VALUES (:email, :name, :address)';
|
||||
$command = $db->createCommand($sql);
|
||||
$email = 'user4@example.com';
|
||||
$name = 'user4';
|
||||
|
||||
@@ -20,7 +20,7 @@ class QueryTest extends \yiiunit\DatabaseTestCase
|
||||
|
||||
$query = new Query;
|
||||
$query->select('id, name', 'something')->distinct(true);
|
||||
$this->assertEquals(array('id','name'), $query->select);
|
||||
$this->assertEquals(array('id', 'name'), $query->select);
|
||||
$this->assertTrue($query->distinct);
|
||||
$this->assertEquals('something', $query->selectOption);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class StringHelperTest extends \yii\test\TestCase
|
||||
'car' => 'cars',
|
||||
);
|
||||
|
||||
foreach($testData as $testIn => $testOut) {
|
||||
foreach ($testData as $testIn => $testOut) {
|
||||
$this->assertEquals($testOut, StringHelper::pluralize($testIn));
|
||||
$this->assertEquals(ucfirst($testOut), ucfirst(StringHelper::pluralize($testIn)));
|
||||
}
|
||||
|
||||
@@ -164,8 +164,8 @@ abstract class ManagerTestBase extends TestCase
|
||||
public function testExecuteBizRule()
|
||||
{
|
||||
$this->assertTrue($this->auth->executeBizRule(null, array(), null));
|
||||
$this->assertTrue($this->auth->executeBizRule('return 1==true;', array(), null));
|
||||
$this->assertTrue($this->auth->executeBizRule('return $params[0]==$params[1];', array(1, '1'), null));
|
||||
$this->assertTrue($this->auth->executeBizRule('return 1 == true;', array(), null));
|
||||
$this->assertTrue($this->auth->executeBizRule('return $params[0] == $params[1];', array(1, '1'), null));
|
||||
$this->assertFalse($this->auth->executeBizRule('invalid', array(), null));
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ abstract class ManagerTestBase extends TestCase
|
||||
$this->auth->createOperation('updatePost', 'update a post');
|
||||
$this->auth->createOperation('deletePost', 'delete a post');
|
||||
|
||||
$task = $this->auth->createTask('updateOwnPost', 'update a post by author himself', 'return $params["authorID"]==$params["userID"];');
|
||||
$task = $this->auth->createTask('updateOwnPost', 'update a post by author himself', 'return $params["authorID"] == $params["userID"];');
|
||||
$task->addChild('updatePost');
|
||||
|
||||
$role = $this->auth->createRole('reader');
|
||||
|
||||
Reference in New Issue
Block a user