markTestSkipped('FRAPPE_ERP_* env vars not set'); } $this->client = new FrappeHttpClient( HttpClient::create(), (string) $baseUrl, (string) $apiKey, (string) $apiSecret, ); } protected function tearDown(): void { if ('' !== $this->createdCustomerName) { try { $this->client->delete('/api/resource/Customer/'.$this->createdCustomerName); } catch (\Throwable) { // best-effort cleanup } } } public function testCreateCustomer(): void { $response = $this->client->post('/api/resource/Customer', [ 'customer_name' => 'Test Superseller Integration', 'customer_type' => 'Individual', 'customer_group' => 'Individual', 'territory' => 'Germany', ]); $this->assertArrayHasKey('data', $response); $this->assertNotEmpty($response['data']['name']); $this->createdCustomerName = $response['data']['name']; } public function testFindCreatedCustomer(): void { // Create first $created = $this->client->post('/api/resource/Customer', [ 'customer_name' => 'Test Superseller Integration', 'customer_type' => 'Individual', 'customer_group' => 'Individual', 'territory' => 'Germany', ]); $this->createdCustomerName = $created['data']['name']; // Find by name $response = $this->client->get('/api/resource/Customer/'.$this->createdCustomerName); $this->assertSame($this->createdCustomerName, $response['data']['name']); $this->assertSame('Test Superseller Integration', $response['data']['customer_name']); } public function testFindNonexistentCustomerThrows(): void { $this->expectException(ClientExceptionInterface::class); $this->client->get('/api/resource/Customer/CUST-DOES-NOT-EXIST-99999'); } public function testDeleteCustomer(): void { // Create $created = $this->client->post('/api/resource/Customer', [ 'customer_name' => 'Test Superseller Integration', 'customer_type' => 'Individual', 'customer_group' => 'Individual', 'territory' => 'Germany', ]); $name = $created['data']['name']; // Delete $this->client->delete('/api/resource/Customer/'.$name); // Confirm gone $this->expectException(ClientExceptionInterface::class); $this->client->get('/api/resource/Customer/'.$name); } }