Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/217'
Browse files Browse the repository at this point in the history
Close #217
Fixes #216
  • Loading branch information
weierophinney committed Sep 8, 2016
2 parents 2ae287d + deeccb6 commit 9838857
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ All notable changes to this project will be documented in this file, in reverse

### Added

- Nothing.
- [#217](https://github.com/zendframework/ZendDeveloperTools/pull/217) adds
support in the `SerializableException` for PHP 7 Throwables, including Error
types.

### Deprecated

Expand Down
4 changes: 2 additions & 2 deletions src/Exception/SerializableException.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class SerializableException implements \Serializable
/**
* Saves the exception data in an array.
*
* @param \Exception $exception
* @param \Exception|\Throwable $exception
*/
public function __construct(\Exception $exception)
public function __construct($exception)
{
$this->data = [
'code' => $exception->getCode(),
Expand Down
37 changes: 37 additions & 0 deletions test/Exception/SerializableExceptionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* @link http://github.com/zendframework/ZendDeveloperTools for the canonical source repository
* @copyright Copyright (c) 2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace ZendDeveloperToolsTest\Exception;

use Exception;
use PHPUnit_Framework_TestCase as TestCase;
use stdClass;
use Throwable;
use ZendDeveloperTools\Exception\SerializableException;

class SerializableExceptionTest extends TestCase
{
public function testSerializableExceptionUsesPreviousExceptionMessage()
{
$original = new Exception('foo');
$serializable = new SerializableException($original);
$this->assertEquals($original->getMessage(), $serializable->getMessage());
}

/**
* @requires PHP 7
*/
public function testSerializableExceptionReportsCallToUndefinedMethod()
{
try {
(new stdClass)->iDoNotExist();
} catch (Throwable $exception) {
$serializable = new SerializableException($exception);
$this->assertEquals('Call to undefined method stdClass::iDoNotExist()', $serializable->getMessage());
}
}
}

0 comments on commit 9838857

Please sign in to comment.