Skip to content

Commit

Permalink
EZP-30008: More unique uniqid() (#2523)
Browse files Browse the repository at this point in the history
  • Loading branch information
glye authored Jan 18, 2019
1 parent ad0a470 commit 776db6a
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public function getThisContentId()
private function createContentType()
{
$name = $this->fieldConstructionObject['fieldType']->identifier;
$name = $name . '#' . uniqid();
$name = uniqid($name . '#', true);
$identifier = strtolower($name);
$contentTypeCreateStruct = $this->contentTypeService->newContentTypeCreateStruct($identifier);
$contentTypeCreateStruct->mainLanguageCode = self::DEFAULT_LANGUAGE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private function createFolder()
'eng-GB'
);

$struct->setField('name', uniqid('Query Controller BDD '));
$struct->setField('name', uniqid('Query Controller BDD ', true));

$contentDraft = $contentService->createContent(
$struct,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ private function findNonExistingUserEmail($username = 'User')
}

for ($i = 0; $i < 20; ++$i) {
$email = 'User#' . uniqid() . '@ez.no';
$email = uniqid('User#', true) . '@ez.no';
if (!$this->checkUserExistenceByEmail($email)) {
return $email;
}
Expand All @@ -582,7 +582,7 @@ private function findNonExistingUserEmail($username = 'User')
private function findNonExistingUserName()
{
for ($i = 0; $i < 20; ++$i) {
$username = 'User#' . uniqid();
$username = uniqid('User#', true);
if (!$this->checkUserExistenceByUsername($username)) {
return $username;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testCatchAll($uri)
{
self::markTestSkipped('@todo fixme');
$response = $this->sendHttpRequest(
$this->createHttpRequest('GET', '/api/ezp/v2/' . uniqid('rest'), '', 'Stuff+json')
$this->createHttpRequest('GET', '/api/ezp/v2/' . uniqid('rest', true), '', 'Stuff+json')
);
self::assertHttpResponseCodeEquals($response, 404);
$responseArray = json_decode($response->getContent(), true);
Expand Down
3 changes: 2 additions & 1 deletion eZ/Bundle/EzPublishRestBundle/Tests/Functional/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ protected function getContentLocations($contentHref)
protected function addTestSuffix($string)
{
if (!isset(self::$testSuffix)) {
self::$testSuffix = uniqid();
/** @noinspection NonSecureUniqidUsageInspection */
self::$testSuffix = uniqid('', true);
}

return $string . '_' . self::$testSuffix;
Expand Down
2 changes: 1 addition & 1 deletion eZ/Publish/API/Repository/Tests/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ public function createUserWithPolicies($login, array $policiesData)
$userCreateStruct->setField('last_name', $login);
$user = $userService->createUser($userCreateStruct, [$userService->loadUserGroup(4)]);

$role = $this->createRoleWithPolicies(uniqid('role_for_' . $login . '_'), $policiesData);
$role = $this->createRoleWithPolicies(uniqid('role_for_' . $login . '_', true), $policiesData);
$roleService->assignRoleToUser($role, $user);

$repository->commit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,8 @@ private function assertContentFieldHasCorrectData($contentId, KeywordValue $valu
public function testKeywordsAreCaseSensitive()
{
$contentType = $this->testCreateContentType();
$publishedContent01 = $this->createAndPublishContent('Foo', $contentType, md5(uniqid() . microtime()));
$publishedContent02 = $this->createAndPublishContent('foo', $contentType, md5(uniqid() . microtime()));
$publishedContent01 = $this->createAndPublishContent('Foo', $contentType, md5(uniqid(__METHOD__, true)));
$publishedContent02 = $this->createAndPublishContent('foo', $contentType, md5(uniqid(__METHOD__, true)));

$data = $publishedContent01->getField('data')->value;
$this->assertCount(1, $data->values);
Expand Down

0 comments on commit 776db6a

Please sign in to comment.