decrease minimum username length to 3 character (#362)

This commit is contained in:
Kevin Papst
2018-10-19 16:50:03 +02:00
committed by GitHub
parent ad171e7706
commit b46e752d0a
5 changed files with 17 additions and 16 deletions

View File

@@ -14,8 +14,6 @@ use App\Entity\User;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\Validator\ConstraintViolationListInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
/**
* @coversDefaultClass \App\Command\CreateUserCommand
@@ -36,15 +34,10 @@ class CreateUserCommandTest extends KernelTestCase
$passwordEncoder = $container->get('security.password_encoder');
$validationResult = $this->getMockBuilder(ConstraintViolationListInterface::class)->getMock();
$validationResult->method('count')->willReturn(0);
$validator = $this->getMockBuilder(ValidatorInterface::class)->getMock();
$validator->method('validate')->willReturn($validationResult);
$this->application->add(new CreateUserCommand(
$passwordEncoder,
$container->get('doctrine'),
$validator
$container->get('validator')
));
}
@@ -75,6 +68,14 @@ class CreateUserCommandTest extends KernelTestCase
return $commandTester;
}
public function testUserWithValidationProblem()
{
$commandTester = $this->createUser('xx', '', 'ROLE_USER', '');
$output = $commandTester->getDisplay();
$this->assertContains('[ERROR] plainPassword ()', $output);
// TODO the test validator is misconfigured, doesn't find "short username" and "empty email"
}
public function testUserAlreadyExisting()
{
$this->createUser('MyTestUser', 'user@example.com', 'ROLE_USER', 'foobar');