Skip to content

Commit a58d635

Browse files
committed
Add test for upsert with set fields in IntegrateTest
1 parent a489ecb commit a58d635

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/Endpoint/IntegrateTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,29 @@ public function testUpsert(): void
9999
$this->assertEquals('test', $endpoint->foobar_c);
100100
$this->assertEquals('Prospect', $endpoint['account_type']);
101101
}
102+
public function testUpsertWithSetField(): void
103+
{
104+
$this->client->mockResponses->append(new Response('201'));
105+
$endpoint = new Integrate();
106+
$endpoint->setClient($this->client);
107+
$endpoint->setModule('Accounts');
108+
$endpoint['name'] = 'Test Account';
109+
$endpoint['sync_key'] = 'test';
110+
$Reflection = new \ReflectionClass($endpoint::class);
111+
$configurePayload = $Reflection->getMethod('configurePayload');
112+
$configurePayload->setAccessible(true);
113+
$payload = $configurePayload->invoke($endpoint)->toArray();
114+
$this->assertArrayNotHasKey('fields', $payload);
115+
116+
$this->client->mockResponses->append(new Response('201'));
117+
$endpoint->setFields(['foobar_c', 'account_type']);
118+
$endpoint->upsert();
119+
120+
$payload = $configurePayload->invoke($endpoint)->toArray();
121+
$this->assertArrayHasKey('fields', $payload);
122+
$fields = $payload['fields'];
123+
$this->assertEquals("foobar_c,account_type", $fields);
124+
}
102125

103126
/**
104127
* @covers ::getSyncKey

0 commit comments

Comments
 (0)