Skip to content

Instantly share code, notes, and snippets.

@raank
Last active October 29, 2016 01:15
Show Gist options
  • Save raank/e0670a952f60983c3f6bc4ada547a617 to your computer and use it in GitHub Desktop.
Save raank/e0670a952f60983c3f6bc4ada547a617 to your computer and use it in GitHub Desktop.
<?php
namespace FlyingLuscas\BugNotifier;
class MessageTest extends TestCase
{
/**
* @dataProvider dataExceptionProvider
*/
public function testMessageTitleOutput($e)
{
$message = new Message(new $e);
$expectedTitle = sprintf('%s in %s line %d', class_basename($e), basename(__FILE__), (__LINE__ - 1));
$this->assertEquals($expectedTitle, $message->getTitle());
}
/**
* @dataProvider dataExceptionProvider
*/
public function testMessageBodyOutput($e)
{
$description = 'Some dummy message';
$thrown = new $e($description);
$message = new Message($thrown);
$at = 'teste';
$expectedBody = sprintf("[%s] %s in %s line %d\n\n%s\n\n%s", $at, $e, __FILE__, (__LINE__ - 2), $description, $thrown->getTraceAsString());
$this->assertEquals($expectedBody, $message->getBody());
}
public function dataExceptionProvider()
{
return [
[\Exception::class],
[\InvalidArgumentException::class],
[\RuntimeException::class],
[DummyException::class],
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment