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);
 }
Example #2
0
 public function testAccountState()
 {
     $account = CreateObjectHelper::makeAccount();
     $this->assertEquals(Account::STATE_NORMAL, $account['account_state']);
     $account = CreateObjectHelper::makeAccount(array('account_state' => Account::STATE_FAVORITE));
     $this->assertEquals(Account::STATE_FAVORITE, $account['account_state']);
     $account = CreateObjectHelper::makeAccount(array('account_state' => Account::STATE_ARCHIVE));
     $this->assertEquals(Account::STATE_ARCHIVE, $account['account_state']);
 }
 /**
  * Удаление почты пользователя
  */
 public function testDeleteServiceMail()
 {
     // Фэлз, ибо нет почты
     $options = array('user_login' => 'user1' . rand(1, 10000), 'user_pass' => sha1($pass = '******'), 'user_new' => 0, 'user_service_mail' => '');
     CreateObjectHelper::makeUser($options);
     $this->assertFalse($this->profile1->deleteServiceMail(new oldUser($options['user_login'], $pass)));
     // Тру, почта удалена
     $this->assertTrue($this->profile1->deleteServiceMail($this->user2));
 }
Example #4
0
 /**
  * Создать набор дефолтных счетов
  */
 public function testInsertDefaultAccounts()
 {
     $userId = CreateObjectHelper::makeUser();
     $date = date('Y-m-d H:i:s');
     Login_Model::defaultAccounts($userId);
     $count = $this->getConnection()->selectCell("SELECT count(*) FROM accounts WHERE user_id=?", $userId);
     $this->assertTrue((bool) $count, "Expected accounts were created");
     // Timestampable
     $cat = $this->getConnection()->selectRow("SELECT * FROM accounts WHERE user_id=? LIMIT 1", $userId);
     $this->assertEquals($date, $cat['created_at']);
     $this->assertEquals($cat['created_at'], $cat['updated_at']);
 }
 /**
  * Тест перевода на долговой счёт
  */
 public function testDebtTransfer()
 {
     $this->_prepareOperation();
     // Долговой счёт
     $options = array('user_id' => $this->userId, 'account_name' => 'Debt account', 'account_currency_id' => myMoney::RUR, 'account_type_id' => Account_Collection::ACCOUNT_TYPE_CREDIT);
     $account = CreateObjectHelper::makeAccount($options);
     $toAccountId = $account['account_id'];
     $options = array('user_id' => $this->userId, 'system_category_id' => Category_Model::DEBT_SYSTEM_CATEGORY_ID);
     $debtCategoryId = CreateObjectHelper::createCategory($options);
     $this->user->init();
     $this->user->save();
     $operation = new Operation_Model($this->user);
     // Перевели 100 рублей с рублёвого на долларовый
     $opId = $operation->addTransfer(100, 0, 0, '2010-01-01', $this->accountId, $toAccountId, 'Комментарий', array('тег 1'));
     $dateFrom = '2009-12-29';
     $dateTo = '2010-01-02';
     $list = $operation->getOperationList($dateFrom, $dateTo);
     $this->assertEquals($debtCategoryId, $list[0]['cat_id'], 'Expected only 1 transfer operation');
 }