Testing Your Services with In-Memory Implementations

Setting up a fully persistent Repository implementation can be complex and result in slow execution. You should care about keeping your tests fast. Going through the whole database setup and then querying will slow you down enormously. Having an in-memory implementation could help delay persistence decisions until the end. We can test in the same manner as we did before, but this time, we'll use a full-featured fast and simple in-memory implementation:

class MyServiceTest extends PHPUnit_Framework_TestCase
{
private $service;

public function setUp()
{
$this->service = new MyService(
new InMemoryPostRepository()
);
}
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset