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 -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -