Skip to content

Commit

Permalink
don't use @ExpectedException annotation as it will get deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
burned42 committed Oct 17, 2018
1 parent 6773165 commit f8a2b52
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions tests/unit/Codeception/Module/AssertsTest.php
Expand Up @@ -55,22 +55,20 @@ public function testExceptions()
});
}

/**
* @expectedException PHPUnit\Framework\AssertionFailedError
*/
public function testExceptionFails()
{
$this->expectException(PHPUnit\Framework\AssertionFailedError::class);

$this->module->expectException(new Exception('here', 200), function () {
throw new Exception('here', 2);
});
}

/**
* @expectedException PHPUnit\Framework\AssertionFailedError
* @expectedExceptionMessageRegExp /RuntimeException/
*/
public function testOutputExceptionTimeWhenNothingCaught()
{
$this->expectException(\PHPUnit\Framework\AssertionFailedError::class);
$this->expectExceptionMessageRegExp('/RuntimeException/');

$this->module->expectException(RuntimeException::class, function () {
});
}
Expand All @@ -88,42 +86,38 @@ public function testExpectThrowable()
});
}

/**
* @expectedException PHPUnit\Framework\AssertionFailedError
*/
public function testExpectThrowableFailOnDifferentClass()
{
$this->expectException(\PHPUnit\Framework\AssertionFailedError::class);

$this->module->expectThrowable(new RuntimeException(), function () {
throw new Exception();
});
}

/**
* @expectedException PHPUnit\Framework\AssertionFailedError
*/
public function testExpectThrowableFailOnDifferentMessage()
{
$this->expectException(\PHPUnit\Framework\AssertionFailedError::class);

$this->module->expectThrowable(new Exception('foo', 200), function () {
throw new Exception('bar', 200);
});
}

/**
* @expectedException PHPUnit\Framework\AssertionFailedError
*/
public function testExpectThrowableFailOnDifferentCode()
{
$this->expectException(\PHPUnit\Framework\AssertionFailedError::class);

$this->module->expectThrowable(new Exception('foobar', 200), function () {
throw new Exception('foobar', 2);
});
}

/**
* @expectedException PHPUnit\Framework\AssertionFailedError
* @expectedExceptionMessageRegExp /RuntimeException/
*/
public function testExpectThrowableFailOnNothingCaught()
{
$this->expectException(\PHPUnit\Framework\AssertionFailedError::class);
$this->expectExceptionMessageRegExp('/RuntimeException/');

$this->module->expectThrowable(RuntimeException::class, function () {
});
}
Expand Down

0 comments on commit f8a2b52

Please sign in to comment.