コード例 #1
0
ファイル: AuditServiceTest.php プロジェクト: nidzix/Newscoop
 public function testFindBy()
 {
     $result = array(1, 2, 4);
     $criteria = array('resource' => 'article');
     $orderBy = array('created');
     $limit = 5;
     $offset = 1;
     $this->repository->expects($this->once())->method('findBy')->with($this->equalTo($criteria), $this->equalTo($orderBy), $this->equalTo($limit), $this->equalTo($offset))->will($this->returnValue($result));
     $this->em->expects($this->once())->method('getRepository')->with($this->equalTo('Newscoop\\Entity\\AuditEvent'))->will($this->returnValue($this->repository));
     $this->assertEquals($result, $this->service->findBy($criteria, $orderBy, $limit, $offset));
 }
コード例 #2
0
ファイル: AuditTest.php プロジェクト: nidzix/Newscoop
 public function testSaveEntity()
 {
     $user = new User('email');
     $this->em->persist($user);
     $audit = new AuditEvent();
     $this->repository->save($audit, array('resource_type' => 'test-type', 'resource_id' => array('id' => 123), 'resource_title' => 'test-title', 'resource_diff' => array('name' => array('tic', 'toc')), 'action' => 'test-action', 'user' => $user));
     $this->em->flush();
     $audits = $this->repository->findAll();
     $this->assertEquals(1, sizeof($audits));
     $this->assertEquals($audit, $audits[0]);
     $this->assertEquals(1, $audit->getId());
     $this->assertEquals('test-type', $audit->getResourceType());
     $this->assertEquals(array('id' => 123), $audit->getResourceId());
     $this->assertEquals('test-title', $audit->getResourceTitle());
     $this->assertEquals(array('name' => array('tic', 'toc')), $audit->getResourceDiff());
     $this->assertEquals('test-action', $audit->getAction());
     $this->assertEquals($user, $audit->getUser());
     $now = new \DateTime();
     $this->assertLessThanOrEqual(1, $now->diff($audit->getCreated())->s);
 }