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

Fixes #216 remove \Exception type hint #217

Merged
merged 4 commits into from
Sep 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
32 changes: 32 additions & 0 deletions test/Exception/SerializableExceptionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace ZendDeveloperToolsTest\Exception;

use PHPUnit_Framework_TestCase;
use ZendDeveloperTools\Exception\SerializableException;

class SerializableExceptionTest extends PHPUnit_Framework_TestCase
{
public function testException()
{
try {
new \Exception('foo');
} catch (\Exception $exception) {
$serializable = new SerializableException($exception);
$this->assertEquals('foo', $serializable->getMessage());
}
}

/**
* @requires PHP 7
*/
public function testStdClassCallNotExistMethod()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test requires PHP 7 - you can use the PHPUnit annotation for that

{
try {
(new \stdClass)->iDoNotExist();
} catch (\Throwable $exception) {
$serializable = new SerializableException($exception);
$this->assertEquals('Call to undefined method stdClass::iDoNotExist()', $serializable->getMessage());
}
}
}