Ejemplo n.º 1
0
 public function testExecuteAction()
 {
     $email = new Email();
     $options = ['process_type' => 'demo', 'email' => '$.email', 'attribute' => '$.attribute'];
     $fakeContext = ['fake', 'things', 'are', 'here'];
     $mailboxes = [new Mailbox()];
     $this->contextAccessor->expects($this->at(0))->method('getValue')->with($this->equalTo($fakeContext), $this->equalTo('demo'))->will($this->returnValue('demo'));
     $this->contextAccessor->expects($this->at(1))->method('getValue')->with($this->equalTo($fakeContext), $this->equalTo('$.email'))->will($this->returnValue($email));
     $this->contextAccessor->expects($this->once())->method('setValue')->with($this->equalTo($fakeContext), $this->equalTo('$.attribute'), $this->equalTo($mailboxes));
     $this->repository->expects($this->once())->method('findBySettingsClassAndEmail')->with($this->equalTo('DemoProcessSettings'), $this->equalTo($email))->will($this->returnValue($mailboxes));
     $this->action->initialize($options);
     $this->action->execute($fakeContext);
 }
Ejemplo n.º 2
0
 public function testFilterQueryByUserIdWhenNoMailboxesFound()
 {
     $user = new User();
     $organization = new Organization();
     $em = $this->getTestEntityManager();
     $qb = $em->createQueryBuilder();
     $this->securityFacade->expects($this->once())->method('getLoggedUser')->will($this->returnValue($user));
     $this->securityFacade->expects($this->once())->method('getOrganization')->will($this->returnValue($organization));
     $this->mailboxRepository->expects($this->any())->method('findAvailableMailboxIds')->with($user, $organization)->will($this->returnValue([1, 3, 5]));
     $qb->select('eu')->from('EmailUser', 'eu');
     $this->factory->applyAcl($qb, 1);
     $this->assertEquals("SELECT eu FROM EmailUser eu" . " WHERE (eu.owner = :owner AND eu.organization  = :organization) OR eu.mailboxOwner IN(:mailboxIds)", $qb->getQuery()->getDQL());
 }