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\LingxingErp\Test\Unit\Observer;
use Esun\LingxingErp\Model\Order\CancellationSourceResolver;
use Esun\LingxingErp\Observer\RecordOrderCancellation;
use Magento\Framework\Event;
use Magento\Framework\Event\Observer;
use Magento\Sales\Model\Order;
use PHPUnit\Framework\TestCase;
class RecordOrderCancellationTest extends TestCase
{
public function testAddsLocalCancellationSourceCommentOnly(): void
{
$sourceResolver = $this->createMock(CancellationSourceResolver::class);
$sourceResolver->expects(self::once())
->method('resolve')
->willReturn(CancellationSourceResolver::CUSTOMER);
$sourceResolver->expects(self::once())
->method('getComment')
->with(CancellationSourceResolver::CUSTOMER)
->willReturn('The customer canceled this order from their account.');
$order = $this->createMock(Order::class);
$order->expects(self::once())
->method('addCommentToStatusHistory')
->with('The customer canceled this order from their account.');
(new RecordOrderCancellation($sourceResolver))->execute(new Observer([
'event' => new Event(['order' => $order]),
]));
}
}
@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
namespace Esun\LingxingErp\Test\Unit\Observer;
use Esun\LingxingErp\Model\Warehouse\WarehouseRepository;
use Esun\LingxingErp\Observer\SaveSourceWarehouseMapping;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Event\Observer;
use Magento\InventoryApi\Api\Data\SourceInterface;
use PHPUnit\Framework\TestCase;
class SaveSourceWarehouseMappingTest extends TestCase
{
public function testAssignsSelectedWarehouseAfterSourceSave(): void
{
$repository = $this->createMock(WarehouseRepository::class);
$repository->expects(self::once())->method('assignSource')->with('uk', 42);
$request = $this->createMock(RequestInterface::class);
$request->method('getParam')->with('general')->willReturn(['lingxing_wid' => '42']);
$source = $this->createMock(SourceInterface::class);
$source->method('getSourceCode')->willReturn('uk');
(new SaveSourceWarehouseMapping($repository))->execute(new Observer([
'request' => $request,
'source' => $source,
]));
}
public function testClearsMappingWhenEmptyOptionIsSelected(): void
{
$repository = $this->createMock(WarehouseRepository::class);
$repository->expects(self::once())->method('assignSource')->with('eu', null);
$request = $this->createMock(RequestInterface::class);
$request->method('getParam')->with('general')->willReturn(['lingxing_wid' => '']);
$source = $this->createMock(SourceInterface::class);
$source->method('getSourceCode')->willReturn('eu');
(new SaveSourceWarehouseMapping($repository))->execute(new Observer([
'request' => $request,
'source' => $source,
]));
}
}