init
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Cart\Test\Unit\Plugin\TestMode;
|
||||
|
||||
use Esun\Cart\Model\TestModeConfig;
|
||||
use Esun\Cart\Plugin\TestMode\RestrictAddToCartPlugin;
|
||||
use Magento\Checkout\Model\Cart;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class RestrictAddToCartPluginTest extends TestCase
|
||||
{
|
||||
public function testAllowsAddToCartWhenCustomerIsNotRestricted(): void
|
||||
{
|
||||
$config = $this->createMock(TestModeConfig::class);
|
||||
$config->method('isRestricted')->willReturn(false);
|
||||
|
||||
$plugin = new RestrictAddToCartPlugin($config);
|
||||
|
||||
self::assertNull($plugin->beforeAddProduct($this->createMock(Cart::class), 10));
|
||||
}
|
||||
|
||||
public function testRejectsAddToCartWhenCustomerIsRestricted(): void
|
||||
{
|
||||
$config = $this->createMock(TestModeConfig::class);
|
||||
$config->method('isRestricted')->willReturn(true);
|
||||
|
||||
$plugin = new RestrictAddToCartPlugin($config);
|
||||
|
||||
$this->expectException(LocalizedException::class);
|
||||
$this->expectExceptionMessage('Our website is currently in beta testing.');
|
||||
$plugin->beforeAddProduct($this->createMock(Cart::class), 10);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user