@@ -101,26 +101,23 @@ public function testUpsert(): void
101101 }
102102 public function testUpsertWithSetField (): void
103103 {
104- $ this ->client ->mockResponses ->append (new Response ('201 ' ));
104+ $ this ->client ->mockResponses ->append (new Response ('201 ' ), new Response ( ' 201 ' ) );
105105 $ endpoint = new Integrate ();
106106 $ endpoint ->setClient ($ this ->client );
107107 $ endpoint ->setModule ('Accounts ' );
108108 $ endpoint ['name ' ] = 'Test Account ' ;
109109 $ 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 ' ]);
118110 $ endpoint ->upsert ();
111+ $ request = $ this ->client ->mockResponses ->getLastRequest ();
112+ $ body = json_decode ($ request ->getBody ()->getContents (), true );
113+ $ this ->assertArrayNotHasKey ('fields ' , $ body );
119114
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 ' ]);
124121 }
125122
126123 /**
0 commit comments