diff --git a/framework/yii/base/Exception.php b/framework/yii/base/Exception.php index 4f66e53..b771490 100644 --- a/framework/yii/base/Exception.php +++ b/framework/yii/base/Exception.php @@ -41,10 +41,10 @@ class Exception extends \Exception implements Arrayable { if ($exception instanceof self) { $array = array( - 'type' => get_class($this), - 'name' => $this->getName(), - 'message' => $this->getMessage(), - 'code' => $this->getCode(), + 'type' => get_class($exception), + 'name' => $exception->getName(), + 'message' => $exception->getMessage(), + 'code' => $exception->getCode(), ); } else { $array = array( diff --git a/tests/unit/framework/base/ExceptionTest.php b/tests/unit/framework/base/ExceptionTest.php new file mode 100644 index 0000000..af4293a --- /dev/null +++ b/tests/unit/framework/base/ExceptionTest.php @@ -0,0 +1,23 @@ +toArray(); + $this->assertEquals('bar', $array['message']); + $this->assertEquals('foo', $array['previous']['message']); + + $e = new InvalidCallException('bar', 0 ,new UserException('foo')); + $array = $e->toArray(); + $this->assertEquals('bar', $array['message']); + $this->assertEquals('foo', $array['previous']['message']); + } +}