Commit f2c09009 authored by Emma's avatar Emma 🦉

Merge branch 'buncha-shit' into 'master'

Buncha shit

See merge request edgyemma/Postmill!49
parents eded51c4 26acd83e
Pipeline #22693593 passed with stage
in 4 minutes and 47 seconds
This diff is collapsed.
......@@ -22,4 +22,5 @@ return [
Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['dev' => true],
Gregwar\CaptchaBundle\GregwarCaptchaBundle::class => ['all' => true],
EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle::class => ['all' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
];
......@@ -48,7 +48,11 @@ final class CommentType extends AbstractType {
$this->addUserFlagOption($builder, $options['forum']);
$builder->add('submit', SubmitType::class);
$editing = $builder->getData() && $builder->getData()->getEntityId();
$builder->add('submit', SubmitType::class, [
'label' => $editing ? 'action.save' : 'action.post',
]);
}
/**
......
......@@ -22,13 +22,19 @@ final class PasswordEncodingSubscriber implements EventSubscriberInterface {
}
public function onPostSubmit(FormEvent $event) {
if ($event->getForm()->getErrors()->count() > 0) {
if (!$event->getForm()->isValid()) {
return;
}
/** @var UserData $user */
/* @var UserData $user */
$user = $event->getForm()->getData();
if (!$user instanceof UserData) {
throw new \UnexpectedValueException(
'Form data must be instance of '.UserData::class
);
}
if ($user->getPlainPassword() !== null) {
$encoded = $this->encoder->encodePassword($user, $user->getPlainPassword());
$user->setPassword($encoded);
......
......@@ -13,6 +13,11 @@ use Symfony\Component\Validator\Constraints as Assert;
* @NotForumBanned(forumPath="submission.forum", errorPath="body")
*/
class CommentData {
/**
* @var int|null
*/
private $entityId;
/**
* @var Submission
*/
......@@ -34,6 +39,7 @@ class CommentData {
public static function createFromComment(Comment $comment): self {
$self = new self($comment->getSubmission());
$self->entityId = $comment->getId();
$self->submission = $comment->getSubmission();
$self->body = $comment->getBody();
$self->userFlag = $comment->getUserFlag();
......@@ -69,6 +75,10 @@ class CommentData {
}
}
public function getEntityId(): ?int {
return $this->entityId;
}
public function getBody(): ?string {
return $this->body;
}
......
......@@ -164,6 +164,9 @@
"monolog/monolog": {
"version": "1.23.0"
},
"nikic/php-parser": {
"version": "v4.0.1"
},
"ocramius/proxy-manager": {
"version": "2.1.1"
},
......@@ -329,6 +332,15 @@
"symfony/intl": {
"version": "v4.0.3"
},
"symfony/maker-bundle": {
"version": "1.0",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "1.0",
"ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f"
}
},
"symfony/monolog-bridge": {
"version": "v4.0.3"
},
......@@ -356,6 +368,9 @@
"ref": "179470cb6492db92dffee208cfdb436f175c93b4"
}
},
"symfony/polyfill-ctype": {
"version": "v1.8.0"
},
"symfony/polyfill-intl-grapheme": {
"version": "v1.6.0"
},
......
......@@ -8,6 +8,27 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @covers \App\Controller\UserController
*/
class UserControllerTest extends WebTestCase {
public function testCannotSignUpWithPasswordLongerThan72Characters() {
$client = $this->createClient();
$crawler = $client->request('GET', '/registration');
$password = str_repeat('a', 73);
$form = $crawler->selectButton('user[submit]')->form([
'user[username]' => 'random4',
'user[password][first]' => $password,
'user[password][second]' => $password,
'user[verification]' => 'bypass',
]);
$crawler = $client->submit($form);
$this->assertContains(
'This value is too long. It should have 72 characters or less.',
$crawler->filter('.form__error')->text()
);
}
public function testCanReceiveSubmissionNotifications() {
$client = $this->createEmmaClient();
$crawler = $client->request('GET', '/f/cats/3');
......
......@@ -53,7 +53,6 @@ comments:
comment_form:
comment: Kommentar
submit: Einreichen
edit_title: Kommentar bearbeiten
create_title: Kommentar einreichen
......
......@@ -69,7 +69,6 @@ comments:
comment_form:
comment: Σχόλιο
submit: Στειλε το
edit_title: Διόρθωση σχολίου
create_title: Γράφω σχόλιο
......
......@@ -26,6 +26,7 @@ action:
create: Create
compare: Compare
add: Add
post: Post
save: Save
add_moderator:
......@@ -76,7 +77,6 @@ comments:
comment_form:
comment: Comment
submit: Submit
edit_title: Editing comment
create_title: Posting a comment
......
......@@ -54,7 +54,6 @@ comments:
comment_form:
comment: Komento
submit: Afiŝi
edit_title: Redaktas komenton
create_title: Skribas komenton
......
......@@ -74,7 +74,6 @@ comments:
comment_form:
comment: Comentar
submit: Publicar
edit_title: Editando comentario
create_title: Publicando un comentario
......
......@@ -54,7 +54,6 @@ comments:
comment_form:
comment: Kommentoi
submit: Lisää
edit_title: Muokataan kommenttia
create_title: Lisätään kommentti
......
......@@ -65,7 +65,6 @@ comments:
comment_form:
comment: Commentaire
submit: Envoyer
edit_title: Modifier commentaire
create_title: Publier un commentaire
......
......@@ -53,7 +53,6 @@ comments:
comment_form:
comment: Kommentar
submit: Send
edit_title: Redigerer en kommentar
create_title: Poster en kommentar
......
......@@ -67,7 +67,6 @@ comments:
comment_form:
comment: Comentar
submit: Enviar
edit_title: Alterando comentário
create_title: Enviando comentário
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment