/**
  *
  */
 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();
     }
 }
 /**
  *
  */
 public function testGenerate_ManyManyField_GeneratesObjectWithManyManyField()
 {
     $writer = new RecordWriter();
     $configParser = new ConfigParser($writer);
     $field = $configParser->objectConfig2Field(array('class' => 'Seeder\\Tests\\Human', 'provider' => 'Seeder\\Tests\\TestProvider', 'fields' => array('Children' => array('count' => 10, 'provider' => 'Seeder\\Tests\\TestProvider', 'fields' => array('Name' => 'test()', 'Age' => 'test()')), 'Pets' => array('count' => 5, 'provider' => 'Seeder\\Tests\\TestProvider'))));
     $provider = $field->provider;
     $people = $provider->generate($field, new SeederState());
     $writer->finish();
     $this->assertCount(1, $people);
     $this->assertEquals(11, Human::get()->Count());
     $this->assertEquals(5, Pet::get()->Count());
     $person = $people[0];
     $children = $person->Children();
     $this->assertEquals(10, $children->Count());
     foreach ($children as $child) {
         $this->assertEquals(TestProvider::TEST_STRING, $child->Name);
         $this->assertEquals(TestProvider::TEST_INT, $child->Age);
     }
 }