Doctrine\Common\DataFixtures\Loader::getFixture PHP Method

getFixture() public method

Get a specific fixture instance
public getFixture ( string $className ) : Doctrine\Common\DataFixtures\FixtureInterface
$className string
return Doctrine\Common\DataFixtures\FixtureInterface
    public function getFixture($className)
    {
        if (!isset($this->fixtures[$className])) {
            throw new \InvalidArgumentException(sprintf('"%s" is not a registered fixture', $className));
        }
        return $this->fixtures[$className];
    }

Usage Example

Beispiel #1
0
 public function testGetFixture()
 {
     $loader = new Loader();
     $loader->loadFromFile(__DIR__ . '/TestFixtures/MyFixture1.php');
     $fixture = $loader->getFixture(MyFixture1::class);
     $this->assertInstanceOf(MyFixture1::class, $fixture);
 }