elliotchance / concise

✅ Concise is test framework for using plain English and minimal code, built on PHPUnit.
MIT License
45 stars 3 forks source link

fakedb for mocking SQL databases #291

Open elliotchance opened 8 years ago

elliotchance commented 8 years ago

This could be a layer on top of mocking just for certain PDO objects or a separate daemon if needed.

public function testFetchingAPerson()
{
    $this->fakedb->stub(
        'SELECT * FROM people WHERE id = 123',
        ['id' => 123, 'name' => 'John Smith']
    );
    $fetcher = new Person();
    $this->assert($fetcher->get(123))->equals(['id' => 123, 'name' => 'John Smith']);
}

public function testAddingAPerson()
{
    $this->fakedb->expectInsert('people', ['name' => 'John Smith']);
    $person = new Person();
    $person->name = 'John Smith';
    $person->save();
}