public function testClearWithClass()
 {
     $factory = new FixtureFactory();
     $obj1 = $factory->createObject('FixtureFactoryTest_DataObject', 'object-one');
     $relation1 = $factory->createObject('FixtureFactoryTest_DataObjectRelation', 'relation-one');
     $factory->clear('FixtureFactoryTest_DataObject');
     $this->assertFalse($factory->getId('FixtureFactoryTest_DataObject', 'one'));
     $this->assertNull(FixtureFactoryTest_DataObject::get()->byId($obj1->ID));
     $this->assertEquals($relation1->ID, $factory->getId('FixtureFactoryTest_DataObjectRelation', 'relation-one'));
     $this->assertInstanceOf('FixtureFactoryTest_DataObjectRelation', FixtureFactoryTest_DataObjectRelation::get()->byId($relation1->ID));
 }
 /**
  * Persists the YAML data in a FixtureFactory,
  * which in turn saves them into the database.
  * Please use the passed in factory to access the fixtures afterwards.
  *
  * @param  FixtureFactory $factory
  */
 public function writeInto(FixtureFactory $factory)
 {
     $parser = new Parser();
     if (isset($this->fixtureString)) {
         $fixtureContent = $parser->parse($this->fixtureString);
     } else {
         if (!file_exists($this->fixtureFile)) {
             return;
         }
         $contents = file_get_contents($this->fixtureFile);
         $fixtureContent = $parser->parse($contents);
         if (!$fixtureContent) {
             return;
         }
     }
     foreach ($fixtureContent as $class => $items) {
         foreach ($items as $identifier => $data) {
             if (ClassInfo::exists($class)) {
                 $factory->createObject($class, $identifier, $data);
             } else {
                 $factory->createRaw($class, $identifier, $data);
             }
         }
     }
 }