Skip to content

Instantly share code, notes, and snippets.

@polyfractal
Last active December 16, 2015 22:19
Show Gist options
  • Select an option

  • Save polyfractal/5506185 to your computer and use it in GitHub Desktop.

Select an option

Save polyfractal/5506185 to your computer and use it in GitHub Desktop.

Revisions

  1. polyfractal revised this gist May 2, 2013. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,10 @@ public function assertThrowsException($exception, $code)

    public function testGizmo()
    {
    $widget = 'something';
    // Some more code


    $this->assertThrowsException('\Package\Specific\Exception', function () use ($widget) {
    $blah = new \Package\Gizmo($widget);
    });
  2. polyfractal created this gist May 2, 2013.
    19 changes: 19 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    public function assertThrowsException($exception, $code)
    {
    $raisedException = null;
    try {
    $code();
    } catch (\Exception $raisedException) {
    // No more code, we only want to catch the exception in $raisedException.
    }

    $this->assertInstanceOf($exception, $raisedException);

    }

    public function testGizmo()
    {
    $this->assertThrowsException('\Package\Specific\Exception', function () use ($widget) {
    $blah = new \Package\Gizmo($widget);
    });
    }