public function testSetUsers() { // new entity $role = new Role(); // Dummy entity $user1 = new User(); $user1->setFirstName("Per"); $user2 = new User(); $user2->setFirstName("Hans"); $user3 = new User(); $user3->setFirstName("Ole"); // Create a array with the users $userList = array($user1, $user2, $user3); // set the array as users of the role $role->setUsers($userList); // Users are stored in an array $users = $role->getUsers(); // Loop through the array and check for matches foreach ($users as $user) { foreach ($userList as $u) { if ($u == $user) { // Assert the result $this->assertEquals($u, $user); } } } }