public function addRemainingToAccounts($when, \PropelPDO $con) { $systemAccount = \SystemStats::getSystemAccount(); $transfer = $systemAccount->getCurrentTransferBundle($this->currency, $con); $transaction = $transfer->createTransaction($systemAccount, $this->toSystemAccount, \Transaction::REASON_REMAINING_MEMBER_FEE, $this->member->getId(), $when, $con); $systemAccount->save($con); }
function testSystemStats() { $SystemStats = new SystemStats(); // // Get uptime // $retval = $SystemStats->GetUptime(); $this->assertTrue(is_double($retval), "System uptime is double number"); // // Get linux ver // $retval = $SystemStats->GetLinuxVersion(); $this->assertTrue(is_string($retval), "System version is string"); // // Get linux name // $retval = $SystemStats->GetLinuxName(); $this->assertTrue(is_string($retval), "System version is string"); }
public static function create(Member $login, array $data, PropelPDO $con) { $type = $data['type']; $hash = SystemStats::getIncreasedInvitationIncrementer($con); $invitation = new Invitation(); if ($type === \Member::TYPE_SUB_PROMOTER) { $invitation->setMeta(['promoter_num' => $data['promoter_num'], 'promoter_id' => $data['promoter_id']]); } $invitation->setHash($hash)->setMemberId($login->getId())->setType($type)->setFreeSignup(isset($data['free_signup']) && $data['free_signup'] ? 1 : 0)->setCreationDate(time())->save($con); return $invitation; }
public static function doSetupUnitTests() { $IT_SPECIALIST_EMAIL = '*****@*****.**'; \SystemStats::_refreshForUnitTests(); /* Setup - SYSTEM ACCOUNT ---------------------------------------------*/ self::createMember(null, ['LastName' => 'system', 'FirstName' => 'account', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_SYSTEM, 'Type' => \Member::TYPE_SYSTEM]); /* Setup - ROOT ACCOUNT ---------------------------------------------*/ self::createMember(null, ['LastName' => 'root', 'FirstName' => 'account', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_ROOT, 'Type' => \Member::TYPE_SYSTEM]); /* Setup - CEO1 ---------------------------------------------*/ $ceo1 = self::createMember(null, ['LastName' => 'system', 'FirstName' => 'ceo1', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_CEO1, 'Type' => \Member::TYPE_CEO]); }
public function testSnowballModel() { /* Setup ---------------------------------------------*/ $systemAccount = SystemStats::getSystemAccount(); $systemTransfer = new TransactionTotalsAssertions($systemAccount, $this); $promoter1 = DbEntityHelper::createMember(); $MYSELF = DbEntityHelper::createSignupMember($promoter1); $this->assertEquals($MYSELF->getFundsLevel(), Member::FUNDS_LEVEL1); /* Advertise 2 users ---------------------------------------------*/ $far_l1_1 = DbEntityHelper::createSignupMember($MYSELF); $bea_l1_2 = DbEntityHelper::createSignupMember($MYSELF); $this->assertEquals($MYSELF->getFundsLevel(), Member::FUNDS_LEVEL2); $MYSELF_total = new TransactionTotalsAssertions($MYSELF, $this); $MYSELF_total->add(Transaction::REASON_ADVERTISED_LVL1, 2); $MYSELF_total->assertTotals(); /* Advertise 1 more user - chris ---------------------------------------------*/ $CHRIS_l1_3 = DbEntityHelper::createSignupMember($MYSELF); // ---- assert - ME $MYSELF_total->add(Transaction::REASON_ADVERTISED_LVL2); $MYSELF_total->assertTotals(); /* chris advertise 1 user - dean ---------------------------------------------*/ $DEAN_l2_1 = DbEntityHelper::createSignupMember($CHRIS_l1_3); // ---- assert - CHRIS $CHRIS_transfer = DbEntityHelper::getCurrentTransferBundle($CHRIS_l1_3); $CHRIS_total = new TransactionTotalsAssertions($CHRIS_l1_3, $this); $CHRIS_total->add(Transaction::REASON_ADVERTISED_LVL1); $CHRIS_total->assertTotals(); // ---- assert - ME $MYSELF_total->add(Transaction::REASON_ADVERTISED_INDIRECT); $MYSELF_total->assertTotals(); /* chris advertise 1 user - emi ---------------------------------------------*/ $EMI_l2_2 = DbEntityHelper::createSignupMember($CHRIS_l1_3); // ---- assert - CHRIS $CHRIS_total->add(Transaction::REASON_ADVERTISED_LVL1); $CHRIS_total->assertTotals(); $this->assertEquals($CHRIS_l1_3->getFundsLevel(), Member::FUNDS_LEVEL2); // ---- assert - ME $MYSELF_total->add(Transaction::REASON_ADVERTISED_INDIRECT); $MYSELF_total->assertTotals(); /* dean advertise 1 user - franz ---------------------------------------------*/ $FRANZ_l3_1 = DbEntityHelper::createSignupMember($DEAN_l2_1); // ---- assert - CHRIS - remain at 10 euro $CHRIS_total->assertTotals(); // ---- assert - ME $MYSELF_total->add(Transaction::REASON_ADVERTISED_INDIRECT); $MYSELF_total->assertTotals(); DbEntityHelper::createSignupMember($DEAN_l2_1); DbEntityHelper::createSignupMember($EMI_l2_2); DbEntityHelper::createSignupMember($EMI_l2_2); $CHRIS_total->add(Transaction::REASON_ADVERTISED_LVL2); $CHRIS_total->add(Transaction::REASON_ADVERTISED_INDIRECT, 2); $ALF_l2_3 = DbEntityHelper::createSignupMember($CHRIS_l1_3); $GUST_l3_1 = DbEntityHelper::createSignupMember($ALF_l2_3); DbEntityHelper::createSignupMember($ALF_l2_3); // ---- assert - CHRIS - at 60 euro $CHRIS_total->assertTotals(); // ---- assert - ME $MYSELF_total->add(Transaction::REASON_ADVERTISED_INDIRECT, 3); $MYSELF_total->assertTotals(); $CHRIS_total->add(Transaction::REASON_ADVERTISED_INDIRECT, 2); DbEntityHelper::createSignupMember($GUST_l3_1); DbEntityHelper::createSignupMember($GUST_l3_1); // ---- assert - CHRIS - at 90 euro $CHRIS_total->assertTotals(); /* if anyone advertised more than 2 user i dont get anything from the third on ---------------------------------------------*/ DbEntityHelper::createSignupMember($CHRIS_l1_3); DbEntityHelper::createSignupMember($CHRIS_l1_3); DbEntityHelper::createSignupMember($CHRIS_l1_3); DbEntityHelper::createSignupMember($GUST_l3_1); DbEntityHelper::createSignupMember($GUST_l3_1); DbEntityHelper::createSignupMember($GUST_l3_1); DbEntityHelper::createSignupMember($ALF_l2_3); DbEntityHelper::createSignupMember($ALF_l2_3); DbEntityHelper::createSignupMember($ALF_l2_3); DbEntityHelper::createSignupMember($EMI_l2_2); DbEntityHelper::createSignupMember($EMI_l2_2); /* as well, i dont get anything but 5euro from my first advertisings ---------------------------------------------*/ DbEntityHelper::createSignupMember($bea_l1_2); DbEntityHelper::createSignupMember($bea_l1_2); DbEntityHelper::createSignupMember($bea_l1_2); // ---- assert - MYSELF $MYSELF_total->assertTotals(); }
/** * Do setup system. Execute once. * */ public static function doSetup() { $IT_SPECIALIST_EMAIL = '*****@*****.**'; /* Setup - SYSTEM ACCOUNT ---------------------------------------------*/ self::createMember(null, ['LastName' => 'account', 'FirstName' => 'system', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_SYSTEM, 'Type' => \Member::TYPE_SYSTEM, 'FundsLevel' => \Member::FUNDS_LEVEL2]); /* Setup - CEO1 ---------------------------------------------*/ $ceo1 = self::createMember(null, ['FirstName' => 'Marcus', 'LastName' => 'CEO', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_CEO1, 'Type' => \Member::TYPE_CEO, 'FundsLevel' => \Member::FUNDS_LEVEL2]); /* Setup - IT ---------------------------------------------*/ $it = self::createMember(null, ['FirstName' => 'System', 'LastName' => 'IT', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_IT, 'Type' => \Member::TYPE_ITSPECIALIST, 'FundsLevel' => \Member::FUNDS_LEVEL2]); /* Setup - SYLVHEIM ---------------------------------------------*/ $sylvheim = self::createMember(null, ['ReferrerId' => $ceo1->getId(), 'FirstName' => 'Sales', 'LastName' => 'Management', 'Email' => '*****@*****.**', 'Num' => \SystemStats::ACCOUNT_SYLVHEIM, 'Type' => \Member::TYPE_SALES_MANAGER, 'FundsLevel' => \Member::FUNDS_LEVEL2]); /* Setup - EXECUTIVE ---------------------------------------------*/ $executive = self::createMember(null, ['FirstName' => 'Administration', 'LastName' => 'Executive', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_EXECUTIVE, 'Type' => \Member::TYPE_MEMBER, 'FundsLevel' => \Member::FUNDS_LEVEL2]); /* Setup - REASON_NGO_PROJECTS ---------------------------------------------*/ // $ngoProjects = self::createMember(null, [ // 'FirstName' => 'Projects', // 'LastName' => 'NGO', // 'Email' => $IT_SPECIALIST_EMAIL, // 'Num' => \SystemStats::ACCOUNT_NGO_PROJECTS, // 'Type' => \Member::TYPE_MEMBER, // 'FundsLevel'=> \Member::FUNDS_LEVEL2 // ]); /* Setup - TOP LEVEL BONUS IDS ---------------------------------------------*/ $topLvlBonusIds = json_encode([$ceo1->getId() => $ceo1->getType(), $it->getId() => $it->getType(), $executive->getId() => $executive->getType()]); $salesManagerBonusIds = json_encode([$ceo1->getId() => $ceo1->getType(), $it->getId() => $it->getType(), $sylvheim->getId() => $sylvheim->getType(), $executive->getId() => $executive->getType()]); $ceo1->setBonusIds($topLvlBonusIds); $it->setBonusIds($topLvlBonusIds); $sylvheim->setBonusIds($salesManagerBonusIds); $executive->setBonusIds($topLvlBonusIds); // $taricWani->setBonusIds($topLvlBonusIds); // $ngoProjects->setBonusIds($topLvlBonusIds); $ceo1->save(self::$con); $it->save(self::$con); $sylvheim->save(self::$con); $executive->save(self::$con); // $taricWani->save(self::$con); // $ngoProjects->save(self::$con); /* SET auto increment counter for member numbers ---------------------------------------------*/ $sql = "ALTER TABLE tbmt_member AUTO_INCREMENT=1000001"; $stmt = self::$con->prepare($sql); $stmt->execute(); /* Setup - SYSTEM STATS ---------------------------------------------*/ $systemStats = new \SystemStats(); $systemStats->setInvitationIncrementer('2A15F6'); $systemStats->save(); }
public static function _refreshForUnitTests() { self::$systemAccount = null; }