Пример #1
0
 /**
  * tests serialize()
  */
 public function testSerialize()
 {
     $this->user->setId('id');
     $this->user->setEmail('email');
     $this->user->setPassword('pw');
     $this->user->setCurrentTextnode('55cd2a9808985ca80c3c9877');
     $this->assertEquals(serialize(array('id', 'email', 'pw', '55cd2a9808985ca80c3c9877')), $this->user->serialize());
 }
 /**
  * tests the formdelAction with an existing user
  */
 public function testFormdelActionExistingUser()
 {
     $user = new User();
     $user->setId('someId');
     $user->setEmail('*****@*****.**');
     $user->setRoles('ROLE_USER');
     $this->loadMongoContainer();
     $request = $this->getMockBuilder("Symfony\\Component\\HttpFoundation\\Request")->disableOriginalConstructor()->getMock();
     $postMock = $this->getMockBuilder("Symfony\\Component\\HttpFoundation\\ParameterBag")->disableOriginalConstructor()->getMock();
     $postArray = array('formtype' => 'user', 'id' => $user->getId());
     $postMock->expects($this->once())->method("all")->will($this->returnValue($postArray));
     $request->request = $postMock;
     $this->repository->expects($this->once())->method('find')->with($user->getId())->will($this->returnValue($user));
     $dm = $this->getMockBuilder('Doctrine\\ODM\\MongoDB\\DocumentManager')->disableOriginalConstructor()->getMock();
     $this->service->expects($this->once())->method('getManager')->will($this->returnValue($dm));
     $dm->expects($this->once())->method('remove')->with($user);
     $dm->expects($this->once())->method('flush');
     $controller = new DefaultController();
     $controller->setContainer($this->container);
     /* @var $response \Symfony\Component\HttpFoundation\Response */
     $response = $controller->formdelAction($request);
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $response);
     $json = $response->getContent();
     $this->assertJson($json);
     $json = json_decode($json);
     $this->assertFalse($json->error);
 }