Improve Fixture and FixtureRollback interface
schmengler opened this issue · comments
It's currently a bit cumbersome to use the Fixture and FixtureRollback classes together with the Builder classes.
I would like to make it easier to create a bunch of fixtures and roll them back at once, e.g. with a fixture pool:
class SomeTest
{
private FixturePool $fixtures;
protected function setUp()
{
$this->fixtures = new FixturePool();
$this->fixtures->addCustomer(CustomerBuilder::aCustomer()->build(), 'customer1');
$this->fixtures->addCustomer(CustomerBuilder::aCustomer()->build(), 'customer2');
$this->fixtures->addProduct(ProductBuilder::aSimpleProduct()->build(), 'product1');
}
protected function tearDown()
{
$this->fixtures->rollBackAll();
}
public function testSomething()
{
$customer1 = $this->fixtures->getCustomer('customer1'); // returns CustomerFixture object
$product = $this->fixtures->getProduct(); // key is optional, returns first element by default
// ....
}
}