Example #1
0
 public function testCreatePartialPayouts()
 {
     $user = new User();
     $referralUserLevel1 = new User();
     $referralUserLevel2 = new User();
     $referralUserLevel3 = new User();
     // Setup referral hierarchy
     $user->setReferrer($referralUserLevel1);
     $referralUserLevel1->setReferrer($referralUserLevel2);
     $referralUserLevel2->setReferrer($referralUserLevel3);
     // Setup the account
     $account = new Account();
     $account->setUser($user);
     $account->setPayoutPercentage(0.9);
     $account->setBroker(new Broker());
     // Setup payment
     $payment = new Payment();
     $payment->setAccount($account);
     $payment->setAmount(100);
     $this->paymentManager->createPartialPayouts($payment);
     $this->assertEquals(90, $user->getTotalPartialPayoutAmount());
     $this->assertEquals(9, $referralUserLevel1->getTotalPartialPayoutAmount());
     $this->assertEquals(5, $referralUserLevel2->getTotalPartialPayoutAmount());
     $this->assertEquals(1, $referralUserLevel3->getTotalPartialPayoutAmount());
 }
Example #2
0
 public function authenticateClient(User $user, $firewall = 'main')
 {
     $session = $this->getSession();
     $token = new UsernamePasswordToken($user, null, $firewall, $user->getRoles());
     $session->set('_security_' . $firewall, serialize($token));
     $session->save();
     $cookie = new Cookie($session->getName(), $session->getId());
     $this->client->getCookieJar()->set($cookie);
 }
Example #3
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $userManager = $this->container->get('fos_user.user_manager');
     //$jsuggs = $userManager->createUser();
     $jsuggs = new User();
     $jsuggs->setUsername('jsuggs');
     $jsuggs->setEmail('*****@*****.**');
     $jsuggs->setPlainPassword('testtest');
     $jsuggs->setEnabled(true);
     $jsuggs->setRoles(array('ROLE_ADMIN'));
     $userManager->updateUser($jsuggs, true);
     $manager->flush();
 }
Example #4
0
 public function testGetCurrentPayoutBalance()
 {
     $user = new User();
     $payment1 = new Payment();
     $partialPayout1 = new PartialPayout($payment1);
     $partialPayout1->setAmount(100);
     $user->addPartialPayout($partialPayout1);
     $this->assertEquals(100, $user->getCurrentPayoutBalance());
     $payment2 = new Payment();
     $partialPayout2 = new PartialPayout($payment2);
     $partialPayout2->setAmount(200);
     $user->addPartialPayout($partialPayout2);
     $this->assertEquals(300, $user->getCurrentPayoutBalance());
     $payout1 = new Payout();
     $payout1->setAmount(150);
     $user->addPayout($payout1);
     $this->assertEquals(150, $user->getCurrentPayoutBalance());
 }
Example #5
0
 public function addReferrerToUser(User $user, User $referrer)
 {
     if (!$user->getReferrer()) {
         $user->setReferrer($referrer);
     }
 }
Example #6
0
 public function setUser(User $user)
 {
     $this->user = $user;
     $this->email = $user->getEmail();
 }