I am writing a unit test upfront for a service that does not exist yet. Let's just say it is called ResponseFormatter
.
I want to start adding unit tests for what I expect this service to do. How do I inject it to a UnitTestCase, or reference it?
Example, I am trying to do something like:
class FormatterTest extends UnitTestCase {
/**
* @dataProvider responses
*/
public function testThisWorks($response, $expected) {
// the following line I want to call a service,
// ex. like $this->responseFormatter->format($string);
$clean = html_entity_decode(strip_tags($response));
$this->assertEquals($expected, $clean);
}
public function responses() {
return [
['not-set', 'not-set'],
['<strong>foo</strong>', 'foo'],
['& #93 bar', '& #93 bar'],
];
}
}