コード例 #1
0
 function testImportResetsExistingMany2ManyCollection()
 {
     $group = new GroupForTest();
     $group->setTitle('Some group');
     $u1 = new UserForTest();
     $u1->setFirstName('Bob');
     $u2 = new UserForTest();
     $u2->setFirstName('John');
     $group->addToUsers($u1);
     $group->addToUsers($u2);
     $group->save();
     $source = array('title' => $group->getTitle(), 'users' => array($u2->getId()));
     $group2 = new GroupForTest($group->getId());
     $group2->import($source);
     $this->assertEqual($group2->getTitle(), $group->getTitle());
     $this->assertEqual($group2->getUsers()->count(), 1);
     $this->assertEqual($group2->getUsers()->at(0)->getFirstName(), $u2->getFirstName());
 }