/**
  * tests controller's userAction with two users in db
  */
 public function testUserActionWithUsers()
 {
     $this->loadMongoContainer();
     $user1 = new User();
     $user1->setEmail('email1');
     $user1->setId('id1');
     $user1->setRoles('ROLE_ADMIN');
     $user1->setLicenseeId('lic1');
     $user2 = new User();
     $user2->setEmail('email2');
     $user2->setId('id2');
     $user2->setRoles('ROLE_USER');
     $user2->setLicenseeId('lic2');
     $userArray = array($user1, $user2);
     $this->repository->expects($this->once())->method("findAll")->will($this->returnValue($userArray));
     $controller = new DefaultController();
     $controller->setContainer($this->container);
     /* @var $response \Symfony\Component\HttpFoundation\Response */
     $response = $controller->usersAction();
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $response);
     $this->assertJsonStringEqualsJsonString('[{"id":"id1","email":"email1","roles":"ROLE_ADMIN","licenseeId":"lic1"},{"id":"id2","email":"email2","roles":"ROLE_USER","licenseeId":"lic2"}]', $response->getContent());
     $this->assertEquals('200', $response->getStatusCode());
 }
Ejemplo n.º 2
0
 /**
  * tests setLicenseeId()
  */
 public function testGetLicenseeIdShouldBeEqualSetLicenseeId()
 {
     $this->user->setLicenseeId('test');
     $this->assertEquals('test', $this->user->getLicenseeId());
 }