+ {% for initial, speakers in speakers_by_initial %}
+
+ {% else %}
+
Aucun speaker pour le moment.
+ {% endfor %}
+
+{% endblock %}
diff --git a/tests/behat/bootstrap/FeatureContext.php b/tests/behat/bootstrap/FeatureContext.php
index db30917c9..bbae0f62a 100644
--- a/tests/behat/bootstrap/FeatureContext.php
+++ b/tests/behat/bootstrap/FeatureContext.php
@@ -8,6 +8,7 @@
use Behat\Behat\Context\Context;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Gherkin\Node\PyStringNode;
+use Behat\Gherkin\Node\TableNode;
use Behat\Hook\AfterScenario;
use Behat\Hook\BeforeScenario;
use Behat\Mink\Driver\BrowserKitDriver;
@@ -362,4 +363,77 @@ public function openMenu(string $text): void
$node->click();
}
+
+ #[Then('the JSON-LD :type should have the following properties:')]
+ public function assertJsonLdHasProperties(string $type, TableNode $expectedProperties): void
+ {
+ $data = $this->findJsonLd($type);
+
+ if (null === $data) {
+ throw new ExpectationException(sprintf('No JSON-LD of type "%s" found', $type), $this->minkContext->getSession()->getDriver());
+ }
+
+ foreach ($expectedProperties->getRowsHash() as $property => $expectedValue) {
+ $actualValue = $data[$property] ?? null;
+ if (!is_scalar($actualValue) || (string) $actualValue !== $expectedValue) {
+ throw new ExpectationException(
+ sprintf('JSON-LD "%s" property "%s" is %s, "%s" expected', $type, $property, json_encode($actualValue, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), $expectedValue),
+ $this->minkContext->getSession()->getDriver(),
+ );
+ }
+ }
+ }
+
+ #[Then('the JSON-LD :type property :property should match :regex')]
+ public function assertJsonLdPropertyMatches(string $type, string $property, string $regex): void
+ {
+ $actualValue = $this->findJsonLd($type)[$property] ?? null;
+
+ if (!is_string($actualValue) || !preg_match($regex, $actualValue)) {
+ throw new ExpectationException(
+ sprintf('JSON-LD "%s" property "%s" is %s, it does not match "%s"', $type, $property, json_encode($actualValue, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), $regex),
+ $this->minkContext->getSession()->getDriver(),
+ );
+ }
+ }
+
+ #[Then('the response should not contain a JSON-LD :type')]
+ public function assertNoJsonLd(string $type): void
+ {
+ if (null !== $this->findJsonLd($type)) {
+ throw new ExpectationException(sprintf('A JSON-LD of type "%s" was found', $type), $this->minkContext->getSession()->getDriver());
+ }
+ }
+
+ /**
+ * Décode chaque ', 'Doe', [1], new \DateTimeImmutable()),
+ new Speaker(),
+ null,
+ null,
+ [],
+ [new SpeakerTalk(new Speaker(), new Talk(), new Event(), new \DateTimeImmutable())],
+ );
+
+ $json = json_encode(new PersonJsonLd()->getData($profile, 'https://afup.org/talks/speakers/x', null), PersonJsonLd::JSON_FLAGS);
+
+ self::assertIsString($json);
+ self::assertStringNotContainsString('<', $json);
+ self::assertSame(' Doe', json_decode($json, true)['name']);
+ }
+
+ /**
+ * @param array<'twitter'|'mastodon'|'bluesky'|'linkedin'|'github', string> $socialLinks
+ */
+ private static function profile(array $socialLinks): SpeakerProfile
+ {
+ $speaker = new Speaker()->setId(1)->setFirstname('Geoffrey')->setLastname('Bachelet');
+
+ return new SpeakerProfile(
+ new SpeakerIdentity('geoffrey-bachelet', 'Geoffrey', 'Bachelet', [1], new \DateTimeImmutable()),
+ $speaker,
+ null,
+ null,
+ $socialLinks,
+ [new SpeakerTalk($speaker, new Talk()->setId(1), new Event(), new \DateTimeImmutable())],
+ );
+ }
+}
diff --git a/tests/unit/AppBundle/Event/Speaker/SpeakerIdentityTest.php b/tests/unit/AppBundle/Event/Speaker/SpeakerIdentityTest.php
new file mode 100644
index 000000000..1f6cdd639
--- /dev/null
+++ b/tests/unit/AppBundle/Event/Speaker/SpeakerIdentityTest.php
@@ -0,0 +1,30 @@
+getInitial());
+ }
+
+ public static function initials(): \Generator
+ {
+ yield 'initiale du nom en majuscule' => ['Geoffrey', 'bachelet', 'B'];
+ yield 'accent retiré' => ['Élodie', 'Évrard', 'E'];
+ yield 'espaces en tête' => ['Cyrille', ' Grandval', 'G'];
+ yield 'prénom quand le nom est vide' => ['Ödile', '', 'O'];
+ yield 'chiffre' => ['Team', '42', '#'];
+ yield 'nom et prénom vides' => ['', '', '#'];
+ }
+}