Skip to content

Commit 7e707e1

Browse files
committed
MAGETWO-58255: Unable to view signed up billing agreement on storefront
- Added validation for empty quote
1 parent fdfe68f commit 7e707e1

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

app/code/Magento/Vault/Model/Method/Vault.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ public function assignData(\Magento\Framework\DataObject $data)
579579
public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
580580
{
581581
return $this->getVaultProvider()->isAvailable($quote)
582-
&& $this->config->getValue(self::$activeKey, $this->getStore() ?: $quote->getStoreId());
582+
&& $this->config->getValue(self::$activeKey, $this->getStore() ?: ($quote ? $quote->getStoreId() : null));
583583
}
584584

585585
/**

app/code/Magento/Vault/Test/Unit/Model/Method/VaultTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,4 +274,32 @@ public function isAvailableDataProvider()
274274
['isAvailableProvider' => true, 'isActiveVault' => true, 'expected' => true],
275275
];
276276
}
277+
278+
/**
279+
* @covers \Magento\Vault\Model\Method\Vault::isAvailable
280+
*/
281+
public function testIsAvailableWithoutQuote()
282+
{
283+
$quote = null;
284+
285+
$vaultProvider = $this->getMockForAbstractClass(MethodInterface::class);
286+
$config = $this->getMockForAbstractClass(ConfigInterface::class);
287+
288+
$vaultProvider->expects(static::once())
289+
->method('isAvailable')
290+
->with($quote)
291+
->willReturn(true);
292+
293+
$config->expects(static::once())
294+
->method('getValue')
295+
->with('active', $quote)
296+
->willReturn(false);
297+
298+
/** @var Vault $model */
299+
$model = $this->objectManager->getObject(Vault::class, [
300+
'config' => $config,
301+
'vaultProvider' => $vaultProvider
302+
]);
303+
static::assertFalse($model->isAvailable($quote));
304+
}
277305
}

0 commit comments

Comments
 (0)