public function testAccountBuilderDemolish() { $accountNumber = 1; $accountName = 'an account'; $dateOpened = new DateTime(); $dateClosed = new DateTime(); $dateClosed->setDate(3000, 1, 1); $groupId = 1; $builder = new AccountBuilder(); $entity = new Account(); $column = array('account_number' => $accountNumber, 'account_name' => $accountName, 'account_date_opened' => $dateOpened, 'account_date_closed' => $dateClosed, 'account_group_id' => $groupId); $entity->setAccountNumber($accountNumber); $entity->setAccountName($accountName); $entity->setDateOpened($dateOpened); $entity->setDateClosed($dateClosed); $entity->setGroupId($groupId); $this->assertEquals($column, $builder->demolish($entity)); }
/** * Convert data array into entity * * @return Account * @param array $data * @access public */ public function build($data) { $account = new Account(); $account->setAccountNumber($data['account_number']); $account->setAccountName($data['account_name']); $account->setDateOpened($data['account_date_opened']); $account->setDateClosed($data['account_date_closed']); # account group is managed via the marshaler return $account; }
/** * Will do node construction and assignment passback parent. * * @access public * @return NodeBuilderInterface * */ public function end() { $account = new Account(); $closed = new DateTime(); $closed->setDate(3000, 1, 1); $closed->setTime(0, 0, 0); # group id will be set later when group has # been saved $account->setAccountName($this->accountName); $account->setAccountNumber($this->accountNumber); $account->setDateOpened($this->now); $account->setDateClosed($closed); # attach the new entity to node to the tree node $this->getNode()->setInternal($account); # add account to an account group $parentTreeNode = $this->parentNode->getNode()->addChild($this->accountTreeNode); return $this->parentNode; }
/** * Return all entries that use the given account * * @access public * @return array[AccountEntry] * */ public function findByAccount(Account $account) { $iterator = $this->getIterator(); $entryList = array(); foreach ($iterator as $ac) { if ($ac->getAccountId() === $account->getAccountId()) { $indexRemove[] = $ac; } } return $entryList; }
/** * @expectedException IComeFromTheNet\Ledger\Exception\LedgerException * @expectedExceptionMessage Date the account opened must be before the set closed date * */ public function testErrorAccountDateOpenedOccursAfterClose() { $account = new Account(); $dateOpened = new DateTime(); $dateClosed = clone $dateOpened; $account->setDateClosed($dateClosed); $account->setDateOpened($dateOpened); }