/** * @test */ public function testGetGravatarForUser() { $details = $this->createDummyUserDetails(); $this->userService->expects($this->once())->method('getGravatarLink')->with($this->equalTo('*****@*****.**'), $this->equalTo(58))->will($this->returnValue(sprintf('http://gravatar.com/avatar/%s.jpg?s=58&d=identicon', $this->getHash($details->getEmail())))); $link = $this->userDetailsExtension->getGravatarForUser($details->getEmail()); $this->assertEquals(sprintf('http://gravatar.com/avatar/%s.jpg?s=58&d=identicon', $this->getHash($details->getEmail())), $link); }
public function load(ObjectManager $manager) { for ($i = 1; $i <= 10; $i++) { $email = sprintf("*****@*****.**", $i); $user = new DiamanteUser($email, 'Test', 'User'); $apiUser = new ApiUser($email, UserServiceImpl::generateRandomSequence(20), UserServiceImpl::generateRandomSequence(20)); $apiUser->activate($apiUser->getHash()); $user->setApiUser($apiUser); $user->setDeleted(false); $manager->persist($user); } $manager->flush(); }
/** * @test */ public function testSearchWithNotEmptyQuery() { $query = 'Name'; $expectedDiamanteUsers = 1; $expectedOroUsers = 3; $totalExpectedResult = $expectedDiamanteUsers + $expectedOroUsers; $this->userService->expects($this->once())->method('getGravatarLink')->with($this->equalTo('*****@*****.**', DiamanteUserSearchHandler::AVATAR_SIZE)); $this->diamanteUserRepository->expects($this->once())->method('searchByInput')->with($this->equalTo($query), $this->equalTo($this->getProperties()))->will($this->returnValue($this->getDiamanteUsersCollection($expectedDiamanteUsers, $query))); $this->userSearchHandler->expects($this->once())->method('search')->with($this->equalTo($query), 1, 10)->will($this->returnValue(array('results' => $this->getOroUsersCollection($expectedOroUsers, $query), 'more' => false))); $result = $this->diamanteUserSearchHandler->search($query, 1, 10); $this->assertInternalType('array', $result); $this->assertTrue(array_key_exists('results', $result)); $this->assertEquals($totalExpectedResult, count($result['results'])); foreach ($result['results'] as $item) { $this->assertStringEndsWith($query, $item['firstName']); } }
/** * Updates Diamante User * * @ApiDoc( * description="Updates Diamante User", * uri="/users/{id}.{_format}", * method={ * "PUT", * "PATCH" * }, * resource=true, * requirements={ * { * "name"="id", * "dataType"="integer", * "requirement"="\d+", * "description"="Diamante User ID" * } * }, * statusCodes={ * 200="Returned when successful", * 403="Returned when user is not authorized to update resource", * 404="Returned when user not found" * } * ) * * @param UpdateDiamanteUserCommand $command * @return \Diamante\DeskBundle\Model\Shared\Entity */ public function updateDiamanteUser(UpdateDiamanteUserCommand $command) { $id = parent::updateDiamanteUser($command); return $this->diamanteUserRepository->get($id); }