frappe = $this->createMock(FrappeHttpClient::class); $this->adapter = new FrappeErpAdapter($this->frappe, 'REFURB-HW'); } public function test_create_customer_returns_frappe_id(): void { $this->frappe ->method('post') ->with('/api/resource/Customer', $this->isType('array')) ->willReturn(['data' => ['name' => 'CUST-00001']]); $customer = new Customer('Max Mustermann', 'max@test.de', ['street' => 'Str 1', 'city' => 'Berlin', 'zip' => '10115']); $customer->addPlatformId('ebay', 'buyer123'); $result = $this->adapter->createCustomer($customer); $this->assertSame('CUST-00001', $result); } public function test_create_sales_invoice_submits_and_returns_id(): void { $this->frappe ->expects($this->exactly(2)) ->method('post') ->willReturnOnConsecutiveCalls( ['data' => ['name' => 'SINV-00001']], ['data' => ['name' => 'SINV-00001', 'docstatus' => 1]], ); $customer = new Customer('Max Mustermann', 'max@test.de', ['street' => 'Str 1', 'city' => 'Berlin', 'zip' => '10115']); $customer->setFrappeCustomerId('CUST-00001'); $order = new Order( new Article(new ArticleType('Laptop'), 'LAP-001', 'INV-001', 1, ArticleCondition::Good), $customer, new Platform('ebay', 'eBay DE'), 'ORDER-001', '299.99', new \DateTimeImmutable('2026-05-13'), ); $result = $this->adapter->createSalesInvoice($order); $this->assertSame('SINV-00001', $result); } public function test_fetch_invoice_pdf_returns_binary(): void { $this->frappe ->method('getContent') ->with($this->stringContains('SINV-00001')) ->willReturn('%PDF-binary-content'); $result = $this->adapter->fetchInvoicePdf('SINV-00001'); $this->assertStringStartsWith('%PDF', $result); } }