ExceptionTest.php 640 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
<?php
namespace yiiunit\framework\base;

use yii\test\TestCase;
use yii\base\UserException;
use yii\base\InvalidCallException;


class ExceptionTest extends TestCase
{
	public function testToArrayWithPrevious() 
	{
		$e = new InvalidCallException('bar', 0 ,new InvalidCallException('foo'));
		$array = $e->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']);
	}
}