-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EZP-28902: Creating a user with existing username results in Internal…
… Server Error. (#2279)
- Loading branch information
1 parent
87a68d8
commit d987eea
Showing
4 changed files
with
124 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,9 +8,11 @@ | |
*/ | ||
namespace eZ\Publish\Core\FieldType\Tests; | ||
|
||
use eZ\Publish\Core\Persistence\Cache\UserHandler; | ||
use eZ\Publish\Core\FieldType\User\Type as UserType; | ||
use eZ\Publish\Core\FieldType\User\Value as UserValue; | ||
use eZ\Publish\Core\Base\Exceptions\InvalidArgumentException; | ||
use eZ\Publish\Core\FieldType\ValidationError; | ||
|
||
/** | ||
* @group fieldType | ||
|
@@ -31,7 +33,8 @@ class UserTest extends FieldTypeTest | |
*/ | ||
protected function createFieldTypeUnderTest() | ||
{ | ||
$fieldType = new UserType(); | ||
$userHandler = $this->createMock(UserHandler::class); | ||
$fieldType = new UserType($userHandler); | ||
$fieldType->setTransformationProcessor($this->getTransformationProcessorMock()); | ||
|
||
return $fieldType; | ||
|
@@ -295,6 +298,67 @@ public function provideInputForFromHash() | |
); | ||
} | ||
|
||
/** | ||
* Provides data sets with validator configuration and/or field settings and | ||
* field value which are considered valid by the {@link validate()} method. | ||
* | ||
* @return array | ||
*/ | ||
public function provideValidDataForValidate() | ||
{ | ||
return [ | ||
[ | ||
[], | ||
new UserValue([ | ||
'hasStoredLogin' => true, | ||
'contentId' => 23, | ||
'login' => 'sindelfingen', | ||
'email' => '[email protected]', | ||
'passwordHash' => '1234567890abcdef', | ||
'passwordHashType' => 'md5', | ||
'enabled' => true, | ||
'maxLogin' => 1000, | ||
]), | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* Provides data sets with validator configuration and/or field settings, | ||
* field value and corresponding validation errors returned by | ||
* the {@link validate()} method. | ||
* | ||
* @return array | ||
*/ | ||
public function provideInvalidDataForValidate() | ||
{ | ||
return [ | ||
[ | ||
[], | ||
new UserValue([ | ||
'hasStoredLogin' => false, | ||
'contentId' => 23, | ||
'login' => 'sindelfingen', | ||
'email' => '[email protected]', | ||
'passwordHash' => '1234567890abcdef', | ||
'passwordHashType' => 'md5', | ||
'enabled' => true, | ||
'maxLogin' => 1000, | ||
]), | ||
[ | ||
new ValidationError( | ||
"The user login '%login%' is used by another user. You must enter a unique login.", | ||
null, | ||
[ | ||
'%login%' => 'sindelfingen', | ||
], | ||
'username' | ||
), | ||
], | ||
], | ||
]; | ||
} | ||
|
||
protected function provideFieldTypeIdentifier() | ||
{ | ||
return 'ezuser'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters