SuperSeller3000/tests/Unit/Infrastructure/Channel/Ebay/EbayAdapterTest.php
Simon Kuehn 46cff4553f feat: add eBay and Frappe channel adapters with order infrastructure
eBay adapter covers OAuth, inventory API, fulfillment API, taxonomy
service and webhook signature verification. Frappe ERP adapter wraps
the Frappe HTTP client for order/invoice sync.

Includes CustomerResolver, InvoiceMailer, and the EbayWebhookController
for inbound eBay marketplace notifications.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 22:43:52 +00:00

61 lines
2.1 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Tests\Unit\Infrastructure\Channel\Ebay;
use App\Domain\Article\Article;
use App\Domain\Article\ArticleCondition;
use App\Domain\Article\ArticleType;
use App\Infrastructure\Channel\Ebay\EbayAdapter;
use App\Infrastructure\Channel\Ebay\EbayInventoryApiClient;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
final class EbayAdapterTest extends TestCase
{
private EbayInventoryApiClient&MockObject $apiClient;
private EbayAdapter $adapter;
private Article $article;
protected function setUp(): void
{
$this->apiClient = $this->createMock(EbayInventoryApiClient::class);
$this->adapter = new EbayAdapter($this->apiClient);
$this->article = new Article(new ArticleType('Notebook'), 'NB-001', 'INV-001', 1, ArticleCondition::Good);
$this->article->setEbayTitle('Dell Latitude 5520');
$this->article->setListingPrice('299.00');
}
public function test_get_type_returns_ebay(): void
{
$this->assertSame('ebay', $this->adapter->getType());
}
public function test_publish_listing_calls_upsert_create_and_publish(): void
{
$this->apiClient->expects($this->once())->method('upsertInventoryItem');
$this->apiClient->expects($this->once())->method('createOffer')->willReturn('offer-123');
$this->apiClient->expects($this->once())->method('publishOffer')->with('offer-123')->willReturn('listing-456');
$listingId = $this->adapter->publishListing($this->article);
$this->assertSame('listing-456', $listingId);
}
public function test_deactivate_listing_withdraws_offer(): void
{
$this->article->setEbayListingId('offer-123');
$this->apiClient->expects($this->once())->method('withdrawOffer')->with('offer-123');
$this->adapter->deactivateListing($this->article);
}
public function test_deactivate_listing_is_noop_when_no_listing_id(): void
{
$this->apiClient->expects($this->never())->method('withdrawOffer');
$this->adapter->deactivateListing($this->article);
}
}