示例#1
0
 public function testCascadeModel()
 {
     $user = new User(array('fullname' => 'Mukhamad Ikhsan', 'email' => '*****@*****.**', 'password' => 'rahasia'));
     $this->assertTrue($user->save());
     $group = new Group(array('name' => "Testing"));
     $this->assertTrue($group->save());
     $user->addGroup($group);
     $this->assertTrue($user->save());
     $this->assertEqual(1, count($user->groups));
     $this->assertEqual(1, count($group->members));
     $ikhsan = User::getRepository()->findOneBy(array('email' => '*****@*****.**'));
     $testing = Group::getRepository()->findOneBy(array('name' => 'Testing'));
     $this->assertEqual(1, count($ikhsan->groups));
     $this->assertEqual(1, count($testing->members));
     $user->delete();
     $group->delete();
 }