private function _makeOperation() { $this->user = new oldUser($this->userLogin, $this->userPass); $this->userId = $this->user->getId(); $options = array('user_id' => $this->userId, 'chain_id' => 999, 'date' => date('Y-m-d', time() - 86400)); // Правильные операции, на вчера CreateObjectHelper::makeOperation($options); CreateObjectHelper::makeOperation($options); CreateObjectHelper::makeOperation($options); // Операция не выполнена $data = $options; $data['accepted'] = 0; CreateObjectHelper::makeOperation($data); // Дата операции установлена на завтра $data = $options; $data['accepted'] = 0; $data['date'] = date('Y-m-d', time() + 86400); CreateObjectHelper::makeOperation($data); // Дата операции установлена на завтра, но она отмечена выполненной $data = $options; $data['accepted'] = 1; $data['date'] = date('Y-m-d', time() + 86400); CreateObjectHelper::makeOperation($data); // Удалённая операция $data = $options; $data['accepted'] = 0; $data['deleted_at'] = '2010-02-02 02:02:02'; CreateObjectHelper::makeOperation($data); // Обычная операция, вне цепочки unset($options['deleted_at']); unset($options['chain_id']); CreateObjectHelper::makeOperation($options); }
/** * Создаём операции */ private function _makeOperation() { $options = array('user_id' => $this->userId, 'chain_id' => 999, 'date' => date('Y-m-d', time() - 86400), 'cat_id' => $this->catId, 'account_id' => $this->accountId); // Правильные операции, на вчера CreateObjectHelper::makeOperation($options); CreateObjectHelper::makeOperation($options); CreateObjectHelper::makeOperation($options); // Операция не выполнена $options['accepted'] = 0; CreateObjectHelper::makeOperation($options); // Дата операции установлена на завтра $options['date'] = date('Y-m-d', time() + 86400); CreateObjectHelper::makeOperation($options); // Дата операции установлена на завтра, но она отмечена выполненной $options['accepted'] = 1; $options['date'] = date('Y-m-d', time() + 86400); CreateObjectHelper::makeOperation($options); // Удалённая операция $options['deleted_at'] = '2010-02-02 02:02:02'; CreateObjectHelper::makeOperation($options); // Обычная операция, вне цепочки unset($options['deleted_at']); unset($options['chain_id']); CreateObjectHelper::makeOperation($options); }
/** * Получить список всех счетов пользователя со статистикой по балансу и пр. */ public function testLoadAllWithStat() { $accountA = CreateObjectHelper::makeAccount(); $account1 = CreateObjectHelper::makeAccount(); $account2 = CreateObjectHelper::makeAccount(array('deleted_at' => '2010-06-04', 'user_id' => $account1['user_id'])); // Начальный баланс CreateObjectHelper::makeBalanceOperation($account1, $initBalance = 123.45); // Обычная операция CreateObjectHelper::makeOperation(array('user_id' => $account1['user_id'], 'account_id' => $account1['account_id'], 'money' => $amount = 5)); // Резерв на финцель $model = new Account_Model(); $result = $model->loadAllWithStat($account1['user_id']); $this->assertEquals(array($account1['account_id'] => array('id' => $account1['account_id'], 'type' => $account1['account_type_id'], 'currency' => $account1['account_currency_id'], 'name' => $account1['account_name'], 'comment' => $account1['account_description'], 'state' => Account::STATE_NORMAL, 'totalBalance' => $amount + $initBalance, 'reserve' => 0, 'initBalance' => $initBalance)), $result); }