/**
  *
  */
 public function testGenerate_SimpleFields_GeneratesObjectWithFields()
 {
     $writer = new RecordWriter();
     $configParser = new ConfigParser($writer);
     $field = $configParser->objectConfig2Field(array('class' => 'Seeder\\Tests\\Dog', 'provider' => 'Seeder\\Tests\\TestProvider', 'fields' => array('Name' => 'test()', 'Age' => 'test()', 'Breed' => 'test()')));
     $provider = $field->provider;
     $dogs = $provider->generate($field, new SeederState());
     $writer->finish();
     $this->assertCount(1, $dogs);
     $this->assertEquals(1, Dog::get()->Count());
     $dog = $dogs[0];
     $this->assertEquals(TestProvider::TEST_STRING, $dog->Name);
     $this->assertEquals(TestProvider::TEST_INT, $dog->Age);
     $this->assertEquals(TestProvider::TEST_STRING, $dog->Breed);
 }
 /**
  *
  */
 public function testWriteManyMany_WriteManyManyObjects_ObjectsAccessibleFromManyMany()
 {
     $this->markTestIncomplete('Need silverstripe-batchwrite compatibility.');
     $batchSizes = array(10, 30, 100, 300);
     foreach ($batchSizes as $batchSize) {
         $writer = new BatchedSeedWriter($batchSize);
         for ($i = 0; $i < 10; $i++) {
             $owner = new Human();
             $owner->Name = 'Mr bean ' . $i;
             for ($j = 0; $j < 10; $j++) {
                 $dog = new Dog();
                 $dog->Name = 'Walnut ' . $i;
                 $afterExists = new \OnAfterExists(function () use($owner, $dog, $writer) {
                     $writer->writeManyMany($owner, 'Pets', $dog);
                 });
                 $afterExists->addCondition($owner);
                 $afterExists->addCondition($dog);
                 $writer->write($dog, $this->createField());
             }
             $writer->write($owner, $this->createField());
         }
         $writer->finish();
         $owners = Human::get();
         $dogs = Dog::get();
         $this->assertEquals(10, $owners->Count());
         $this->assertEquals(100, $dogs->Count());
         foreach ($owners as $owner) {
             $this->assertEquals(10, $owner->Pets()->Count());
         }
         $writer->delete($owners);
         $writer->delete($dogs);
         $writer->finish();
     }
 }