Skip to content

Commit

Permalink
Add new shopware versions to git workflow (#283)
Browse files Browse the repository at this point in the history
* Add new shopware versions to git workflow

* Fix phpstan errors

* Fix wrong parameter in unit tests

* Add 6.5.7.3 and missing test traits from shopware core

---------

Co-authored-by: Moritz Müller <moritz.mueller@interlutions.de>
  • Loading branch information
momocode-de and Moritz Müller authored Jan 9, 2024
1 parent c0e11db commit da1c483
Show file tree
Hide file tree
Showing 18 changed files with 394 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
matrix:
php-versions: [ '8.1', '8.2' ]
mysql-versions: [ '5.7', '8.0' ]
shopware-versions: [ 'v6.5.0.0', 'v6.5.1.0', 'v6.5.2.0' ]
shopware-versions: [ 'v6.5.0.0', 'v6.5.1.0', 'v6.5.2.0', 'v6.5.3.0', 'v6.5.4.0', 'v6.5.5.0', 'v6.5.6.0', 'v6.5.7.3' ]
services:
mysql:
image: mysql:${{ matrix.mysql-versions }}
Expand Down
5 changes: 4 additions & 1 deletion src/Components/CardRepository/CardRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ public function getExistingCard(
new EqualsFilter('payone_payment_card.customerId', $customer->getId())
);

return $this->cardRepository->search($criteria, $context)->first();
/** @var PayonePaymentCardEntity|null $card */
$card = $this->cardRepository->search($criteria, $context)->first();

return $card;
}
}
5 changes: 4 additions & 1 deletion src/Components/Helper/OrderFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ public function getOrderById(string $orderId, Context $context): ?OrderEntity
$criteria = $this->getOrderCriteria();
$criteria->addFilter(new EqualsFilter('id', $orderId));

return $this->orderRepository->search($criteria, $context)->first();
/** @var OrderEntity|null $order */
$order = $this->orderRepository->search($criteria, $context)->first();

return $order;
}

public function getOrderBillingAddress(OrderEntity $order): OrderAddressEntity
Expand Down
2 changes: 2 additions & 0 deletions src/Components/KlarnaSessionService/KlarnaSessionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use PayonePayment\Payone\RequestParameter\Struct\KlarnaCreateSessionStruct;
use PayonePayment\Storefront\Struct\CheckoutKlarnaSessionData;
use Shopware\Core\Checkout\Cart\SalesChannel\CartService;
use Shopware\Core\Checkout\Order\OrderEntity;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\System\SalesChannel\SalesChannelContext;

Expand All @@ -28,6 +29,7 @@ public function createKlarnaSession(SalesChannelContext $salesChannelContext, ?s
{
if ($orderId) {
$orderCriteria = $this->cartHasher->getCriteriaForOrder($orderId);
/** @var OrderEntity|null $order */
$order = $this->orderEntityRepository->search($orderCriteria, $salesChannelContext->getContext())->first();
}

Expand Down
5 changes: 4 additions & 1 deletion src/Components/MandateService/MandateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ protected function getExistingMandate(
new EqualsFilter('customerId', $customer->getId())
);

return $this->mandateRepository->search($criteria, $context)->first();
/** @var PayonePaymentMandateEntity|null $mandate */
$mandate = $this->mandateRepository->search($criteria, $context)->first();

return $mandate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ protected function getTransaction(string $transactionId): ?OrderTransactionEntit
$criteria->addAssociation('order.deliveries');
$criteria->addAssociation('paymentMethod');

return $this->transactionRepository->search($criteria, $this->context)->first();
/** @var OrderTransactionEntity|null $transaction */
$transaction = $this->transactionRepository->search($criteria, $this->context)->first();

return $transaction;
}
}
4 changes: 3 additions & 1 deletion src/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public function validateApiCredentials(Request $request, Context $context): Json
$criteria = (new Criteria())->addFilter(new EqualsFilter('handlerIdentifier', $paymentClass));
$paymentMethod = $this->paymentMethodRepository->search($criteria, $context)->first();

if (!$paymentMethod || !$paymentMethod->getActive() || \in_array($paymentMethod->getHandlerIdentifier(), Handler\PaymentHandlerGroups::RATEPAY, true)) {
if (!$paymentMethod instanceof PaymentMethodEntity
|| !$paymentMethod->getActive()
|| \in_array($paymentMethod->getHandlerIdentifier(), Handler\PaymentHandlerGroups::RATEPAY, true)) {
continue;
}

Expand Down
5 changes: 4 additions & 1 deletion src/EventListener/CheckoutFinishEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ private function getMandate(string $mandateIdentification, Context $context): ?P
$criteria = new Criteria();
$criteria->addFilter(new EqualsFilter('identification', $mandateIdentification));

return $this->mandateRepository->search($criteria, $context)->first();
/** @var PayonePaymentMandateEntity|null $mandate */
$mandate = $this->mandateRepository->search($criteria, $context)->first();

return $mandate;
}

private function getMandateIdentification(OrderEntity $order, Context $context): ?string
Expand Down
5 changes: 4 additions & 1 deletion src/Installer/PaymentMethodInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,12 @@ private function getPaymentMethods(): array

private function findPaymentMethodEntity(string $id, Context $context): ?PaymentMethodEntity
{
return $this->paymentMethodRepository
/** @var PaymentMethodEntity|null $paymentMethod */
$paymentMethod = $this->paymentMethodRepository
->search(new Criteria([$id]), $context)
->first();

return $paymentMethod;
}

private function upsertPaymentMethod(PaymentMethodInterface $paymentMethod, Context $context): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ private function getOrderById(AbstractRequestParameterStruct $arguments): ?Order
$criteria->addAssociation('addresses');
$criteria->addAssociation('addresses.country');

return $this->orderRepository->search($criteria, $context)->first();
/** @var OrderEntity|null $order */
$order = $this->orderRepository->search($criteria, $context)->first();

return $order;
}

private function getCardType(ParameterBag $requestDataBag): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private function getCustomerSalutation(CustomerAddressEntity $addressEntity, Con

$salutation = $this->salutationRepository->search($criteria, $context)->first();

if ($salutation === null) {
if (!$salutation instanceof SalutationEntity) {
throw new \RuntimeException('missing order customer salutation');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace PayonePayment\Storefront\Controller\Account;

use PayonePayment\PaymentHandler\PaymentHandlerGroups;
use Shopware\Core\Checkout\Order\OrderEntity;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
Expand Down Expand Up @@ -77,6 +78,7 @@ protected function isRatepayOrder(string $orderId, Context $context): bool
$criteria = new Criteria([$orderId]);
$criteria->addAssociation('transactions.paymentMethod');

/** @var OrderEntity|null $order */
$order = $this->orderRepository->search($criteria, $context)->first();

if ($order && $order->getTransactions()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ private function performPayment(
$paymentHandler->pay(
new SyncPaymentTransactionStruct(
$paymentTransaction->getOrderTransaction(),
$paymentTransaction->getOrder(),
''
$paymentTransaction->getOrder()
),
$dataBag,
$salesChannelContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ private function performPayment(
$paymentHandler->pay(
new SyncPaymentTransactionStruct(
$paymentTransaction->getOrderTransaction(),
$paymentTransaction->getOrder(),
''
$paymentTransaction->getOrder()
),
$dataBag,
$salesChannelContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ private function performPayment(
$paymentHandler->pay(
new SyncPaymentTransactionStruct(
$paymentTransaction->getOrderTransaction(),
$paymentTransaction->getOrder(),
''
$paymentTransaction->getOrder()
),
$dataBag,
$salesChannelContext
Expand Down
1 change: 0 additions & 1 deletion tests/TestCaseBase/PayoneTestBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
use Shopware\Core\System\StateMachine\Aggregation\StateMachineState\StateMachineStateEntity;
use Shopware\Core\Test\TestDefaults;
use Shopware\Storefront\Page\Checkout\Confirm\CheckoutConfirmPageLoader;
use Shopware\Storefront\Test\Page\StorefrontPageTestBehaviour;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
Expand Down
Loading

0 comments on commit da1c483

Please sign in to comment.