Skip to content

Commit

Permalink
Merge pull request #411 from mollie/1.27.1
Browse files Browse the repository at this point in the history
1.27.1
  • Loading branch information
Marvin-Magmodules committed Jun 29, 2021
2 parents b72abaa + f14ffcf commit 533c2b6
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 16 deletions.
16 changes: 8 additions & 8 deletions GraphQL/Resolver/Cart/ResetCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Mollie\Payment\GraphQL\Resolver\Cart;

use Magento\Framework\App\ObjectManager;
use Magento\Framework\GraphQl\Config\Element\Field;
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Query\ResolverInterface;
Expand All @@ -15,21 +16,14 @@

class ResetCart implements ResolverInterface
{
/**
* @var GetCartForUser
*/
private $getCartForUser;

/**
* @var CartRepositoryInterface
*/
private $cartRepository;

public function __construct(
GetCartForUser $cartForUser,
CartRepositoryInterface $cartRepository
) {
$this->getCartForUser = $cartForUser;
$this->cartRepository = $cartRepository;
}

Expand All @@ -42,7 +36,13 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
$maskedCartId = $args['input']['cart_id'];

$storeId = (int)$context->getExtensionAttributes()->getStore()->getId();
$cart = $this->getCartForUser->execute($maskedCartId, $context->getUserId(), $storeId);

/**
* Use the ObjectManager to prevent setup:di:compile errors when people replace the GraphQL modules.
*/
/** @var GetCartForUser $getCartForUser */
$getCartForUser = ObjectManager::getInstance()->get(GetCartForUser::class);
$cart = $getCartForUser->execute($maskedCartId, $context->getUserId(), $storeId);

$cart->setIsActive(1);
$this->cartRepository->save($cart);
Expand Down
7 changes: 4 additions & 3 deletions Model/MollieConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,12 @@ public function getConfig()
}

/**
* @param \Mollie\Api\MollieApiClient $mollieApi
* @param MollieApiClient $mollieApi
* @param CartInterface|null $cart
*
* @return array
*/
public function getActiveMethods($mollieApi, CartInterface $cart = null)
public function getActiveMethods(MollieApiClient $mollieApi, CartInterface $cart = null): array
{
if (!$cart) {
$cart = $this->checkoutSession->getQuote();
Expand All @@ -246,8 +246,9 @@ public function getActiveMethods($mollieApi, CartInterface $cart = null)
'resource' => 'orders',
'includeWallets' => 'applepay',
];
$apiMethods = $mollieApi->methods->allActive($this->methodParameters->enhance($parameters, $cart));

$this->methodData = [];
$apiMethods = $mollieApi->methods->allActive($this->methodParameters->enhance($parameters, $cart));
foreach ($apiMethods as $method) {
$methodId = 'mollie_methods_' . $method->id;
$this->methodData[$methodId] = [
Expand Down
6 changes: 3 additions & 3 deletions Service/Order/Reorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ private function recreate(OrderInterface $originalOrder, string $method = 'molli

$order = $this->orderCreate->createOrder();

$order->setState(Order::STATE_PROCESSING);
$order->setStatus(Order::STATE_PROCESSING);
$order->setState(Order::STATE_PENDING_PAYMENT);
$order->setStatus(Order::STATE_PENDING_PAYMENT);

$this->transaction->addObject($order);
$this->transaction->addObject($originalOrder);
Expand Down Expand Up @@ -196,4 +196,4 @@ private function addCommentHistoryOriginalOrder(OrderInterface $originalOrder, $
$comment = __('We created a new order with increment ID: %1', $newIncrementId);
$this->orderCommentHistory->add($originalOrder, $comment, false);
}
}
}
18 changes: 18 additions & 0 deletions Test/Integration/Model/MollieConfigProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Mollie\Payment\Test\Integration\Model;

use Magento\Framework\Locale\Resolver;
use Mollie\Api\Endpoints\MethodEndpoint;
use Mollie\Api\Resources\MethodCollection;
use Mollie\Payment\Config;
use Mollie\Payment\Model\MollieConfigProvider;
use Mollie\Payment\Test\Integration\IntegrationTestCase;
Expand Down Expand Up @@ -108,4 +110,20 @@ public function testContainsTheLocale()

$this->assertSame('nl_NL', $result['payment']['mollie']['locale']);
}

public function testWhenNoActiveMethodsAvailableTheResultIsAnEmptyArray()
{
$methodMock = $this->createMock(MethodEndpoint::class);
$methodMock->method('allActive')->willReturn(new MethodCollection(0, new \stdClass));

$api = new \Mollie\Api\MollieApiClient;
$api->methods = $methodMock;

/** @var MollieConfigProvider $instance */
$instance = $this->objectManager->create(MollieConfigProvider::class);
$result = $instance->getActiveMethods($api);

$this->assertTrue(is_array($result), 'We expect an array');
$this->assertCount(0, $result);
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mollie/magento2",
"description": "Mollie Payment Module for Magento 2",
"version": "1.27.0",
"version": "1.27.1",
"keywords": [
"mollie",
"payment",
Expand Down
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<default>
<payment>
<mollie_general>
<version>v1.27.0</version>
<version>v1.27.1</version>
<active>0</active>
<enabled>0</enabled>
<type>test</type>
Expand Down

0 comments on commit 533c2b6

Please sign in to comment.