@@ -101,26 +101,23 @@ public function testUpsert(): void
101
101
}
102
102
public function testUpsertWithSetField (): void
103
103
{
104
- $ this ->client ->mockResponses ->append (new Response ('201 ' ));
104
+ $ this ->client ->mockResponses ->append (new Response ('201 ' ), new Response ( ' 201 ' ) );
105
105
$ endpoint = new Integrate ();
106
106
$ endpoint ->setClient ($ this ->client );
107
107
$ endpoint ->setModule ('Accounts ' );
108
108
$ endpoint ['name ' ] = 'Test Account ' ;
109
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
110
$ endpoint ->upsert ();
111
+ $ request = $ this ->client ->mockResponses ->getLastRequest ();
112
+ $ body = json_decode ($ request ->getBody ()->getContents (), true );
113
+ $ this ->assertArrayNotHasKey ('fields ' , $ body );
119
114
120
- $ payload = $ configurePayload ->invoke ($ endpoint )->toArray ();
121
- $ this ->assertArrayHasKey ('fields ' , $ payload );
122
- $ fields = $ payload ['fields ' ];
123
- $ this ->assertEquals ("foobar_c,account_type " , $ fields );
115
+ $ endpoint ->setFields (['foobar ' , 'bar ' ]);
116
+ $ endpoint ->upsert ();
117
+ $ request = $ this ->client ->mockResponses ->getLastRequest ();
118
+ $ body = json_decode ($ request ->getBody ()->getContents (), true );
119
+ $ this ->assertArrayHasKey ('fields ' , $ body );
120
+ $ this ->assertEquals ("foobar,bar " , $ body ['fields ' ]);
124
121
}
125
122
126
123
/**
0 commit comments