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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
tests for SerializableException
  • Loading branch information
samsonasik committed Jul 1, 2016
commit de5eee964c2189bdefcc135a3eb28d7eb50c7575
35 changes: 35 additions & 0 deletions test/Exception/SerializableExceptionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace ZendDeveloperToolsTest\Exception;

use PHPUnit_Framework_TestCase;
use ZendDeveloperTools\Exception\SerializableException;

class SerializableExceptionTest extends PHPUnit_Framework_TestCase
{
public function testExceptionAndThrowable()
Copy link
Member

Choose a reason for hiding this comment

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

Can simplify to just an exception test case (instantiate a new exception)

{
try {
$a = 1 / 0;
} catch (\Throwable $exception) {
$serializable = new SerializableException($exception);
$this->assertEquals('Division by zero', $serializable->getMessage());
} catch (\Exception $exception) {
$serializable = new SerializableException($exception);
$this->assertEquals('Division by zero', $serializable->getMessage());
}
}

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());
} catch (\Exception $exception) {
$serializable = new SerializableException($exception);
$this->assertEquals('Call to undefined method stdClass::iDoNotExist()', $serializable->getMessage());
}
}
}