php - How Do I Test a Very Simple Event Handler Without Coupling to Implementation? -


so have question practice when comes (unit) testing event handlers.

my situation involves domain object should mutated , persisted in handler of set of events. logic simple , goes this:

function handle(domainevent $event) {     $entitya = $this->entityarepository->getbyid($event->getentityaid());     $entitybid = $entitya->getentitybid();     $entityb = $this->entitybrepository->getbyid($entitybid);      if ($entityb->getstatus() == entitybstatus::some_status) {         $entitya->commandmethod($entitybid);      }     $this->entityarepository->save($entitya); } 

the main point important behavior of handler calls command method , persists resultant state. how test without coupling test heavily implementation, or necessary evil?


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -