children->add($child); $child->parents->add($parent); $em = $this->_getTestEntityManager(); $em->persist($parent); $em->flush(); /** @var ChildClass|null $childReloaded */ $childReloaded = $em->find(ChildClass::class, ['id1' => 1, 'otherParent' => $otherParent]); self::assertNotNull($childReloaded); $persister = new ManyToManyPersister($em); $persister->delete($childReloaded->parents); /** @var ConnectionMock $conn */ $conn = $em->getConnection(); $updates = $conn->getExecuteUpdates(); $lastUpdate = array_pop($updates); self::assertEquals('DELETE FROM parent_child WHERE child_id1 = ? AND child_id2 = ?', $lastUpdate['query']); self::assertEquals([1, 42], $lastUpdate['params']); } }