This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -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);
}
}