Exemple #1
0
 public function testUser_get_sponsorWithOneSponsor()
 {
     $user = new \BeeHub_User('/system/users/jane');
     // There can not be a default sponsor; Jane does not have any sponsors at all
     $this->assertNull($user->user_prop_sponsor());
     // Give Jane a sponsor, and this should automatically be her default sponsor
     $this->setCurrentUser('/system/users/john');
     $sponsor = new \BeeHub_Sponsor('/system/sponsors/sponsor_a');
     $sponsor->change_memberships(array('jane'), \BeeHub_Sponsor::ADMIN_ACCEPT);
     $userWithSponsor = \DAV::$REGISTRY->resource('/system/users/jane');
     $this->assertSame('/system/sponsors/sponsor_a', $userWithSponsor->user_prop_sponsor());
     // Remove the only sponsor Jane has and she should have no default sponsor either
     $sponsor->change_memberships(array('jane'), \BeeHub_Sponsor::DELETE_MEMBER);
     $userWithoutSponsor = \DAV::$REGISTRY->resource('/system/users/jane');
     $this->assertNull($userWithoutSponsor->user_prop_sponsor());
 }