public function testCreateUser() { $notificator = $this->getMock(NotificatorInterface::class); $notificator->expects($this->once())->method('publishNotification'); $validator = $this->getMock(ValidatorInterface::class); $validator->expects($this->once())->method('validate')->willReturn(new ConstraintViolationList()); $hasher = new PhpPasswordHasher(); $generator = new ActivationKeyCodeGenerator(); $repository = $this->getMock(UserWriteRepositoryInterface::class); $repository->expects($this->once())->method('save'); $handler = new CreateUserHandler($repository, $hasher, $generator, $validator); $dto = new CreateUserDTO(); $handler->setNotificator($notificator); $dto->username = '******'; $dto->password = '******'; $dto->email = '*****@*****.**'; $dto->locale = 'de'; $this->assertNull($dto->user); $handler($dto); $this->assertNotNull($dto->user); $user = $dto->user; $this->assertSame($user->getUsername(), 'Ma27'); $this->assertTrue($hasher->compareWith($user->getPassword(), '123456')); $this->assertSame($user->getEmail(), '*****@*****.**'); $this->assertSame($user->getLocale(), 'de'); $this->assertCount(0, $user->getRoles()); }