/** * @return array */ public function getPaymentTermDataProvider() { $account = new Account(); $accountWithGroup = new Account(); $accountWithGroup->setGroup(new AccountGroup()); $paymentTerm = new PaymentTerm(); return [['account' => $account, 'repositoryMethods' => ['getOnePaymentTermByAccount' => ['expects' => $this->once(), 'with' => $account, 'willReturn' => $paymentTerm], 'getOnePaymentTermByAccountGroup' => ['expects' => $this->never()]], 'expected' => $paymentTerm], ['account' => $account, 'repositoryMethods' => ['getOnePaymentTermByAccount' => ['expects' => $this->once(), 'with' => $account, 'willReturn' => null], 'getOnePaymentTermByAccountGroup' => ['expects' => $this->never()]], 'expected' => null], ['account' => $accountWithGroup, 'repositoryMethods' => ['getOnePaymentTermByAccount' => ['expects' => $this->once(), 'with' => $accountWithGroup, 'willReturn' => null], 'getOnePaymentTermByAccountGroup' => ['expects' => $this->once(), 'with' => $accountWithGroup->getGroup(), 'willReturn' => $paymentTerm]], 'expected' => $paymentTerm], ['account' => $accountWithGroup, 'repositoryMethods' => ['getOnePaymentTermByAccount' => ['expects' => $this->once(), 'with' => $accountWithGroup, 'willReturn' => null], 'getOnePaymentTermByAccountGroup' => ['expects' => $this->once(), 'with' => $accountWithGroup->getGroup(), 'willReturn' => null]], 'expected' => null]]; }
/** * @param Account $account * @return null|PriceList */ protected function getPriceListFromAccountGroup(Account $account) { $accountGroup = $account->getGroup(); if (!$accountGroup) { return null; } $priceList = $this->getPriceListRepository()->getPriceListByAccountGroup($accountGroup); if ($priceList) { return $priceList; } return null; }