ExceptionTest.php 638 Bytes
Newer Older
1 2 3
<?php
namespace yiiunit\framework\base;

4
use yiiunit\TestCase;
5 6 7 8 9 10
use yii\base\UserException;
use yii\base\InvalidCallException;


class ExceptionTest extends TestCase
{
11
	public function testToArrayWithPrevious()
12 13 14 15 16 17 18 19 20 21 22 23
	{
		$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']);
	}
}