Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
ed8b7952
Commit
ed8b7952
authored
Jan 17, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamed exception classes.
parent
b51d3474
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
92 additions
and
111 deletions
+92
-111
Application.php
framework/base/Application.php
+3
-3
BadPropertyException.php
framework/base/BadPropertyException.php
+0
-21
Component.php
framework/base/Component.php
+9
-9
Dictionary.php
framework/base/Dictionary.php
+4
-4
InvalidCallException.php
framework/base/InvalidCallException.php
+3
-3
InvalidConfigException.php
framework/base/InvalidConfigException.php
+3
-3
Object.php
framework/base/Object.php
+9
-9
UnknownMethodException.php
framework/base/UnknownMethodException.php
+3
-3
UnknownPropertyException.php
framework/base/UnknownPropertyException.php
+3
-3
Vector.php
framework/base/Vector.php
+10
-10
View.php
framework/base/View.php
+4
-4
ActiveRecord.php
framework/db/ActiveRecord.php
+12
-12
ActiveRelation.php
framework/db/ActiveRelation.php
+3
-3
DataReader.php
framework/db/DataReader.php
+3
-3
Schema.php
framework/db/Schema.php
+3
-3
TableSchema.php
framework/db/TableSchema.php
+3
-3
ArrayHelper.php
framework/util/ArrayHelper.php
+5
-3
ComponentTest.php
tests/unit/framework/base/ComponentTest.php
+3
-3
DictionaryTest.php
tests/unit/framework/base/DictionaryTest.php
+2
-2
ObjectTest.php
tests/unit/framework/base/ObjectTest.php
+2
-2
VectorTest.php
tests/unit/framework/base/VectorTest.php
+5
-5
No files found.
framework/base/Application.php
View file @
ed8b7952
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
namespace
yii\base
;
namespace
yii\base
;
use
yii\base\Exception
;
use
yii\base\
InvalidCall
Exception
;
/**
/**
* Application is the base class for all application classes.
* Application is the base class for all application classes.
...
@@ -236,13 +236,13 @@ class Application extends Module
...
@@ -236,13 +236,13 @@ class Application extends Module
/**
/**
* Sets the directory that stores runtime files.
* Sets the directory that stores runtime files.
* @param string $path the directory that stores runtime files.
* @param string $path the directory that stores runtime files.
* @throws
BadParam
Exception if the directory does not exist or is not writable
* @throws
InvalidCall
Exception if the directory does not exist or is not writable
*/
*/
public
function
setRuntimePath
(
$path
)
public
function
setRuntimePath
(
$path
)
{
{
$p
=
\Yii
::
getAlias
(
$path
);
$p
=
\Yii
::
getAlias
(
$path
);
if
(
$p
===
false
||
!
is_dir
(
$p
)
||
!
is_writable
(
$path
))
{
if
(
$p
===
false
||
!
is_dir
(
$p
)
||
!
is_writable
(
$path
))
{
throw
new
BadParam
Exception
(
"Application runtime path
\"
$path
\"
is invalid. Please make sure it is a directory writable by the Web server process."
);
throw
new
InvalidCall
Exception
(
"Application runtime path
\"
$path
\"
is invalid. Please make sure it is a directory writable by the Web server process."
);
}
else
{
}
else
{
$this
->
_runtimePath
=
$p
;
$this
->
_runtimePath
=
$p
;
}
}
...
...
framework/base/BadPropertyException.php
deleted
100644 → 0
View file @
b51d3474
<?php
/**
* BadPropertyException class file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\base
;
/**
* BadPropertyException represents an exception caused by accessing unknown object properties.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
BadPropertyException
extends
\Exception
{
}
framework/base/Component.php
View file @
ed8b7952
...
@@ -42,7 +42,7 @@ class Component extends \yii\base\Object
...
@@ -42,7 +42,7 @@ class Component extends \yii\base\Object
* @param string $name the property name
* @param string $name the property name
* @return mixed the property value, event handlers attached to the event,
* @return mixed the property value, event handlers attached to the event,
* the behavior, or the value of a behavior's property
* the behavior, or the value of a behavior's property
* @throws
Bad
PropertyException if the property is not defined
* @throws
Unknown
PropertyException if the property is not defined
* @see __set
* @see __set
*/
*/
public
function
__get
(
$name
)
public
function
__get
(
$name
)
...
@@ -60,7 +60,7 @@ class Component extends \yii\base\Object
...
@@ -60,7 +60,7 @@ class Component extends \yii\base\Object
}
}
}
}
}
}
throw
new
Bad
PropertyException
(
'Getting unknown property: '
.
get_class
(
$this
)
.
'.'
.
$name
);
throw
new
Unknown
PropertyException
(
'Getting unknown property: '
.
get_class
(
$this
)
.
'.'
.
$name
);
}
}
/**
/**
...
@@ -76,7 +76,7 @@ class Component extends \yii\base\Object
...
@@ -76,7 +76,7 @@ class Component extends \yii\base\Object
* will be implicitly called when executing `$component->property = $value;`.
* will be implicitly called when executing `$component->property = $value;`.
* @param string $name the property name or the event name
* @param string $name the property name or the event name
* @param mixed $value the property value
* @param mixed $value the property value
* @throws
Bad
PropertyException if the property is not defined or read-only.
* @throws
Unknown
PropertyException if the property is not defined or read-only.
* @see __get
* @see __get
*/
*/
public
function
__set
(
$name
,
$value
)
public
function
__set
(
$name
,
$value
)
...
@@ -106,9 +106,9 @@ class Component extends \yii\base\Object
...
@@ -106,9 +106,9 @@ class Component extends \yii\base\Object
}
}
}
}
if
(
method_exists
(
$this
,
'get'
.
$name
))
{
if
(
method_exists
(
$this
,
'get'
.
$name
))
{
throw
new
BadProperty
Exception
(
'Setting read-only property: '
.
get_class
(
$this
)
.
'.'
.
$name
);
throw
new
InvalidCall
Exception
(
'Setting read-only property: '
.
get_class
(
$this
)
.
'.'
.
$name
);
}
else
{
}
else
{
throw
new
Bad
PropertyException
(
'Setting unknown property: '
.
get_class
(
$this
)
.
'.'
.
$name
);
throw
new
Unknown
PropertyException
(
'Setting unknown property: '
.
get_class
(
$this
)
.
'.'
.
$name
);
}
}
}
}
...
@@ -151,7 +151,7 @@ class Component extends \yii\base\Object
...
@@ -151,7 +151,7 @@ class Component extends \yii\base\Object
* Do not call this method directly as it is a PHP magic method that
* Do not call this method directly as it is a PHP magic method that
* will be implicitly called when executing `unset($component->property)`.
* will be implicitly called when executing `unset($component->property)`.
* @param string $name the property name
* @param string $name the property name
* @throws
Bad
PropertyException if the property is read only.
* @throws
Unknown
PropertyException if the property is read only.
*/
*/
public
function
__unset
(
$name
)
public
function
__unset
(
$name
)
{
{
...
@@ -170,7 +170,7 @@ class Component extends \yii\base\Object
...
@@ -170,7 +170,7 @@ class Component extends \yii\base\Object
}
}
}
}
if
(
method_exists
(
$this
,
'get'
.
$name
))
{
if
(
method_exists
(
$this
,
'get'
.
$name
))
{
throw
new
BadProperty
Exception
(
'Unsetting read-only property: '
.
get_class
(
$this
)
.
'.'
.
$name
);
throw
new
InvalidCall
Exception
(
'Unsetting read-only property: '
.
get_class
(
$this
)
.
'.'
.
$name
);
}
}
}
}
...
@@ -186,7 +186,7 @@ class Component extends \yii\base\Object
...
@@ -186,7 +186,7 @@ class Component extends \yii\base\Object
* @param string $name the method name
* @param string $name the method name
* @param array $params method parameters
* @param array $params method parameters
* @return mixed the method return value
* @return mixed the method return value
* @throws
Bad
MethodException when calling unknown method
* @throws
Unknown
MethodException when calling unknown method
*/
*/
public
function
__call
(
$name
,
$params
)
public
function
__call
(
$name
,
$params
)
{
{
...
@@ -205,7 +205,7 @@ class Component extends \yii\base\Object
...
@@ -205,7 +205,7 @@ class Component extends \yii\base\Object
}
}
}
}
throw
new
Bad
MethodException
(
'Calling unknown method: '
.
get_class
(
$this
)
.
"::
$name
()"
);
throw
new
Unknown
MethodException
(
'Calling unknown method: '
.
get_class
(
$this
)
.
"::
$name
()"
);
}
}
/**
/**
...
...
framework/base/Dictionary.php
View file @
ed8b7952
...
@@ -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
BadParam
Exception if data is neither an array nor an iterator.
* @throws
InvalidCall
Exception 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
BadParam
Exception
(
'Data must be either an array or an object implementing Traversable.'
);
throw
new
InvalidCall
Exception
(
'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
BadParam
Exception if data is neither an array nor an object implementing `Traversable`.
* @throws
InvalidCall
Exception 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
BadParam
Exception
(
'The data to be merged with must be an array or an object implementing Traversable.'
);
throw
new
InvalidCall
Exception
(
'The data to be merged with must be an array or an object implementing Traversable.'
);
}
}
}
}
...
...
framework/base/
Ba
dCallException.php
→
framework/base/
Invali
dCallException.php
View file @
ed8b7952
<?php
<?php
/**
/**
*
Ba
dCallException class file.
*
Invali
dCallException class file.
*
*
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008 Yii Software LLC
* @copyright Copyright © 2008 Yii Software LLC
...
@@ -10,12 +10,12 @@
...
@@ -10,12 +10,12 @@
namespace
yii\base
;
namespace
yii\base
;
/**
/**
*
Ba
dCallException represents an exception caused by calling a method in a wrong way.
*
Invali
dCallException represents an exception caused by calling a method in a wrong way.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
* @since 2.0
*/
*/
class
Ba
dCallException
extends
\Exception
class
Invali
dCallException
extends
\Exception
{
{
}
}
framework/base/
Ba
dConfigException.php
→
framework/base/
Invali
dConfigException.php
View file @
ed8b7952
<?php
<?php
/**
/**
*
Ba
dConfigException class file.
*
Invali
dConfigException class file.
*
*
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008 Yii Software LLC
* @copyright Copyright © 2008 Yii Software LLC
...
@@ -10,12 +10,12 @@
...
@@ -10,12 +10,12 @@
namespace
yii\base
;
namespace
yii\base
;
/**
/**
*
Ba
dConfigException represents an exception caused by incorrect object configuration.
*
Invali
dConfigException represents an exception caused by incorrect object configuration.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
* @since 2.0
*/
*/
class
Ba
dConfigException
extends
\Exception
class
Invali
dConfigException
extends
\Exception
{
{
}
}
framework/base/Object.php
View file @
ed8b7952
...
@@ -58,7 +58,7 @@ class Object
...
@@ -58,7 +58,7 @@ class Object
* @param string $name the property name
* @param string $name the property name
* @return mixed the property value, event handlers attached to the event,
* @return mixed the property value, event handlers attached to the event,
* the named behavior, or the value of a behavior's property
* the named behavior, or the value of a behavior's property
* @throws
Bad
PropertyException if the property is not defined
* @throws
Unknown
PropertyException if the property is not defined
* @see __set
* @see __set
*/
*/
public
function
__get
(
$name
)
public
function
__get
(
$name
)
...
@@ -67,7 +67,7 @@ class Object
...
@@ -67,7 +67,7 @@ class Object
if
(
method_exists
(
$this
,
$getter
))
{
if
(
method_exists
(
$this
,
$getter
))
{
return
$this
->
$getter
();
return
$this
->
$getter
();
}
else
{
}
else
{
throw
new
Bad
PropertyException
(
'Getting unknown property: '
.
get_class
(
$this
)
.
'.'
.
$name
);
throw
new
Unknown
PropertyException
(
'Getting unknown property: '
.
get_class
(
$this
)
.
'.'
.
$name
);
}
}
}
}
...
@@ -78,7 +78,7 @@ class Object
...
@@ -78,7 +78,7 @@ class Object
* will be implicitly called when executing `$object->property = $value;`.
* will be implicitly called when executing `$object->property = $value;`.
* @param string $name the property name or the event name
* @param string $name the property name or the event name
* @param mixed $value the property value
* @param mixed $value the property value
* @throws
Bad
PropertyException if the property is not defined or read-only.
* @throws
Unknown
PropertyException if the property is not defined or read-only.
* @see __get
* @see __get
*/
*/
public
function
__set
(
$name
,
$value
)
public
function
__set
(
$name
,
$value
)
...
@@ -87,9 +87,9 @@ class Object
...
@@ -87,9 +87,9 @@ class Object
if
(
method_exists
(
$this
,
$setter
))
{
if
(
method_exists
(
$this
,
$setter
))
{
$this
->
$setter
(
$value
);
$this
->
$setter
(
$value
);
}
elseif
(
method_exists
(
$this
,
'get'
.
$name
))
{
}
elseif
(
method_exists
(
$this
,
'get'
.
$name
))
{
throw
new
BadProperty
Exception
(
'Setting read-only property: '
.
get_class
(
$this
)
.
'.'
.
$name
);
throw
new
InvalidCall
Exception
(
'Setting read-only property: '
.
get_class
(
$this
)
.
'.'
.
$name
);
}
else
{
}
else
{
throw
new
Bad
PropertyException
(
'Setting unknown property: '
.
get_class
(
$this
)
.
'.'
.
$name
);
throw
new
Unknown
PropertyException
(
'Setting unknown property: '
.
get_class
(
$this
)
.
'.'
.
$name
);
}
}
}
}
...
@@ -122,7 +122,7 @@ class Object
...
@@ -122,7 +122,7 @@ class Object
* Note that if the property is not defined, this method will do nothing.
* Note that if the property is not defined, this method will do nothing.
* If the property is read-only, it will throw an exception.
* If the property is read-only, it will throw an exception.
* @param string $name the property name
* @param string $name the property name
* @throws
Bad
PropertyException if the property is read only.
* @throws
Unknown
PropertyException if the property is read only.
*/
*/
public
function
__unset
(
$name
)
public
function
__unset
(
$name
)
{
{
...
@@ -130,7 +130,7 @@ class Object
...
@@ -130,7 +130,7 @@ class Object
if
(
method_exists
(
$this
,
$setter
))
{
if
(
method_exists
(
$this
,
$setter
))
{
$this
->
$setter
(
null
);
$this
->
$setter
(
null
);
}
elseif
(
method_exists
(
$this
,
'get'
.
$name
))
{
}
elseif
(
method_exists
(
$this
,
'get'
.
$name
))
{
throw
new
BadProperty
Exception
(
'Unsetting read-only property: '
.
get_class
(
$this
)
.
'.'
.
$name
);
throw
new
InvalidCall
Exception
(
'Unsetting read-only property: '
.
get_class
(
$this
)
.
'.'
.
$name
);
}
}
}
}
...
@@ -143,7 +143,7 @@ class Object
...
@@ -143,7 +143,7 @@ class Object
* will be implicitly called when an unknown method is being invoked.
* will be implicitly called when an unknown method is being invoked.
* @param string $name the method name
* @param string $name the method name
* @param array $params method parameters
* @param array $params method parameters
* @throws
Bad
MethodException when calling unknown method
* @throws
Unknown
MethodException when calling unknown method
* @return mixed the method return value
* @return mixed the method return value
*/
*/
public
function
__call
(
$name
,
$params
)
public
function
__call
(
$name
,
$params
)
...
@@ -155,7 +155,7 @@ class Object
...
@@ -155,7 +155,7 @@ class Object
return
call_user_func_array
(
$func
,
$params
);
return
call_user_func_array
(
$func
,
$params
);
}
}
}
}
throw
new
Bad
MethodException
(
'Unknown method: '
.
get_class
(
$this
)
.
"::
$name
()"
);
throw
new
Unknown
MethodException
(
'Unknown method: '
.
get_class
(
$this
)
.
"::
$name
()"
);
}
}
/**
/**
...
...
framework/base/
Bad
MethodException.php
→
framework/base/
Unknown
MethodException.php
View file @
ed8b7952
<?php
<?php
/**
/**
*
Bad
MethodException class file.
*
Unknown
MethodException class file.
*
*
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008 Yii Software LLC
* @copyright Copyright © 2008 Yii Software LLC
...
@@ -10,12 +10,12 @@
...
@@ -10,12 +10,12 @@
namespace
yii\base
;
namespace
yii\base
;
/**
/**
*
Bad
MethodException represents an exception caused by accessing unknown object methods.
*
Unknown
MethodException represents an exception caused by accessing unknown object methods.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
* @since 2.0
*/
*/
class
Bad
MethodException
extends
\Exception
class
Unknown
MethodException
extends
\Exception
{
{
}
}
framework/base/
BadParam
Exception.php
→
framework/base/
UnknownProperty
Exception.php
View file @
ed8b7952
<?php
<?php
/**
/**
*
BadParam
Exception class file.
*
UnknownProperty
Exception class file.
*
*
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008 Yii Software LLC
* @copyright Copyright © 2008 Yii Software LLC
...
@@ -10,12 +10,12 @@
...
@@ -10,12 +10,12 @@
namespace
yii\base
;
namespace
yii\base
;
/**
/**
*
BadParamException represents an exception caused by incorrect method parameter
s.
*
UnknownPropertyException represents an exception caused by accessing unknown object propertie
s.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
* @since 2.0
*/
*/
class
BadParam
Exception
extends
\Exception
class
UnknownProperty
Exception
extends
\Exception
{
{
}
}
framework/base/Vector.php
View file @
ed8b7952
...
@@ -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
BadParam
Exception if the index is out of range
* @throws
InvalidCall
Exception 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
BadParam
Exception
(
'Index out of range: '
.
$index
);
throw
new
InvalidCall
Exception
(
'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
BadParam
Exception if the index specified is out of range, or the vector is read-only.
* @throws
InvalidCall
Exception 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
BadParam
Exception
(
'Index out of range: '
.
$index
);
throw
new
InvalidCall
Exception
(
'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
BadParam
Exception if the index is out of range, or the vector is read only.
* @throws
InvalidCall
Exception 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
BadParam
Exception
(
'Index out of range: '
.
$index
);
throw
new
InvalidCall
Exception
(
'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
BadParam
Exception if data is neither an array nor an object implementing `Traversable`.
* @throws
InvalidCall
Exception 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
BadParam
Exception
(
'Data must be either an array or an object implementing Traversable.'
);
throw
new
InvalidCall
Exception
(
'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
BadParam
Exception if data is neither an array nor an object implementing `Traversable`.
* @throws
InvalidCall
Exception 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
BadParam
Exception
(
'The data to be merged with must be an array or an object implementing Traversable.'
);
throw
new
InvalidCall
Exception
(
'The data to be merged with must be an array or an object implementing Traversable.'
);
}
}
}
}
...
...
framework/base/View.php
View file @
ed8b7952
...
@@ -105,7 +105,7 @@ class View extends Component
...
@@ -105,7 +105,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
BadParam
Exception if the view file cannot be found
* @throws
InvalidCall
Exception if the view file cannot be found
*/
*/
public
function
renderPartial
(
$view
,
$params
=
array
())
public
function
renderPartial
(
$view
,
$params
=
array
())
{
{
...
@@ -113,7 +113,7 @@ class View extends Component
...
@@ -113,7 +113,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
BadParam
Exception
(
"Unable to find the view file for view '
$view
'."
);
throw
new
InvalidCall
Exception
(
"Unable to find the view file for view '
$view
'."
);
}
}
}
}
...
@@ -416,7 +416,7 @@ class View extends Component
...
@@ -416,7 +416,7 @@ class View extends Component
* The themed layout file will be returned if theme is enabled and the theme contains such a layout file.
* The themed layout file will be returned if theme is enabled and the theme contains such a layout file.
*
*
* @return string|boolean the layout file path, or false if the context does not need layout.
* @return string|boolean the layout file path, or false if the context does not need layout.
* @throws
BadParam
Exception if the layout file cannot be found
* @throws
InvalidCall
Exception if the layout file cannot be found
*/
*/
public
function
findLayoutFile
()
public
function
findLayoutFile
()
{
{
...
@@ -454,7 +454,7 @@ class View extends Component
...
@@ -454,7 +454,7 @@ class View extends Component
}
}
}
}
if
(
$file
===
false
||
!
is_file
(
$file
))
{
if
(
$file
===
false
||
!
is_file
(
$file
))
{
throw
new
BadParam
Exception
(
"Unable to find the layout file for layout '
{
$module
->
layout
}
' (specified by "
.
get_class
(
$module
)
.
")"
);
throw
new
InvalidCall
Exception
(
"Unable to find the layout file for layout '
{
$module
->
layout
}
' (specified by "
.
get_class
(
$module
)
.
")"
);
}
elseif
(
$this
->
localizeView
)
{
}
elseif
(
$this
->
localizeView
)
{
return
FileHelper
::
localize
(
$file
,
$this
->
language
,
$this
->
sourceLanguage
);
return
FileHelper
::
localize
(
$file
,
$this
->
language
,
$this
->
sourceLanguage
);
}
else
{
}
else
{
...
...
framework/db/ActiveRecord.php
View file @
ed8b7952
...
@@ -12,8 +12,8 @@ namespace yii\db;
...
@@ -12,8 +12,8 @@ namespace yii\db;
use
yii\base\Model
;
use
yii\base\Model
;
use
yii\base\ModelEvent
;
use
yii\base\ModelEvent
;
use
yii\base\
Bad
MethodException
;
use
yii\base\
Unknown
MethodException
;
use
yii\base\
BadParam
Exception
;
use
yii\base\
InvalidCall
Exception
;
use
yii\db\Connection
;
use
yii\db\Connection
;
use
yii\db\TableSchema
;
use
yii\db\TableSchema
;
use
yii\db\Expression
;
use
yii\db\Expression
;
...
@@ -991,7 +991,7 @@ class ActiveRecord extends Model
...
@@ -991,7 +991,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
BadParam
Exception if the named relation does not exist.
* @throws
InvalidCall
Exception if the named relation does not exist.
*/
*/
public
function
getRelation
(
$name
)
public
function
getRelation
(
$name
)
{
{
...
@@ -1001,9 +1001,9 @@ class ActiveRecord extends Model
...
@@ -1001,9 +1001,9 @@ class ActiveRecord extends Model
if
(
$relation
instanceof
ActiveRelation
)
{
if
(
$relation
instanceof
ActiveRelation
)
{
return
$relation
;
return
$relation
;
}
}
}
catch
(
Bad
MethodException
$e
)
{
}
catch
(
Unknown
MethodException
$e
)
{
}
}
throw
new
BadParam
Exception
(
get_class
(
$this
)
.
' has no relation named "'
.
$name
.
'".'
);
throw
new
InvalidCall
Exception
(
get_class
(
$this
)
.
' has no relation named "'
.
$name
.
'".'
);
}
}
/**
/**
...
@@ -1023,7 +1023,7 @@ class ActiveRecord extends Model
...
@@ -1023,7 +1023,7 @@ class ActiveRecord extends Model
* @param array $extraColumns additional column values to be saved into the pivot table.
* @param array $extraColumns additional column values to be saved into the pivot table.
* This parameter is only meaningful for a relationship involving a pivot table
* This parameter is only meaningful for a relationship involving a pivot table
* (i.e., a relation set with `[[ActiveRelation::via()]]` or `[[ActiveRelation::viaTable()]]`.)
* (i.e., a relation set with `[[ActiveRelation::via()]]` or `[[ActiveRelation::viaTable()]]`.)
* @throws
BadParam
Exception if the method is unable to link two models.
* @throws
InvalidCall
Exception if the method is unable to link two models.
*/
*/
public
function
link
(
$name
,
$model
,
$extraColumns
=
array
())
public
function
link
(
$name
,
$model
,
$extraColumns
=
array
())
{
{
...
@@ -1059,7 +1059,7 @@ class ActiveRecord extends Model
...
@@ -1059,7 +1059,7 @@ class ActiveRecord extends Model
$p2
=
$this
->
isPrimaryKey
(
array_values
(
$relation
->
link
));
$p2
=
$this
->
isPrimaryKey
(
array_values
(
$relation
->
link
));
if
(
$p1
&&
$p2
)
{
if
(
$p1
&&
$p2
)
{
if
(
$this
->
getIsNewRecord
()
&&
$model
->
getIsNewRecord
())
{
if
(
$this
->
getIsNewRecord
()
&&
$model
->
getIsNewRecord
())
{
throw
new
BadParam
Exception
(
'Unable to link models: both models are newly created.'
);
throw
new
InvalidCall
Exception
(
'Unable to link models: both models are newly created.'
);
}
elseif
(
$this
->
getIsNewRecord
())
{
}
elseif
(
$this
->
getIsNewRecord
())
{
$this
->
bindModels
(
array_flip
(
$relation
->
link
),
$this
,
$model
);
$this
->
bindModels
(
array_flip
(
$relation
->
link
),
$this
,
$model
);
}
else
{
}
else
{
...
@@ -1070,7 +1070,7 @@ class ActiveRecord extends Model
...
@@ -1070,7 +1070,7 @@ class ActiveRecord extends Model
}
elseif
(
$p2
)
{
}
elseif
(
$p2
)
{
$this
->
bindModels
(
$relation
->
link
,
$model
,
$this
);
$this
->
bindModels
(
$relation
->
link
,
$model
,
$this
);
}
else
{
}
else
{
throw
new
BadParam
Exception
(
'Unable to link models: the link does not involve any primary key.'
);
throw
new
InvalidCall
Exception
(
'Unable to link models: the link does not involve any primary key.'
);
}
}
}
}
...
@@ -1098,7 +1098,7 @@ class ActiveRecord extends Model
...
@@ -1098,7 +1098,7 @@ class ActiveRecord extends Model
* @param boolean $delete whether to delete the model that contains the foreign key.
* @param boolean $delete whether to delete the model that contains the foreign key.
* If false, the model's foreign key will be set null and saved.
* If false, the model's foreign key will be set null and saved.
* If true, the model containing the foreign key will be deleted.
* If true, the model containing the foreign key will be deleted.
* @throws
BadParam
Exception if the models cannot be unlinked
* @throws
InvalidCall
Exception if the models cannot be unlinked
*/
*/
public
function
unlink
(
$name
,
$model
,
$delete
=
false
)
public
function
unlink
(
$name
,
$model
,
$delete
=
false
)
{
{
...
@@ -1147,7 +1147,7 @@ class ActiveRecord extends Model
...
@@ -1147,7 +1147,7 @@ class ActiveRecord extends Model
}
}
$delete
?
$this
->
delete
()
:
$this
->
save
(
false
);
$delete
?
$this
->
delete
()
:
$this
->
save
(
false
);
}
else
{
}
else
{
throw
new
BadParam
Exception
(
'Unable to unlink models: the link does not involve any primary key.'
);
throw
new
InvalidCall
Exception
(
'Unable to unlink models: the link does not involve any primary key.'
);
}
}
}
}
...
@@ -1186,14 +1186,14 @@ class ActiveRecord extends Model
...
@@ -1186,14 +1186,14 @@ class ActiveRecord extends Model
* @param array $link
* @param array $link
* @param ActiveRecord $foreignModel
* @param ActiveRecord $foreignModel
* @param ActiveRecord $primaryModel
* @param ActiveRecord $primaryModel
* @throws
BadParam
Exception
* @throws
InvalidCall
Exception
*/
*/
private
function
bindModels
(
$link
,
$foreignModel
,
$primaryModel
)
private
function
bindModels
(
$link
,
$foreignModel
,
$primaryModel
)
{
{
foreach
(
$link
as
$fk
=>
$pk
)
{
foreach
(
$link
as
$fk
=>
$pk
)
{
$value
=
$primaryModel
->
$pk
;
$value
=
$primaryModel
->
$pk
;
if
(
$value
===
null
)
{
if
(
$value
===
null
)
{
throw
new
BadParam
Exception
(
'Unable to link models: the primary key of '
.
get_class
(
$primaryModel
)
.
' is null.'
);
throw
new
InvalidCall
Exception
(
'Unable to link models: the primary key of '
.
get_class
(
$primaryModel
)
.
' is null.'
);
}
}
$foreignModel
->
$fk
=
$value
;
$foreignModel
->
$fk
=
$value
;
}
}
...
...
framework/db/ActiveRelation.php
View file @
ed8b7952
...
@@ -12,7 +12,7 @@ namespace yii\db;
...
@@ -12,7 +12,7 @@ namespace yii\db;
use
yii\db\Connection
;
use
yii\db\Connection
;
use
yii\db\Command
;
use
yii\db\Command
;
use
yii\base\
BadParam
Exception
;
use
yii\base\
InvalidConfig
Exception
;
/**
/**
* ActiveRelation represents a relation between two Active Record classes.
* ActiveRelation represents a relation between two Active Record classes.
...
@@ -137,12 +137,12 @@ class ActiveRelation extends ActiveQuery
...
@@ -137,12 +137,12 @@ class ActiveRelation extends ActiveQuery
* @param string $name the relation name
* @param string $name the relation name
* @param array $primaryModels primary models
* @param array $primaryModels primary models
* @return array the related models
* @return array the related models
* @throws
BadParam
Exception
* @throws
InvalidConfig
Exception
*/
*/
public
function
findWith
(
$name
,
&
$primaryModels
)
public
function
findWith
(
$name
,
&
$primaryModels
)
{
{
if
(
!
is_array
(
$this
->
link
))
{
if
(
!
is_array
(
$this
->
link
))
{
throw
new
BadParam
Exception
(
'Invalid link: it must be an array of key-value pairs.'
);
throw
new
InvalidConfig
Exception
(
'Invalid link: it must be an array of key-value pairs.'
);
}
}
if
(
$this
->
via
instanceof
self
)
{
if
(
$this
->
via
instanceof
self
)
{
...
...
framework/db/DataReader.php
View file @
ed8b7952
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
namespace
yii\db
;
namespace
yii\db
;
use
yii\base\
Ba
dCallException
;
use
yii\base\
Invali
dCallException
;
/**
/**
* DataReader represents a forward-only stream of rows from a query result set.
* DataReader represents a forward-only stream of rows from a query result set.
...
@@ -212,7 +212,7 @@ class DataReader extends \yii\base\Object implements \Iterator, \Countable
...
@@ -212,7 +212,7 @@ class DataReader extends \yii\base\Object implements \Iterator, \Countable
/**
/**
* Resets the iterator to the initial state.
* Resets the iterator to the initial state.
* This method is required by the interface Iterator.
* This method is required by the interface Iterator.
* @throws
Ba
dCallException if this method is invoked twice
* @throws
Invali
dCallException if this method is invoked twice
*/
*/
public
function
rewind
()
public
function
rewind
()
{
{
...
@@ -220,7 +220,7 @@ class DataReader extends \yii\base\Object implements \Iterator, \Countable
...
@@ -220,7 +220,7 @@ class DataReader extends \yii\base\Object implements \Iterator, \Countable
$this
->
_row
=
$this
->
_statement
->
fetch
();
$this
->
_row
=
$this
->
_statement
->
fetch
();
$this
->
_index
=
0
;
$this
->
_index
=
0
;
}
else
{
}
else
{
throw
new
Ba
dCallException
(
'DataReader cannot rewind. It is a forward-only reader.'
);
throw
new
Invali
dCallException
(
'DataReader cannot rewind. It is a forward-only reader.'
);
}
}
}
}
...
...
framework/db/Schema.php
View file @
ed8b7952
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
namespace
yii\db
;
namespace
yii\db
;
use
yii\base\NotSupportedException
;
use
yii\base\NotSupportedException
;
use
yii\base\
Ba
dCallException
;
use
yii\base\
Invali
dCallException
;
/**
/**
* Schema is the base class for concrete DBMS-specific schema classes.
* Schema is the base class for concrete DBMS-specific schema classes.
...
@@ -205,7 +205,7 @@ abstract class Schema extends \yii\base\Object
...
@@ -205,7 +205,7 @@ abstract class Schema extends \yii\base\Object
* Returns the ID of the last inserted row or sequence value.
* Returns the ID of the last inserted row or sequence value.
* @param string $sequenceName name of the sequence object (required by some DBMS)
* @param string $sequenceName name of the sequence object (required by some DBMS)
* @return string the row ID of the last row inserted, or the last value retrieved from the sequence object
* @return string the row ID of the last row inserted, or the last value retrieved from the sequence object
* @throws
Ba
dCallException if the DB connection is not active
* @throws
Invali
dCallException if the DB connection is not active
* @see http://www.php.net/manual/en/function.PDO-lastInsertId.php
* @see http://www.php.net/manual/en/function.PDO-lastInsertId.php
*/
*/
public
function
getLastInsertID
(
$sequenceName
=
''
)
public
function
getLastInsertID
(
$sequenceName
=
''
)
...
@@ -213,7 +213,7 @@ abstract class Schema extends \yii\base\Object
...
@@ -213,7 +213,7 @@ abstract class Schema extends \yii\base\Object
if
(
$this
->
connection
->
isActive
)
{
if
(
$this
->
connection
->
isActive
)
{
return
$this
->
connection
->
pdo
->
lastInsertId
(
$sequenceName
);
return
$this
->
connection
->
pdo
->
lastInsertId
(
$sequenceName
);
}
else
{
}
else
{
throw
new
Ba
dCallException
(
'DB Connection is not active.'
);
throw
new
Invali
dCallException
(
'DB Connection is not active.'
);
}
}
}
}
...
...
framework/db/TableSchema.php
View file @
ed8b7952
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
namespace
yii\db
;
namespace
yii\db
;
use
yii\base\
BadParam
Exception
;
use
yii\base\
InvalidCall
Exception
;
/**
/**
* TableSchema represents the metadata of a database table.
* TableSchema represents the metadata of a database table.
...
@@ -87,7 +87,7 @@ class TableSchema extends \yii\base\Object
...
@@ -87,7 +87,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
BadParam
Exception if the specified key cannot be found in the table.
* @throws
InvalidCall
Exception if the specified key cannot be found in the table.
*/
*/
public
function
fixPrimaryKey
(
$keys
)
public
function
fixPrimaryKey
(
$keys
)
{
{
...
@@ -102,7 +102,7 @@ class TableSchema extends \yii\base\Object
...
@@ -102,7 +102,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
BadParam
Exception
(
"Primary key '
$key
' cannot be found in table '
{
$this
->
name
}
'."
);
throw
new
InvalidCall
Exception
(
"Primary key '
$key
' cannot be found in table '
{
$this
->
name
}
'."
);
}
}
}
}
}
}
...
...
framework/util/ArrayHelper.php
View file @
ed8b7952
...
@@ -9,6 +9,8 @@
...
@@ -9,6 +9,8 @@
namespace
yii\util
;
namespace
yii\util
;
use
yii\base\InvalidCallException
;
/**
/**
* ArrayHelper provides additional array functionality you can use in your
* ArrayHelper provides additional array functionality you can use in your
* application.
* application.
...
@@ -240,7 +242,7 @@ class ArrayHelper
...
@@ -240,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
\yii\base\BadParam
Exception if the $ascending or $sortFlag parameters do not have
* @throws
InvalidCall
Exception 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
)
...
@@ -253,12 +255,12 @@ class ArrayHelper
...
@@ -253,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
\yii\base\BadParam
Exception
(
'The length of $ascending parameter must be the same as that of $keys.'
);
throw
new
InvalidCall
Exception
(
'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
\yii\base\BadParam
Exception
(
'The length of $ascending parameter must be the same as that of $keys.'
);
throw
new
InvalidCall
Exception
(
'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
)
{
...
...
tests/unit/framework/base/ComponentTest.php
View file @
ed8b7952
...
@@ -64,7 +64,7 @@ class ComponentTest extends \yiiunit\TestCase
...
@@ -64,7 +64,7 @@ class ComponentTest extends \yiiunit\TestCase
public
function
testGetProperty
()
public
function
testGetProperty
()
{
{
$this
->
assertTrue
(
'default'
===
$this
->
component
->
Text
);
$this
->
assertTrue
(
'default'
===
$this
->
component
->
Text
);
$this
->
setExpectedException
(
'yii\base\
Bad
PropertyException'
);
$this
->
setExpectedException
(
'yii\base\
Unknown
PropertyException'
);
$value2
=
$this
->
component
->
Caption
;
$value2
=
$this
->
component
->
Caption
;
}
}
...
@@ -73,7 +73,7 @@ class ComponentTest extends \yiiunit\TestCase
...
@@ -73,7 +73,7 @@ class ComponentTest extends \yiiunit\TestCase
$value
=
'new value'
;
$value
=
'new value'
;
$this
->
component
->
Text
=
$value
;
$this
->
component
->
Text
=
$value
;
$this
->
assertEquals
(
$value
,
$this
->
component
->
Text
);
$this
->
assertEquals
(
$value
,
$this
->
component
->
Text
);
$this
->
setExpectedException
(
'yii\base\
Bad
PropertyException'
);
$this
->
setExpectedException
(
'yii\base\
Unknown
PropertyException'
);
$this
->
component
->
NewMember
=
$value
;
$this
->
component
->
NewMember
=
$value
;
}
}
...
@@ -182,7 +182,7 @@ class ComponentTest extends \yiiunit\TestCase
...
@@ -182,7 +182,7 @@ class ComponentTest extends \yiiunit\TestCase
$this
->
assertSame
(
$behavior
,
$component
->
detachBehavior
(
'a'
));
$this
->
assertSame
(
$behavior
,
$component
->
detachBehavior
(
'a'
));
$this
->
assertFalse
(
$component
->
hasProperty
(
'p'
));
$this
->
assertFalse
(
$component
->
hasProperty
(
'p'
));
$this
->
setExpectedException
(
'yii\base\
Bad
MethodException'
);
$this
->
setExpectedException
(
'yii\base\
Unknown
MethodException'
);
$component
->
test
();
$component
->
test
();
$p
=
'as b'
;
$p
=
'as b'
;
...
...
tests/unit/framework/base/DictionaryTest.php
View file @
ed8b7952
...
@@ -95,7 +95,7 @@ class DictionaryTest extends \yiiunit\TestCase
...
@@ -95,7 +95,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\
BadParam
Exception'
);
$this
->
setExpectedException
(
'yii\base\
InvalidCall
Exception'
);
$this
->
dictionary
->
copyFrom
(
$this
);
$this
->
dictionary
->
copyFrom
(
$this
);
}
}
...
@@ -114,7 +114,7 @@ class DictionaryTest extends \yiiunit\TestCase
...
@@ -114,7 +114,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\
BadParam
Exception'
);
$this
->
setExpectedException
(
'yii\base\
InvalidCall
Exception'
);
$this
->
dictionary
->
mergeWith
(
$this
,
false
);
$this
->
dictionary
->
mergeWith
(
$this
,
false
);
}
}
...
...
tests/unit/framework/base/ObjectTest.php
View file @
ed8b7952
...
@@ -56,7 +56,7 @@ class ObjectTest extends \yiiunit\TestCase
...
@@ -56,7 +56,7 @@ class ObjectTest extends \yiiunit\TestCase
public
function
testGetProperty
()
public
function
testGetProperty
()
{
{
$this
->
assertTrue
(
'default'
===
$this
->
object
->
Text
);
$this
->
assertTrue
(
'default'
===
$this
->
object
->
Text
);
$this
->
setExpectedException
(
'yii\base\
Bad
PropertyException'
);
$this
->
setExpectedException
(
'yii\base\
Unknown
PropertyException'
);
$value2
=
$this
->
object
->
Caption
;
$value2
=
$this
->
object
->
Caption
;
}
}
...
@@ -65,7 +65,7 @@ class ObjectTest extends \yiiunit\TestCase
...
@@ -65,7 +65,7 @@ class ObjectTest extends \yiiunit\TestCase
$value
=
'new value'
;
$value
=
'new value'
;
$this
->
object
->
Text
=
$value
;
$this
->
object
->
Text
=
$value
;
$this
->
assertEquals
(
$value
,
$this
->
object
->
Text
);
$this
->
assertEquals
(
$value
,
$this
->
object
->
Text
);
$this
->
setExpectedException
(
'yii\base\
Bad
PropertyException'
);
$this
->
setExpectedException
(
'yii\base\
Unknown
PropertyException'
);
$this
->
object
->
NewMember
=
$value
;
$this
->
object
->
NewMember
=
$value
;
}
}
...
...
tests/unit/framework/base/VectorTest.php
View file @
ed8b7952
...
@@ -65,7 +65,7 @@ class VectorTest extends \yiiunit\TestCase
...
@@ -65,7 +65,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\
BadParam
Exception'
);
$this
->
setExpectedException
(
'yii\base\
InvalidCall
Exception'
);
$this
->
vector
->
insertAt
(
4
,
$this
->
item3
);
$this
->
vector
->
insertAt
(
4
,
$this
->
item3
);
}
}
...
@@ -87,7 +87,7 @@ class VectorTest extends \yiiunit\TestCase
...
@@ -87,7 +87,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\
BadParam
Exception'
);
$this
->
setExpectedException
(
'yii\base\
InvalidCall
Exception'
);
$this
->
vector
->
removeAt
(
2
);
$this
->
vector
->
removeAt
(
2
);
}
}
...
@@ -118,7 +118,7 @@ class VectorTest extends \yiiunit\TestCase
...
@@ -118,7 +118,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\
BadParam
Exception'
);
$this
->
setExpectedException
(
'yii\base\
InvalidCall
Exception'
);
$this
->
vector
->
copyFrom
(
$this
);
$this
->
vector
->
copyFrom
(
$this
);
}
}
...
@@ -127,7 +127,7 @@ class VectorTest extends \yiiunit\TestCase
...
@@ -127,7 +127,7 @@ class VectorTest extends \yiiunit\TestCase
$array
=
array
(
$this
->
item3
,
$this
->
item1
);
$array
=
array
(
$this
->
item3
,
$this
->
item1
);
$this
->
vector
->
mergeWith
(
$array
);
$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
);
$this
->
setExpectedException
(
'yii\base\
BadParam
Exception'
);
$this
->
setExpectedException
(
'yii\base\
InvalidCall
Exception'
);
$this
->
vector
->
mergeWith
(
$this
);
$this
->
vector
->
mergeWith
(
$this
);
}
}
...
@@ -141,7 +141,7 @@ class VectorTest extends \yiiunit\TestCase
...
@@ -141,7 +141,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\
BadParam
Exception'
);
$this
->
setExpectedException
(
'yii\base\
InvalidCall
Exception'
);
$a
=
$this
->
vector
[
2
];
$a
=
$this
->
vector
[
2
];
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment