New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
As an adherent, I want to create my committee. #98
Conversation
5d764f9
to
8a8e7a3
Compare
8a8e7a3
to
3d02bf4
Compare
3d02bf4
to
00b5d74
Compare
@@ -28,6 +28,8 @@ common.conditions.not_accepted: Vous devez accepter la charte. | |||
|
|||
common.recaptcha.invalid_message: La réponse au contrôle anti-spamm est incorrecte. | |||
|
|||
common.twitter_nickname.invalid_format: Un identifiant Twitter ne peut contenir que des lettres, des chiffres et des underscores. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On utilise davantage le terme "caractère de soulignement" ou "tiret bas" en français.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L'underscore est un anglicisme aujourd'hui ça me paraît assez courant, après le tiret c'est juste un "tiret" :D
<form method="post" id="create-committee-form" class="form"> | ||
{{ form_errors(form) }} | ||
|
||
<h3>Renseignez les informatins de votre comité local</h3> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
informations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bien vu!
00b5d74
to
6224011
Compare
$this->assertSame(9, $crawler->filter('#create-committee-form .form__errors > li')->count()); | ||
$this->assertSame("Cette valeur n'est pas un identifiant valide de ville française.", $crawler->filter('#create-committee-form > .form__errors > li')->text()); | ||
$this->assertSame('Cette chaine est trop courte. Elle doit avoir au minimum 2 caractères.', $crawler->filter('#field-name > .form__errors > li')->text()); | ||
$this->assertSame('Cette chaine est trop courte. Elle doit avoir au minimum 5 caractères.', $crawler->filter('#field-description > .form__errors > li')->text()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bien qu'il s'agisse ici des tests, il conviendrait de corriger les 2 occurrences de "chaîne". Ou au moins de le noter dans les typos à corriger pour la prochaine fois ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah oui bien vu!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
6ca6b78
to
fcf4579
Compare
|
||
// Activate the user account | ||
$activateAccountUrl = sprintf('/inscription/finaliser/%s/%s', $adherent->getUuid(), $activationToken->getValue()); | ||
$this->client->request(Request::METHOD_GET, $activateAccountUrl); | ||
|
||
$this->assertResponseStatusCode(Response::HTTP_FOUND, $this->client->getResponse()); | ||
$this->assertCount(1, $this->emailRepository->findMessages(AdherentAccountConfirmationMessage::class, 'paul@dupont.tld')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HeahDude @romain-pierre @tgalopin voici la nouvelle bonne manière pour tester qu'un email a été envoyé via Mailjet et donc stocké en BDD.
On pourrait imaginer faire une assertion du genre:
$this->assertEmailWasSent(AdherentAccountConfirmationMessage::class, 'paul@dupont.tld');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go for it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pour une prochaine PR ;)
6a34c8d
to
a349a63
Compare
a349a63
to
8fe3b85
Compare
@@ -41,6 +43,15 @@ adherent.plain_password.min_length: Votre mot de passe doit comporter au moins 8 | |||
adherent.activity_position.invalid_choice: Le statut d'activité n'est pas valide. | |||
|
|||
# | |||
# Committee | |||
# | |||
committee.canonical_name.not_unique: Ce nom de comité est déjà choisi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing dot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep
'attr': { | ||
'class': 'form--full', | ||
'placeholder': 'Nom du comité', | ||
'max-length': '50', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you pass null
instead of an explicit form type class in the type, the value will be guessed from the constraint, that avoid changing values in many places.
$command->setCommittee($this->factory->createFromCommitteeCreationCommand($command)); | ||
|
||
$adherent = $command->getAdherent(); | ||
$committee = $command->getCommittee(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for $adherent
var IMO, and you should initialize $committee
thanks to the return from the factory.
{ | ||
$uuid = isset($data['uuid']) | ||
? Uuid::fromString($data['uuid']) | ||
: Committee::createUuid($data['name']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How sure are we that the name
key will exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a requirement but yes I could throw an exception if it doesn't.
} | ||
|
||
$committee->setSocialNetworks( | ||
!empty($data['facebook_page_url']) ? $data['facebook_page_url'] : null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$data['facebook_page_url'] ?? null
* | ||
* @return CommitteeMembership | ||
*/ | ||
public static function createWithAdherent( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createForAdherent
?
*/ | ||
public static function createWithHostPrivilege( | ||
UuidInterface $committeeUuid, | ||
UuidInterface $adherentUuid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be Committee
and Adherent
as type hints IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't because the method is used in the Committee
class when I don't have access to the Adherent
but only its UUID.
->getQuery() | ||
; | ||
|
||
return (int) $query->getSingleScalarResult() >= 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return (bool) $query->getSingleScalarResult();
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope ! I want to cast the result of getSingleScalarResult()
to int.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What for? You return a bool
anyway...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to compare two numbers together. By default, getSingleScalarResult()
returns a string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah a string sanding for a COUNT
result so casting the call to a bool should work the same:
-return (int) $query->getSingleScalarResult() >= 1;
+return (bool) $query->getSingleScalarResult();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you're right this is because PHP is shit with numbers vs bool vs strings. IMO, from a cognitive perspective, it requires less efforts to compare numbers together rather than casting to a boolean. Also it's safer!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean it's explicit when you read the code!
->getQuery() | ||
; | ||
|
||
return 1 === (int) $query->getSingleScalarResult(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope! Explanations is same as above. The cast applies on the returned value of $query->getSingleScalarResult()
;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you're returning a bool! I don't get it :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well the two comparisons below are not equal:
1 === '1'
vs
1 === 1
The cast enforces the right operand to be a valid integer to compare with the left operand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Back to basics
1 === ( (int) '1' )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but here we just need to know that it's not empty, so as above it should be the same:
-return 1 === (int) $query->getSingleScalarResult();
+return (bool) $query->getSingleScalarResult();
Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the getSingleScalarResult()
method returns '2'
? Your condition is wrong! I strictly want to compare that we have only one row matching. No less no more!
|
||
// Activate the user account | ||
$activateAccountUrl = sprintf('/inscription/finaliser/%s/%s', $adherent->getUuid(), $activationToken->getValue()); | ||
$this->client->request(Request::METHOD_GET, $activateAccountUrl); | ||
|
||
$this->assertResponseStatusCode(Response::HTTP_FOUND, $this->client->getResponse()); | ||
$this->assertCount(1, $this->emailRepository->findMessages(AdherentAccountConfirmationMessage::class, 'paul@dupont.tld')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go for it!
748a88f
to
70123cf
Compare
70123cf
to
8a1ed10
Compare
[ADI] #98 Fix questions numerotation
No description provided.