@@ -842,6 +842,47 @@ public function testBatchDncAddAndRemove(): void
842842 $ this ->assertSame (Response::HTTP_OK , $ clientResponse ->getStatusCode ());
843843 }
844844
845+ public function testBatchEditEndpointSameContact (): void
846+ {
847+ $ contact1 = new Lead ();
848+ $ contact1 ->setEmail ('batcheditcontact1@gmail.com ' );
849+ $ this ->em ->persist ($ contact1 );
850+
851+ $ contact2 = new Lead ();
852+ $ contact2 ->setEmail ('batcheditcontact2@gmail.com ' );
853+ $ this ->em ->persist ($ contact2 );
854+
855+ $ this ->em ->flush ();
856+ $ this ->em ->clear ();
857+
858+ $ payload = [
859+ ['points ' => 1 , 'id ' => $ contact1 ->getId ()],
860+ ['points ' => 1 , 'id ' => $ contact2 ->getId ()],
861+ ['points ' => 2 , 'id ' => $ contact1 ->getId ()],
862+ ];
863+
864+ $ this ->client ->request (Request::METHOD_PATCH , '/api/contacts/batch/edit ' , $ payload );
865+ $ clientResponse = $ this ->client ->getResponse ();
866+
867+ self ::assertResponseIsSuccessful ($ clientResponse ->getContent ());
868+
869+ $ response = json_decode ($ clientResponse ->getContent (), true );
870+
871+ self ::assertCount (3 , $ response ['contacts ' ]);
872+
873+ $ this ->assertEquals (Response::HTTP_OK , $ response ['statusCodes ' ][0 ]);
874+ $ this ->assertSame ($ contact1 ->getId (), $ response ['contacts ' ][0 ]['id ' ]);
875+ $ this ->assertSame (2 , $ response ['contacts ' ][0 ]['points ' ]);
876+
877+ $ this ->assertEquals (Response::HTTP_OK , $ response ['statusCodes ' ][1 ]);
878+ $ this ->assertSame ($ contact2 ->getId (), $ response ['contacts ' ][1 ]['id ' ]);
879+ $ this ->assertSame (1 , $ response ['contacts ' ][1 ]['points ' ]);
880+
881+ $ this ->assertEquals (Response::HTTP_OK , $ response ['statusCodes ' ][2 ]);
882+ $ this ->assertSame ($ contact1 ->getId (), $ response ['contacts ' ][2 ]['id ' ]);
883+ $ this ->assertSame (2 , $ response ['contacts ' ][2 ]['points ' ]);
884+ }
885+
845886 public function testAddAndRemoveDncToExistingContact (): void
846887 {
847888 // Create contact
0 commit comments