sebastianbergmann / dbunit

DbUnit port for PHP/PHPUnit.
https://phpunit.de/
Other
225 stars 186 forks source link

Implement TestCaseTrait::createYamlDataSet factory method #200

Closed mszabo-wikia closed 6 years ago

mszabo-wikia commented 6 years ago

The DbUnit documentation currently states:

The YAML Dataset has no factory method on the Database TestCase currently, so you have to instantiate it manually:


<?php
use PHPUnit\Framework\TestCase;
use PHPUnit\DbUnit\TestCaseTrait;
use PHPUnit\DbUnit\DataSet\YamlDataSet;

class YamlGuestbookTest extends TestCase { use TestCaseTrait;

protected function getDataSet()
{
    return new YamlDataSet(dirname(__FILE__)."/_files/guestbook.yml");
}

} ?>



The `YamlDataSet` is the only `IDataSet` implementation provided by DbUnit that does not have a a factory method. This PR creates a protected factory method for `YamlDataSet` on `TestCaseTrait` to be consistent with the rest of the `IDataSet` implementations. The availability of such a factory method also allows callers to remain compatible with DbUnit if a future release changes the namespace or name of the `YamlDataSet` class.