Commit f68bed0c by Qiang Xue

fixed exception.

parent e6672984
...@@ -184,7 +184,7 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co ...@@ -184,7 +184,7 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co
* Copies iterable data into the dictionary. * Copies iterable data into the dictionary.
* Note, existing data in the dictionary will be cleared first. * Note, existing data in the dictionary will be cleared first.
* @param mixed $data the data to be copied from, must be an array or an object implementing `Traversable` * @param mixed $data the data to be copied from, must be an array or an object implementing `Traversable`
* @throws InvalidCallException if data is neither an array nor an iterator. * @throws InvalidParamException if data is neither an array nor an iterator.
*/ */
public function copyFrom($data) public function copyFrom($data)
{ {
...@@ -199,7 +199,7 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co ...@@ -199,7 +199,7 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co
$this->add($key, $value); $this->add($key, $value);
} }
} else { } else {
throw new InvalidCallException('Data must be either an array or an object implementing Traversable.'); throw new InvalidParamException('Data must be either an array or an object implementing Traversable.');
} }
} }
...@@ -216,7 +216,7 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co ...@@ -216,7 +216,7 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co
* *
* @param array|\Traversable $data the data to be merged with. It must be an array or object implementing Traversable * @param array|\Traversable $data the data to be merged with. It must be an array or object implementing Traversable
* @param boolean $recursive whether the merging should be recursive. * @param boolean $recursive whether the merging should be recursive.
* @throws InvalidCallException if data is neither an array nor an object implementing `Traversable`. * @throws InvalidParamException if data is neither an array nor an object implementing `Traversable`.
*/ */
public function mergeWith($data, $recursive = true) public function mergeWith($data, $recursive = true)
{ {
...@@ -240,7 +240,7 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co ...@@ -240,7 +240,7 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co
} }
} }
} else { } else {
throw new InvalidCallException('The data to be merged with must be an array or an object implementing Traversable.'); throw new InvalidParamException('The data to be merged with must be an array or an object implementing Traversable.');
} }
} }
......
...@@ -101,7 +101,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta ...@@ -101,7 +101,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta
* Returns the item at the specified index. * Returns the item at the specified index.
* @param integer $index the index of the item * @param integer $index the index of the item
* @return mixed the item at the index * @return mixed the item at the index
* @throws InvalidCallException if the index is out of range * @throws InvalidParamException if the index is out of range
*/ */
public function itemAt($index) public function itemAt($index)
{ {
...@@ -110,7 +110,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta ...@@ -110,7 +110,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta
} elseif ($index >= 0 && $index < $this->_c) { // in case the value is null } elseif ($index >= 0 && $index < $this->_c) { // in case the value is null
return $this->_d[$index]; return $this->_d[$index];
} else { } else {
throw new InvalidCallException('Index out of range: ' . $index); throw new InvalidParamException('Index out of range: ' . $index);
} }
} }
...@@ -132,7 +132,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta ...@@ -132,7 +132,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta
* one step towards the end. * one step towards the end.
* @param integer $index the specified position. * @param integer $index the specified position.
* @param mixed $item new item to be inserted into the vector * @param mixed $item new item to be inserted into the vector
* @throws InvalidCallException if the index specified is out of range, or the vector is read-only. * @throws InvalidParamException if the index specified is out of range, or the vector is read-only.
*/ */
public function insertAt($index, $item) public function insertAt($index, $item)
{ {
...@@ -142,7 +142,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta ...@@ -142,7 +142,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta
array_splice($this->_d, $index, 0, array($item)); array_splice($this->_d, $index, 0, array($item));
$this->_c++; $this->_c++;
} else { } else {
throw new InvalidCallException('Index out of range: ' . $index); throw new InvalidParamException('Index out of range: ' . $index);
} }
} }
...@@ -169,7 +169,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta ...@@ -169,7 +169,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta
* Removes an item at the specified position. * Removes an item at the specified position.
* @param integer $index the index of the item to be removed. * @param integer $index the index of the item to be removed.
* @return mixed the removed item. * @return mixed the removed item.
* @throws InvalidCallException if the index is out of range, or the vector is read only. * @throws InvalidParamException if the index is out of range, or the vector is read only.
*/ */
public function removeAt($index) public function removeAt($index)
{ {
...@@ -183,7 +183,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta ...@@ -183,7 +183,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta
return $item; return $item;
} }
} else { } else {
throw new InvalidCallException('Index out of range: ' . $index); throw new InvalidParamException('Index out of range: ' . $index);
} }
} }
...@@ -242,7 +242,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta ...@@ -242,7 +242,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta
* Copies iterable data into the vector. * Copies iterable data into the vector.
* Note, existing data in the vector will be cleared first. * Note, existing data in the vector will be cleared first.
* @param mixed $data the data to be copied from, must be an array or an object implementing `Traversable` * @param mixed $data the data to be copied from, must be an array or an object implementing `Traversable`
* @throws InvalidCallException if data is neither an array nor an object implementing `Traversable`. * @throws InvalidParamException if data is neither an array nor an object implementing `Traversable`.
*/ */
public function copyFrom($data) public function copyFrom($data)
{ {
...@@ -257,7 +257,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta ...@@ -257,7 +257,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta
$this->add($item); $this->add($item);
} }
} else { } else {
throw new InvalidCallException('Data must be either an array or an object implementing Traversable.'); throw new InvalidParamException('Data must be either an array or an object implementing Traversable.');
} }
} }
...@@ -265,7 +265,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta ...@@ -265,7 +265,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta
* Merges iterable data into the vector. * Merges iterable data into the vector.
* New items will be appended to the end of the existing items. * New items will be appended to the end of the existing items.
* @param array|\Traversable $data the data to be merged with. It must be an array or object implementing Traversable * @param array|\Traversable $data the data to be merged with. It must be an array or object implementing Traversable
* @throws InvalidCallException if data is neither an array nor an object implementing `Traversable`. * @throws InvalidParamException if data is neither an array nor an object implementing `Traversable`.
*/ */
public function mergeWith($data) public function mergeWith($data)
{ {
...@@ -277,7 +277,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta ...@@ -277,7 +277,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta
$this->add($item); $this->add($item);
} }
} else { } else {
throw new InvalidCallException('The data to be merged with must be an array or an object implementing Traversable.'); throw new InvalidParamException('The data to be merged with must be an array or an object implementing Traversable.');
} }
} }
......
...@@ -122,7 +122,7 @@ class View extends Component ...@@ -122,7 +122,7 @@ class View extends Component
* @param array $params the parameters that should be made available in the view. The PHP function `extract()` * @param array $params the parameters that should be made available in the view. The PHP function `extract()`
* will be called on this variable to extract the variables from this parameter. * will be called on this variable to extract the variables from this parameter.
* @return string the rendering result * @return string the rendering result
* @throws InvalidCallException if the view file cannot be found * @throws InvalidParamException if the view file cannot be found
* @see findViewFile() * @see findViewFile()
*/ */
public function renderPartial($view, $params = array()) public function renderPartial($view, $params = array())
...@@ -131,7 +131,7 @@ class View extends Component ...@@ -131,7 +131,7 @@ class View extends Component
if ($file !== false) { if ($file !== false) {
return $this->renderFile($file, $params); return $this->renderFile($file, $params);
} else { } else {
throw new InvalidCallException("Unable to find the view file for view '$view'."); throw new InvalidParamException("Unable to find the view file for view '$view'.");
} }
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace yii\db; namespace yii\db;
use yii\base\Model; use yii\base\Model;
use yii\base\InvalidParamException;
use yii\base\Event; use yii\base\Event;
use yii\base\ModelEvent; use yii\base\ModelEvent;
use yii\base\UnknownMethodException; use yii\base\UnknownMethodException;
...@@ -1045,7 +1046,7 @@ class ActiveRecord extends Model ...@@ -1045,7 +1046,7 @@ class ActiveRecord extends Model
* It can be declared in either the Active Record class itself or one of its behaviors. * It can be declared in either the Active Record class itself or one of its behaviors.
* @param string $name the relation name * @param string $name the relation name
* @return ActiveRelation the relation object * @return ActiveRelation the relation object
* @throws InvalidCallException if the named relation does not exist. * @throws InvalidParamException if the named relation does not exist.
*/ */
public function getRelation($name) public function getRelation($name)
{ {
...@@ -1057,7 +1058,7 @@ class ActiveRecord extends Model ...@@ -1057,7 +1058,7 @@ class ActiveRecord extends Model
} }
} catch (UnknownMethodException $e) { } catch (UnknownMethodException $e) {
} }
throw new InvalidCallException(get_class($this) . ' has no relation named "' . $name . '".'); throw new InvalidParamException(get_class($this) . ' has no relation named "' . $name . '".');
} }
/** /**
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
namespace yii\db; namespace yii\db;
use yii\base\InvalidCallException; use yii\base\InvalidParamException;
/** /**
* TableSchema represents the metadata of a database table. * TableSchema represents the metadata of a database table.
...@@ -83,7 +83,7 @@ class TableSchema extends \yii\base\Object ...@@ -83,7 +83,7 @@ class TableSchema extends \yii\base\Object
/** /**
* Manually specifies the primary key for this table. * Manually specifies the primary key for this table.
* @param string|array $keys the primary key (can be composite) * @param string|array $keys the primary key (can be composite)
* @throws InvalidCallException if the specified key cannot be found in the table. * @throws InvalidParamException if the specified key cannot be found in the table.
*/ */
public function fixPrimaryKey($keys) public function fixPrimaryKey($keys)
{ {
...@@ -98,7 +98,7 @@ class TableSchema extends \yii\base\Object ...@@ -98,7 +98,7 @@ class TableSchema extends \yii\base\Object
if (isset($this->columns[$key])) { if (isset($this->columns[$key])) {
$this->columns[$key]->isPrimaryKey = true; $this->columns[$key]->isPrimaryKey = true;
} else { } else {
throw new InvalidCallException("Primary key '$key' cannot be found in table '{$this->name}'."); throw new InvalidParamException("Primary key '$key' cannot be found in table '{$this->name}'.");
} }
} }
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
namespace yii\db\mysql; namespace yii\db\mysql;
use yii\db\Exception; use yii\db\Exception;
use yii\base\InvalidCallException; use yii\base\InvalidParamException;
/** /**
* QueryBuilder is the query builder for MySQL databases. * QueryBuilder is the query builder for MySQL databases.
...@@ -98,7 +98,7 @@ class QueryBuilder extends \yii\db\QueryBuilder ...@@ -98,7 +98,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
* @param mixed $value the value for the primary key of the next new row inserted. If this is not set, * @param mixed $value the value for the primary key of the next new row inserted. If this is not set,
* the next new row's primary key will have a value 1. * the next new row's primary key will have a value 1.
* @return string the SQL statement for resetting sequence * @return string the SQL statement for resetting sequence
* @throws InvalidCallException if the table does not exist or there is no sequence associated with the table. * @throws InvalidParamException if the table does not exist or there is no sequence associated with the table.
*/ */
public function resetSequence($tableName, $value = null) public function resetSequence($tableName, $value = null)
{ {
...@@ -113,9 +113,9 @@ class QueryBuilder extends \yii\db\QueryBuilder ...@@ -113,9 +113,9 @@ class QueryBuilder extends \yii\db\QueryBuilder
} }
return "ALTER TABLE $tableName AUTO_INCREMENT=$value"; return "ALTER TABLE $tableName AUTO_INCREMENT=$value";
} elseif ($table === null) { } elseif ($table === null) {
throw new InvalidCallException("Table not found: $tableName"); throw new InvalidParamException("Table not found: $tableName");
} else { } else {
throw new InvalidCallException("There is not sequence associated with table '$tableName'.'"); throw new InvalidParamException("There is not sequence associated with table '$tableName'.'");
} }
} }
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
namespace yii\db\sqlite; namespace yii\db\sqlite;
use yii\db\Exception; use yii\db\Exception;
use yii\base\InvalidParamException;
use yii\base\NotSupportedException; use yii\base\NotSupportedException;
use yii\base\InvalidCallException;
/** /**
* QueryBuilder is the query builder for SQLite databases. * QueryBuilder is the query builder for SQLite databases.
...@@ -50,7 +50,7 @@ class QueryBuilder extends \yii\db\QueryBuilder ...@@ -50,7 +50,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
* @param mixed $value the value for the primary key of the next new row inserted. If this is not set, * @param mixed $value the value for the primary key of the next new row inserted. If this is not set,
* the next new row's primary key will have a value 1. * the next new row's primary key will have a value 1.
* @return string the SQL statement for resetting sequence * @return string the SQL statement for resetting sequence
* @throws InvalidCallException if the table does not exist or there is no sequence associated with the table. * @throws InvalidParamException if the table does not exist or there is no sequence associated with the table.
*/ */
public function resetSequence($tableName, $value = null) public function resetSequence($tableName, $value = null)
{ {
...@@ -70,9 +70,9 @@ class QueryBuilder extends \yii\db\QueryBuilder ...@@ -70,9 +70,9 @@ class QueryBuilder extends \yii\db\QueryBuilder
} catch (Exception $e) { } catch (Exception $e) {
} }
} elseif ($table === null) { } elseif ($table === null) {
throw new InvalidCallException("Table not found: $tableName"); throw new InvalidParamException("Table not found: $tableName");
} else { } else {
throw new InvalidCallException("There is not sequence associated with table '$tableName'.'"); throw new InvalidParamException("There is not sequence associated with table '$tableName'.'");
} }
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
namespace yii\util; namespace yii\util;
use yii\base\InvalidCallException; use yii\base\InvalidParamException;
/** /**
* ArrayHelper provides additional array functionality you can use in your * ArrayHelper provides additional array functionality you can use in your
...@@ -242,7 +242,7 @@ class ArrayHelper ...@@ -242,7 +242,7 @@ class ArrayHelper
* value is for sorting strings in case-insensitive manner. Please refer to * value is for sorting strings in case-insensitive manner. Please refer to
* See [PHP manual](http://php.net/manual/en/function.sort.php) for more details. * See [PHP manual](http://php.net/manual/en/function.sort.php) for more details.
* When sorting by multiple keys with different sort flags, use an array of sort flags. * When sorting by multiple keys with different sort flags, use an array of sort flags.
* @throws InvalidCallException if the $ascending or $sortFlag parameters do not have * @throws InvalidParamException if the $ascending or $sortFlag parameters do not have
* correct number of elements as that of $key. * correct number of elements as that of $key.
*/ */
public static function multisort(&$array, $key, $ascending = true, $sortFlag = SORT_REGULAR) public static function multisort(&$array, $key, $ascending = true, $sortFlag = SORT_REGULAR)
...@@ -255,12 +255,12 @@ class ArrayHelper ...@@ -255,12 +255,12 @@ class ArrayHelper
if (is_scalar($ascending)) { if (is_scalar($ascending)) {
$ascending = array_fill(0, $n, $ascending); $ascending = array_fill(0, $n, $ascending);
} elseif (count($ascending) !== $n) { } elseif (count($ascending) !== $n) {
throw new InvalidCallException('The length of $ascending parameter must be the same as that of $keys.'); throw new InvalidParamException('The length of $ascending parameter must be the same as that of $keys.');
} }
if (is_scalar($sortFlag)) { if (is_scalar($sortFlag)) {
$sortFlag = array_fill(0, $n, $sortFlag); $sortFlag = array_fill(0, $n, $sortFlag);
} elseif (count($sortFlag) !== $n) { } elseif (count($sortFlag) !== $n) {
throw new InvalidCallException('The length of $ascending parameter must be the same as that of $keys.'); throw new InvalidParamException('The length of $ascending parameter must be the same as that of $keys.');
} }
$args = array(); $args = array();
foreach ($keys as $i => $key) { foreach ($keys as $i => $key) {
......
...@@ -17,14 +17,15 @@ namespace yii\util; ...@@ -17,14 +17,15 @@ namespace yii\util;
* recursive display of some peculiar variables. * recursive display of some peculiar variables.
* *
* VarDumper can be used as follows, * VarDumper can be used as follows,
* <pre> *
* ~~~
* VarDumper::dump($var); * VarDumper::dump($var);
* </pre> * ~~~
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
class VarDumper class CVarDumper
{ {
private static $_objects; private static $_objects;
private static $_output; private static $_output;
...@@ -38,9 +39,9 @@ class VarDumper ...@@ -38,9 +39,9 @@ class VarDumper
* @param integer $depth maximum depth that the dumper should go into the variable. Defaults to 10. * @param integer $depth maximum depth that the dumper should go into the variable. Defaults to 10.
* @param boolean $highlight whether the result should be syntax-highlighted * @param boolean $highlight whether the result should be syntax-highlighted
*/ */
public static function dump($var,$depth=10,$highlight=false) public static function dump($var, $depth = 10, $highlight = false)
{ {
echo self::dumpAsString($var,$depth,$highlight); echo self::dumpAsString($var, $depth, $highlight);
} }
/** /**
...@@ -52,16 +53,15 @@ class VarDumper ...@@ -52,16 +53,15 @@ class VarDumper
* @param boolean $highlight whether the result should be syntax-highlighted * @param boolean $highlight whether the result should be syntax-highlighted
* @return string the string representation of the variable * @return string the string representation of the variable
*/ */
public static function dumpAsString($var,$depth=10,$highlight=false) public static function dumpAsString($var, $depth = 10, $highlight = false)
{ {
self::$_output=''; self::$_output = '';
self::$_objects=array(); self::$_objects = array();
self::$_depth=$depth; self::$_depth = $depth;
self::dumpInternal($var,0); self::dumpInternal($var, 0);
if($highlight) if ($highlight) {
{ $result = highlight_string("<?php\n" . self::$_output, true);
$result=highlight_string("<?php\n".self::$_output,true); self::$_output = preg_replace('/&lt;\\?php<br \\/>/', '', $result, 1);
self::$_output=preg_replace('/&lt;\\?php<br \\/>/','',$result,1);
} }
return self::$_output; return self::$_output;
} }
...@@ -70,73 +70,65 @@ class VarDumper ...@@ -70,73 +70,65 @@ class VarDumper
* @param mixed $var variable to be dumped * @param mixed $var variable to be dumped
* @param integer $level depth level * @param integer $level depth level
*/ */
private static function dumpInternal($var,$level) private static function dumpInternal($var, $level)
{ {
switch(gettype($var)) switch (gettype($var)) {
{
case 'boolean': case 'boolean':
self::$_output.=$var?'true':'false'; self::$_output .= $var ? 'true' : 'false';
break; break;
case 'integer': case 'integer':
self::$_output.="$var"; self::$_output .= "$var";
break; break;
case 'double': case 'double':
self::$_output.="$var"; self::$_output .= "$var";
break; break;
case 'string': case 'string':
self::$_output.="'".addslashes($var)."'"; self::$_output .= "'" . addslashes($var) . "'";
break; break;
case 'resource': case 'resource':
self::$_output.='{resource}'; self::$_output .= '{resource}';
break; break;
case 'NULL': case 'NULL':
self::$_output.="null"; self::$_output .= "null";
break; break;
case 'unknown type': case 'unknown type':
self::$_output.='{unknown}'; self::$_output .= '{unknown}';
break; break;
case 'array': case 'array':
if(self::$_depth<=$level) if (self::$_depth <= $level) {
self::$_output.='array(...)'; self::$_output .= 'array(...)';
else if(empty($var)) } elseif (empty($var)) {
self::$_output.='array()'; self::$_output .= 'array()';
else } else {
{ $keys = array_keys($var);
$keys=array_keys($var); $spaces = str_repeat(' ', $level * 4);
$spaces=str_repeat(' ',$level*4); self::$_output .= "array\n" . $spaces . '(';
self::$_output.="array\n".$spaces.'('; foreach ($keys as $key) {
foreach($keys as $key) self::$_output .= "\n" . $spaces . ' ';
{ self::dumpInternal($key, 0);
if(gettype($key)=='integer') self::$_output .= ' => ';
$key2=$key; self::dumpInternal($var[$key], $level + 1);
else
$key2="'".str_replace("'","\\'",$key)."'";
self::$_output.="\n".$spaces." $key2 => ";
self::$_output.=self::dumpInternal($var[$key],$level+1);
} }
self::$_output.="\n".$spaces.')'; self::$_output .= "\n" . $spaces . ')';
} }
break; break;
case 'object': case 'object':
if(($id=array_search($var,self::$_objects,true))!==false) if (($id = array_search($var, self::$_objects, true)) !== false) {
self::$_output.=get_class($var).'#'.($id+1).'(...)'; self::$_output .= get_class($var) . '#' . ($id + 1) . '(...)';
else if(self::$_depth<=$level) } elseif (self::$_depth <= $level) {
self::$_output.=get_class($var).'(...)'; self::$_output .= get_class($var) . '(...)';
else } else {
{ $id = self::$_objects[] = $var;
$id=array_push(self::$_objects,$var); $className = get_class($var);
$className=get_class($var); $members = (array)$var;
$members=(array)$var; $spaces = str_repeat(' ', $level * 4);
$spaces=str_repeat(' ',$level*4); self::$_output .= "$className#$id\n" . $spaces . '(';
self::$_output.="$className#$id\n".$spaces.'('; foreach ($members as $key => $value) {
foreach($members as $key=>$value) $keyDisplay = strtr(trim($key), array("\0" => ':'));
{ self::$_output .= "\n" . $spaces . " [$keyDisplay] => ";
$keyDisplay=strtr(trim($key),array("\0"=>':')); self::dumpInternal($value, $level + 1);
self::$_output.="\n".$spaces." [$keyDisplay] => ";
self::$_output.=self::dumpInternal($value,$level+1);
} }
self::$_output.="\n".$spaces.')'; self::$_output .= "\n" . $spaces . ')';
} }
break; break;
} }
......
...@@ -103,7 +103,7 @@ class DictionaryTest extends \yiiunit\TestCase ...@@ -103,7 +103,7 @@ class DictionaryTest extends \yiiunit\TestCase
$this->assertEquals($this->item3, $this->dictionary['key3']); $this->assertEquals($this->item3, $this->dictionary['key3']);
$this->assertEquals($this->item1, $this->dictionary['key4']); $this->assertEquals($this->item1, $this->dictionary['key4']);
$this->setExpectedException('yii\base\InvalidCallException'); $this->setExpectedException('yii\base\InvalidParamException');
$this->dictionary->copyFrom($this); $this->dictionary->copyFrom($this);
} }
...@@ -122,7 +122,7 @@ class DictionaryTest extends \yiiunit\TestCase ...@@ -122,7 +122,7 @@ class DictionaryTest extends \yiiunit\TestCase
$this->assertEquals(3,$this->dictionary->getCount()); $this->assertEquals(3,$this->dictionary->getCount());
$this->assertEquals($this->item1,$this->dictionary['key2']); $this->assertEquals($this->item1,$this->dictionary['key2']);
$this->assertEquals($this->item3,$this->dictionary['key3']); $this->assertEquals($this->item3,$this->dictionary['key3']);
$this->setExpectedException('yii\base\InvalidCallException'); $this->setExpectedException('yii\base\InvalidParamException');
$this->dictionary->mergeWith($this,false); $this->dictionary->mergeWith($this,false);
} }
......
...@@ -75,7 +75,7 @@ class VectorTest extends \yiiunit\TestCase ...@@ -75,7 +75,7 @@ class VectorTest extends \yiiunit\TestCase
$this->assertEquals(2,$this->vector->indexOf($this->item2)); $this->assertEquals(2,$this->vector->indexOf($this->item2));
$this->assertEquals(0,$this->vector->indexOf($this->item3)); $this->assertEquals(0,$this->vector->indexOf($this->item3));
$this->assertEquals(1,$this->vector->indexOf($this->item1)); $this->assertEquals(1,$this->vector->indexOf($this->item1));
$this->setExpectedException('yii\base\InvalidCallException'); $this->setExpectedException('yii\base\InvalidParamException');
$this->vector->insertAt(4,$this->item3); $this->vector->insertAt(4,$this->item3);
} }
...@@ -97,7 +97,7 @@ class VectorTest extends \yiiunit\TestCase ...@@ -97,7 +97,7 @@ class VectorTest extends \yiiunit\TestCase
$this->assertEquals(-1,$this->vector->indexOf($this->item2)); $this->assertEquals(-1,$this->vector->indexOf($this->item2));
$this->assertEquals(1,$this->vector->indexOf($this->item3)); $this->assertEquals(1,$this->vector->indexOf($this->item3));
$this->assertEquals(0,$this->vector->indexOf($this->item1)); $this->assertEquals(0,$this->vector->indexOf($this->item1));
$this->setExpectedException('yii\base\InvalidCallException'); $this->setExpectedException('yii\base\InvalidParamException');
$this->vector->removeAt(2); $this->vector->removeAt(2);
} }
...@@ -135,7 +135,7 @@ class VectorTest extends \yiiunit\TestCase ...@@ -135,7 +135,7 @@ class VectorTest extends \yiiunit\TestCase
$array=array($this->item3,$this->item1); $array=array($this->item3,$this->item1);
$this->vector->copyFrom($array); $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\InvalidCallException'); $this->setExpectedException('yii\base\InvalidParamException');
$this->vector->copyFrom($this); $this->vector->copyFrom($this);
} }
...@@ -150,7 +150,7 @@ class VectorTest extends \yiiunit\TestCase ...@@ -150,7 +150,7 @@ class VectorTest extends \yiiunit\TestCase
$this->vector->mergeWith($vector); $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\InvalidCallException'); $this->setExpectedException('yii\base\InvalidParamException');
$this->vector->mergeWith($this); $this->vector->mergeWith($this);
} }
...@@ -164,7 +164,7 @@ class VectorTest extends \yiiunit\TestCase ...@@ -164,7 +164,7 @@ class VectorTest extends \yiiunit\TestCase
{ {
$this->assertTrue($this->vector[0]===$this->item1); $this->assertTrue($this->vector[0]===$this->item1);
$this->assertTrue($this->vector[1]===$this->item2); $this->assertTrue($this->vector[1]===$this->item2);
$this->setExpectedException('yii\base\InvalidCallException'); $this->setExpectedException('yii\base\InvalidParamException');
$a=$this->vector[2]; $a=$this->vector[2];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment