/**
  * SetUp
  */
 function _start()
 {
     $this->userLogin = '******';
     $this->userPass = '******';
     $options = array('user_login' => $this->userLogin, 'user_pass' => sha1($this->userPass), 'user_active' => 1, 'user_new' => 0);
     CreateObjectHelper::makeUser($options);
 }
 /**
  * Удаление почты пользователя
  */
 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));
 }
Esempio n. 3
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 testStat()
 {
     $login = '******' . mktime();
     $pass = '******';
     $options = array('user_login' => $login, 'user_pass' => sha1($pass), 'user_active' => 1, 'user_new' => 0, 'user_currency_default' => myMoney::UAH);
     CreateObjectHelper::makeUser($options);
     $user = new oldUser($login, $pass);
     // Счета
     $options = array('user_id' => $user->getId(), 'account_name' => 'USD Account For stat test', 'account_currency_id' => myMoney::USD);
     $account = CreateObjectHelper::makeAccount($options);
     $operation = new Operation_Model($user);
     $options = array('user_id' => $user->getId());
     $catId = CreateObjectHelper::createCategory($options);
     $dateFrom = '2009-12-29';
     $dateTo = '2010-01-02';
     $rate = sfConfig::get('ex')->getRate(myMoney::UAH, myMoney::USD);
     $usdSpent = 100;
     $uahSpent = $usdSpent / $rate;
     $opId = $operation->add(Operation::TYPE_EXPENSE, $usdSpent, '2010-01-01', $catId, 'Комментарий', $account['account_id'], array('тег 1'));
     $stat = $operation->getOperationList($dateFrom, $dateTo, null, null, -1, null, null, null, true);
     $this->assertEquals(round($uahSpent, 2), round(abs($stat), 2), 'Expected 100 dollars have been spent');
 }