Skip to content

Commit

Permalink
Final fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Zales0123 committed Jun 11, 2021
1 parent e480edc commit 0ab7fed
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 6 deletions.
12 changes: 12 additions & 0 deletions src/Doctrine/ORM/InvoiceRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,16 @@ public function findOneByOrder(OrderInterface $order): ?InvoiceInterface

return $invoice;
}

public function findByOrderNumber(string $orderNumber): array
{
return $this
->createQueryBuilder('invoice')
->innerJoin('invoice.order', 'o')
->where('o.number = :orderNumber')
->setParameter('orderNumber', $orderNumber)
->getQuery()
->getResult()
;
}
}
2 changes: 2 additions & 0 deletions src/Doctrine/ORM/InvoiceRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@
interface InvoiceRepositoryInterface extends RepositoryInterface
{
public function findOneByOrder(OrderInterface $order): ?InvoiceInterface;

public function findByOrderNumber(string $orderNumber): array;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

{% block body %}
{% autoescape %}
Invoice with id {{ invoice.id }} was generated for order with number #{{ invoice.orderNumber }}.
Invoice with id {{ invoice.id }} was generated for order with number #{{ invoice.order.number }}.
<br/><br/>
You can find the document in this email's attachments.
{% endautoescape %}
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/views/Invoice/Show/_header.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{{ 'sylius_invoicing_plugin.ui.issued_at'|trans }}: <span id="invoice-issued-at">{{ invoice.issuedAt|format_datetime }}</span>
</div>
<div class="item">
{{ 'sylius_invoicing_plugin.ui.issued_for_order'|trans }}: #{{ invoice.orderNumber }}
{{ 'sylius_invoicing_plugin.ui.issued_for_order'|trans }}: #{{ invoice.order.number }}
</div>
<div class="item">
{{ 'sylius_invoicing_plugin.ui.issued_from'|trans }}
Expand Down
2 changes: 1 addition & 1 deletion tests/Behat/Context/Domain/GeneratingInvoiceContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(ObjectManager $invoiceManager, InvoiceRepositoryInte
*/
public function orderHasLostAllOfItsInvoices(string $orderNumber): void
{
$invoice = $this->invoiceRepository->findOneByOrderNumber($orderNumber);
$invoice = $this->invoiceRepository->findByOrderNumber($orderNumber)[0];

$this->invoiceManager->remove($invoice);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Behat/Context/Ui/Admin/ManagingInvoicesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function viewSummaryOfInvoiceForOrder(OrderInterface $order): void
{
$this->indexPage->open();

$invoiceId = $this->invoiceRepository->findOneByOrderNumber($order->getNumber())->id();
$invoiceId = $this->invoiceRepository->findByOrderNumber($order->getNumber())[0]->id();

$this->showPage->open(['id' => $invoiceId]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function pdfFileForThisInvoiceShouldBeDownloadedSuccessfully(): void
public function tryToDownloadInvoiceForOrder(string $orderNumber): void
{
/** @var InvoiceInterface $invoice */
$invoice = $this->invoiceRepository->findOneByOrderNumber($orderNumber);
$invoice = $this->invoiceRepository->findByOrderNumber($orderNumber)[0];

$this->downloadInvoicePage->tryToOpen(['id' => $invoice->id()]);
}
Expand All @@ -65,7 +65,7 @@ public function tryToDownloadInvoiceForOrder(string $orderNumber): void
public function invoiceForOrderShouldNotBeDownloaded(string $orderNumber): void
{
/** @var InvoiceInterface $invoice */
$invoice = $this->invoiceRepository->findOneByOrderNumber($orderNumber);
$invoice = $this->invoiceRepository->findByOrderNumber($orderNumber)[0];

Assert::false($this->downloadInvoicePage->isOpen(['id' => $invoice->id()]));
}
Expand Down

0 comments on commit 0ab7fed

Please sign in to comment.