diff --git a/fixtures/attendees.yaml b/fixtures/attendees.yaml
index 676d520..8b4f922 100644
--- a/fixtures/attendees.yaml
+++ b/fixtures/attendees.yaml
@@ -1,11 +1,11 @@
App\Entity\Attendee:
attendee_1:
- __construct: [ '02d47053-4034-4818-97d1-299c4cd7168d', 'Ferdinand', 'Hale', 'ferdinand@hale.com' ]
+ __construct: [ '02d47053-4034-4818-97d1-299c4cd7168d', 'Ferdinand', 'Hale', 'Ferdinand Hale', 'ferdinand@hale.com' ]
attendee_2:
- __construct: [ '6047c255-593f-4fa8-888b-f919fafd904f', 'Abraham', 'Noel', 'abraham@noel.com' ]
+ __construct: [ '6047c255-593f-4fa8-888b-f919fafd904f', 'Abraham', 'Noel', 'Abraham Noel', 'abraham@noel.com' ]
attendee_3:
- __construct: [ '92e06a4b-19ac-4e67-b988-00e7250929c6', 'Bertha', 'Tucker', 'bertha@tucker.com' ]
+ __construct: [ '92e06a4b-19ac-4e67-b988-00e7250929c6', 'Bertha', 'Tucker', 'Bertha Tucker', 'bertha@tucker.com' ]
attendee_4:
- __construct: [ 'c153c6c3-c43b-449d-8f5a-2bfb627f9822', 'Melodie', 'Perkins', 'melodie@perkins.com' ]
+ __construct: [ 'c153c6c3-c43b-449d-8f5a-2bfb627f9822', 'Melodie', 'Perkins', 'Melodie Perkins', 'melodie@perkins.com' ]
attendee_5:
- __construct: [ 'f5e2c329-f5b8-4e4b-860d-b5a0189ef35f', 'Keegan', 'Mcpherson', 'keegan@mcpherson.com' ]
+ __construct: [ 'f5e2c329-f5b8-4e4b-860d-b5a0189ef35f', 'Keegan', 'Mcpherson', 'Keegan Mcpherson', 'keegan@mcpherson.com' ]
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 58120ff..277669b 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -17,6 +17,7 @@
+
diff --git a/src/Controller/Attendee/UpdateController.php b/src/Controller/Attendee/UpdateController.php
index 856ef57..04df757 100644
--- a/src/Controller/Attendee/UpdateController.php
+++ b/src/Controller/Attendee/UpdateController.php
@@ -15,7 +15,11 @@
#[IsGranted('ROLE_USER')]
#[Route('/attendees/{identifier}', name: 'update_attendee', methods: ['PUT'])]
-#[OA\Put(tags: ['Attendee'])]
+#[OA\Put(
+ description: 'This endpoint is deprecated, please don\'t rely on it anymore.',
+ tags: ['Attendee'],
+ deprecated: true
+)]
final class UpdateController
{
public function __construct(
@@ -27,6 +31,8 @@ public function __invoke(Request $request, Attendee $attendee, UpdateAttendeeMod
{
$this->attendeeUpdater->update($attendee, $updateAttendeeModel);
- return new Response(null, Response::HTTP_NO_CONTENT);
+ return new Response(null, Response::HTTP_NO_CONTENT, [
+ 'Sunset' => (new \DateTime())->modify('+ 1 year')->format(DATE_RFC7231), // HTTP Date by RFC 7231
+ ]);
}
}
diff --git a/src/Domain/AttendeeCreator.php b/src/Domain/AttendeeCreator.php
index bb4eda4..c8e8482 100644
--- a/src/Domain/AttendeeCreator.php
+++ b/src/Domain/AttendeeCreator.php
@@ -20,8 +20,9 @@ public function create(CreateAttendeeModel $createAttendeeModel): Attendee
{
$newAttendee = new Attendee(
Uuid::uuid4()->toString(),
- $createAttendeeModel->firstname,
- $createAttendeeModel->lastname,
+ $createAttendeeModel->firstname ?? '',
+ $createAttendeeModel->lastname ?? '',
+ $createAttendeeModel->name ?? '',
$createAttendeeModel->email,
);
diff --git a/src/Domain/Model/CreateAttendeeModel.php b/src/Domain/Model/CreateAttendeeModel.php
index 691675c..e6cbd55 100644
--- a/src/Domain/Model/CreateAttendeeModel.php
+++ b/src/Domain/Model/CreateAttendeeModel.php
@@ -4,18 +4,45 @@
namespace App\Domain\Model;
+use OpenApi\Attributes as OA;
+use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\NotBlank;
+use Symfony\Component\Validator\Context\ExecutionContextInterface;
final class CreateAttendeeModel
{
- #[NotBlank]
+ // be aware that deprecating properties means you still need to support both ways of creating attendees
+ // and that you need to move validation into your domain layer
+
+ #[OA\Property(
+ deprecated: true,
+ description: 'Property firstname is deprecated, use property name instead.'
+ )]
+ #[NotBlank(allowNull: true)]
public string $firstname;
- #[NotBlank]
+ #[OA\Property(
+ deprecated: true,
+ description: 'Property lastname is deprecated, use property name instead.'
+ )]
+ #[NotBlank(allowNull: true)]
public string $lastname;
+ #[NotBlank(allowNull: true)]
+ public string $name;
+
#[NotBlank]
#[Email]
public string $email;
+
+ #[Callback]
+ public function validate(ExecutionContextInterface $context, $payload)
+ {
+ if ((empty($this->firstname) || empty($this->lastname)) && empty($this->name)) {
+ $context->buildViolation('Passing values for fields "$firstname" and "$lastname" is deprecated. Pass a value for field "$name" instead.')
+ ->atPath('firstname')
+ ->addViolation();
+ }
+ }
}
diff --git a/src/Entity/Attendee.php b/src/Entity/Attendee.php
index 4aba52c..97fd3a3 100644
--- a/src/Entity/Attendee.php
+++ b/src/Entity/Attendee.php
@@ -31,20 +31,35 @@ class Attendee
#[ORM\Column(type: 'string', length: 255)]
private string $lastname;
+ #[ORM\Column(type: 'string', length: 255)]
+ private string $name;
+
#[ORM\Column(type: 'string', length: 255)]
private string $email;
#[ORM\ManyToMany(targetEntity: Workshop::class, inversedBy: 'attendees')]
private Collection $workshops;
- public function __construct(string $identifier, string $firstname, string $lastname, string $email)
+ public function __construct(string $identifier, string $firstname, string $lastname, string $name, string $email)
{
+ if ((!empty($firstname) || !empty($lastname)) && empty($name)) {
+ @trigger_error('Passing values for argument "$firstname" or "$lastname" is deprecated. Pass a value for argument "$name" instead.', E_USER_DEPRECATED);
+ }
+
Assert::uuid($identifier, 'Argument $identifier is not a valid UUID: %s');
+
+ if ((empty($firstname) || empty($lastname)) && empty($name)) {
+ throw new \InvalidArgumentException('Passing values for argument "$firstname" and "$lastname" is deprecated. Pass a value for argument "$name" instead.');
+ }
+
Assert::email($email);
$this->identifier = Uuid::fromString($identifier);
$this->firstname = $firstname;
$this->lastname = $lastname;
+
+ $this->name = empty($name) ? $firstname.' '.$lastname : $name;
+
$this->email = $email;
$this->workshops = new ArrayCollection();
@@ -62,6 +77,8 @@ public function getIdentifier(): string
public function getFirstname(): string
{
+ @trigger_error('Calling Attendee::getFirstname() is deprecated. Use Attendee::getName()', E_USER_DEPRECATED);
+
return $this->firstname;
}
@@ -74,6 +91,8 @@ public function changeFirstname(string $firstname): self
public function getLastname(): string
{
+ @trigger_error('Calling Attendee::getLastname() is deprecated. Use Attendee::getName()', E_USER_DEPRECATED);
+
return $this->lastname;
}
@@ -84,6 +103,11 @@ public function changeLastname(string $lastname): self
return $this;
}
+ public function getName(): string
+ {
+ return $this->name;
+ }
+
public function getEmail(): string
{
return $this->email;
diff --git a/tests/Controller/Attendee/CreateControllerTest.php b/tests/Controller/Attendee/CreateControllerTest.php
index 44c26db..efee03d 100644
--- a/tests/Controller/Attendee/CreateControllerTest.php
+++ b/tests/Controller/Attendee/CreateControllerTest.php
@@ -36,6 +36,7 @@ public function test_it_should_create_an_attendee(): void
$expectedAttendee = $attendeesAfter[0];
static::assertSame('Paul', $expectedAttendee->getFirstname());
static::assertSame('Paulsen', $expectedAttendee->getLastname());
+ static::assertSame('Paul Paulsen', $expectedAttendee->getName());
static::assertSame('paul@paulsen.de', $expectedAttendee->getEmail());
}
@@ -57,9 +58,9 @@ public static function provideUnprocessableAttendeeData(): \Generator
yield 'empty data' => ['{}'];
yield 'wrong json one' => ['{'];
yield 'wrong json two' => ['}'];
- yield 'missing firstname' => ['{"lastname": "Paulsen", "email": "paul@paulsen.de"}'];
- yield 'missing lastname' => ['{"firstname": "Paul", "email": "paul@paulsen.de"}'];
- yield 'missing email' => ['{"firstname": "Paul", "lastname": "Paulsen"}'];
- yield 'wrong email' => ['{"firstname": "Paul", "lastname": "Paulsen", "email": "paulpaulsende"}'];
+ yield 'missing firstname and missing name' => ['{"lastname": "Paulsen", "email": "paul@paulsen.de"}'];
+ yield 'missing lastname and missing name' => ['{"firstname": "Paul", "email": "paul@paulsen.de"}'];
+ yield 'missing email' => ['{"name": "Paul Paulsen"}'];
+ yield 'wrong email' => ['{"name": "Paul Paulsen", "email": "paulpaulsende"}'];
}
}
diff --git a/tests/Controller/Attendee/__snapshots__/CreateControllerTest__test_it_should_throw_an_UnprocessableEntityHttpException with data set empty data__1.json b/tests/Controller/Attendee/__snapshots__/CreateControllerTest__test_it_should_throw_an_UnprocessableEntityHttpException with data set empty data__1.json
index eef3e75..cdc842d 100644
--- a/tests/Controller/Attendee/__snapshots__/CreateControllerTest__test_it_should_throw_an_UnprocessableEntityHttpException with data set empty data__1.json
+++ b/tests/Controller/Attendee/__snapshots__/CreateControllerTest__test_it_should_throw_an_UnprocessableEntityHttpException with data set empty data__1.json
@@ -2,11 +2,7 @@
"errors": [
{
"message": "Validation failed.",
- "detail": "firstname: This value should not be blank."
- },
- {
- "message": "Validation failed.",
- "detail": "lastname: This value should not be blank."
+ "detail": "firstname: Passing values for fields \"$firstname\" and \"$lastname\" is deprecated. Pass a value for field \"$name\" instead."
},
{
"message": "Validation failed.",
diff --git a/tests/Controller/Attendee/__snapshots__/CreateControllerTest__test_it_should_throw_an_UnprocessableEntityHttpException with data set missing firstname and missing name__1.json b/tests/Controller/Attendee/__snapshots__/CreateControllerTest__test_it_should_throw_an_UnprocessableEntityHttpException with data set missing firstname and missing name__1.json
new file mode 100644
index 0000000..ed58a3c
--- /dev/null
+++ b/tests/Controller/Attendee/__snapshots__/CreateControllerTest__test_it_should_throw_an_UnprocessableEntityHttpException with data set missing firstname and missing name__1.json
@@ -0,0 +1,8 @@
+{
+ "errors": [
+ {
+ "message": "Validation failed.",
+ "detail": "firstname: Passing values for fields \"$firstname\" and \"$lastname\" is deprecated. Pass a value for field \"$name\" instead."
+ }
+ ]
+}
diff --git a/tests/Controller/Attendee/__snapshots__/CreateControllerTest__test_it_should_throw_an_UnprocessableEntityHttpException with data set missing lastname and missing name__1.json b/tests/Controller/Attendee/__snapshots__/CreateControllerTest__test_it_should_throw_an_UnprocessableEntityHttpException with data set missing lastname and missing name__1.json
new file mode 100644
index 0000000..ed58a3c
--- /dev/null
+++ b/tests/Controller/Attendee/__snapshots__/CreateControllerTest__test_it_should_throw_an_UnprocessableEntityHttpException with data set missing lastname and missing name__1.json
@@ -0,0 +1,8 @@
+{
+ "errors": [
+ {
+ "message": "Validation failed.",
+ "detail": "firstname: Passing values for fields \"$firstname\" and \"$lastname\" is deprecated. Pass a value for field \"$name\" instead."
+ }
+ ]
+}
diff --git a/tests/Controller/Attendee/__snapshots__/ListControllerTest__test_it_should_list_all_attendees with data set haljson__1.json b/tests/Controller/Attendee/__snapshots__/ListControllerTest__test_it_should_list_all_attendees with data set haljson__1.json
index 543aa13..4f55c24 100644
--- a/tests/Controller/Attendee/__snapshots__/ListControllerTest__test_it_should_list_all_attendees with data set haljson__1.json
+++ b/tests/Controller/Attendee/__snapshots__/ListControllerTest__test_it_should_list_all_attendees with data set haljson__1.json
@@ -4,6 +4,7 @@
"identifier": "803449f4-9a4c-4ecb-8ce4-cebc804fe70a",
"firstname": "Jan",
"lastname": "Sch\u00e4dlich",
+ "name": "Jan Sch\u00e4dlich",
"email": "schaedlich.jan@gmail.com",
"workshops": [
{
diff --git a/tests/Controller/Attendee/__snapshots__/ListControllerTest__test_it_should_list_all_attendees with data set json__1.json b/tests/Controller/Attendee/__snapshots__/ListControllerTest__test_it_should_list_all_attendees with data set json__1.json
index aef2fdc..908c4f8 100644
--- a/tests/Controller/Attendee/__snapshots__/ListControllerTest__test_it_should_list_all_attendees with data set json__1.json
+++ b/tests/Controller/Attendee/__snapshots__/ListControllerTest__test_it_should_list_all_attendees with data set json__1.json
@@ -4,6 +4,7 @@
"identifier": "803449f4-9a4c-4ecb-8ce4-cebc804fe70a",
"firstname": "Jan",
"lastname": "Sch\u00e4dlich",
+ "name": "Jan Sch\u00e4dlich",
"email": "schaedlich.jan@gmail.com",
"workshops": [
{
diff --git a/tests/Controller/Attendee/__snapshots__/ListControllerTest__test_it_should_paginate_attendees with data set show 1st page, 3 items each__1.json b/tests/Controller/Attendee/__snapshots__/ListControllerTest__test_it_should_paginate_attendees with data set show 1st page, 3 items each__1.json
index c7a3368..04a88ea 100644
--- a/tests/Controller/Attendee/__snapshots__/ListControllerTest__test_it_should_paginate_attendees with data set show 1st page, 3 items each__1.json
+++ b/tests/Controller/Attendee/__snapshots__/ListControllerTest__test_it_should_paginate_attendees with data set show 1st page, 3 items each__1.json
@@ -4,6 +4,7 @@
"identifier": "4878f198-36ab-4fe3-8189-19662a9764fa",
"firstname": "a",
"lastname": "1",
+ "name": "a1",
"email": "a1@test.de",
"workshops": []
},
@@ -11,6 +12,7 @@
"identifier": "e942ce16-27c2-494f-9d93-03412da980c5",
"firstname": "b",
"lastname": "2",
+ "name": "b2",
"email": "b2@test.de",
"workshops": []
},
@@ -18,6 +20,7 @@
"identifier": "4714fb8a-83d8-49af-abbf-7c68fc6c9656",
"firstname": "c",
"lastname": "3",
+ "name": "c3",
"email": "c3@test.de",
"workshops": []
}
diff --git a/tests/Controller/Attendee/__snapshots__/ListControllerTest__test_it_should_paginate_attendees with data set show 1st page, 5 items each__1.json b/tests/Controller/Attendee/__snapshots__/ListControllerTest__test_it_should_paginate_attendees with data set show 1st page, 5 items each__1.json
index f6ffe29..2e8f6c8 100644
--- a/tests/Controller/Attendee/__snapshots__/ListControllerTest__test_it_should_paginate_attendees with data set show 1st page, 5 items each__1.json
+++ b/tests/Controller/Attendee/__snapshots__/ListControllerTest__test_it_should_paginate_attendees with data set show 1st page, 5 items each__1.json
@@ -4,6 +4,7 @@
"identifier": "4878f198-36ab-4fe3-8189-19662a9764fa",
"firstname": "a",
"lastname": "1",
+ "name": "a1",
"email": "a1@test.de",
"workshops": []
},
@@ -11,6 +12,7 @@
"identifier": "e942ce16-27c2-494f-9d93-03412da980c5",
"firstname": "b",
"lastname": "2",
+ "name": "b2",
"email": "b2@test.de",
"workshops": []
},
@@ -18,6 +20,7 @@
"identifier": "4714fb8a-83d8-49af-abbf-7c68fc6c9656",
"firstname": "c",
"lastname": "3",
+ "name": "c3",
"email": "c3@test.de",
"workshops": []
},
@@ -25,6 +28,7 @@
"identifier": "65445e8c-a6c6-4955-9eb2-5fb60d6a991e",
"firstname": "d",
"lastname": "4",
+ "name": "d4",
"email": "d4@test.de",
"workshops": []
},
@@ -32,6 +36,7 @@
"identifier": "3aacd688-5b81-4aba-a5ea-ac7668ba95b6",
"firstname": "e",
"lastname": "5",
+ "name": "e5",
"email": "e5@test.de",
"workshops": []
}
diff --git a/tests/Controller/Attendee/__snapshots__/ListControllerTest__test_it_should_paginate_attendees with data set show 2nd page, 3 items each__1.json b/tests/Controller/Attendee/__snapshots__/ListControllerTest__test_it_should_paginate_attendees with data set show 2nd page, 3 items each__1.json
index dd26fbd..19acf7c 100644
--- a/tests/Controller/Attendee/__snapshots__/ListControllerTest__test_it_should_paginate_attendees with data set show 2nd page, 3 items each__1.json
+++ b/tests/Controller/Attendee/__snapshots__/ListControllerTest__test_it_should_paginate_attendees with data set show 2nd page, 3 items each__1.json
@@ -4,6 +4,7 @@
"identifier": "65445e8c-a6c6-4955-9eb2-5fb60d6a991e",
"firstname": "d",
"lastname": "4",
+ "name": "d4",
"email": "d4@test.de",
"workshops": []
},
@@ -11,6 +12,7 @@
"identifier": "3aacd688-5b81-4aba-a5ea-ac7668ba95b6",
"firstname": "e",
"lastname": "5",
+ "name": "e5",
"email": "e5@test.de",
"workshops": []
}
diff --git a/tests/Controller/Attendee/__snapshots__/ReadControllerTest__test_it_should_show_requested_attendee with data set haljson__1.json b/tests/Controller/Attendee/__snapshots__/ReadControllerTest__test_it_should_show_requested_attendee with data set haljson__1.json
index 2388fd4..f73234b 100644
--- a/tests/Controller/Attendee/__snapshots__/ReadControllerTest__test_it_should_show_requested_attendee with data set haljson__1.json
+++ b/tests/Controller/Attendee/__snapshots__/ReadControllerTest__test_it_should_show_requested_attendee with data set haljson__1.json
@@ -2,6 +2,7 @@
"identifier": "17058af8-1b0f-4afe-910d-669b4bd0fd26",
"firstname": "Jan",
"lastname": "Sch\u00e4dlich",
+ "name": "Jan Sch\u00e4dlich",
"email": "schaedlich.jan@gmail.com",
"workshops": [
{
diff --git a/tests/Controller/Attendee/__snapshots__/ReadControllerTest__test_it_should_show_requested_attendee with data set json__1.json b/tests/Controller/Attendee/__snapshots__/ReadControllerTest__test_it_should_show_requested_attendee with data set json__1.json
index 763a24e..5a9faf5 100644
--- a/tests/Controller/Attendee/__snapshots__/ReadControllerTest__test_it_should_show_requested_attendee with data set json__1.json
+++ b/tests/Controller/Attendee/__snapshots__/ReadControllerTest__test_it_should_show_requested_attendee with data set json__1.json
@@ -2,6 +2,7 @@
"identifier": "17058af8-1b0f-4afe-910d-669b4bd0fd26",
"firstname": "Jan",
"lastname": "Sch\u00e4dlich",
+ "name": "Jan Sch\u00e4dlich",
"email": "schaedlich.jan@gmail.com",
"workshops": [
{
diff --git a/tests/Controller/Attendee/fixtures/delete_attendee.yaml b/tests/Controller/Attendee/fixtures/delete_attendee.yaml
index dbecb1e..51e60b9 100644
--- a/tests/Controller/Attendee/fixtures/delete_attendee.yaml
+++ b/tests/Controller/Attendee/fixtures/delete_attendee.yaml
@@ -1,3 +1,3 @@
App\Entity\Attendee:
attendee_1:
- __construct: [ 'bb5cb8a8-0df8-404f-a3f3-54ee5c9cf855', 'Jan', 'Schädlich', 'schaedlich.jan@gmail.com' ]
+ __construct: [ 'bb5cb8a8-0df8-404f-a3f3-54ee5c9cf855', 'Jan', 'Schädlich', 'Jan Schädlich', 'schaedlich.jan@gmail.com' ]
diff --git a/tests/Controller/Attendee/fixtures/list_attendee.yaml b/tests/Controller/Attendee/fixtures/list_attendee.yaml
index 7381a6a..305c037 100644
--- a/tests/Controller/Attendee/fixtures/list_attendee.yaml
+++ b/tests/Controller/Attendee/fixtures/list_attendee.yaml
@@ -6,4 +6,4 @@ App\Entity\Workshop:
App\Entity\Attendee:
attendee_1:
- __construct: [ '803449f4-9a4c-4ecb-8ce4-cebc804fe70a', 'Jan', 'Schädlich', 'schaedlich.jan@gmail.com' ]
+ __construct: [ '803449f4-9a4c-4ecb-8ce4-cebc804fe70a', 'Jan', 'Schädlich', 'Jan Schädlich', 'schaedlich.jan@gmail.com' ]
diff --git a/tests/Controller/Attendee/fixtures/paginate_attendee.yaml b/tests/Controller/Attendee/fixtures/paginate_attendee.yaml
index 0762258..1c5712f 100644
--- a/tests/Controller/Attendee/fixtures/paginate_attendee.yaml
+++ b/tests/Controller/Attendee/fixtures/paginate_attendee.yaml
@@ -1,11 +1,11 @@
App\Entity\Attendee:
attendee_1:
- __construct: [ '4878f198-36ab-4fe3-8189-19662a9764fa', 'a', '1', 'a1@test.de' ]
+ __construct: [ '4878f198-36ab-4fe3-8189-19662a9764fa', 'a', '1', 'a1', 'a1@test.de' ]
attendee_2:
- __construct: [ 'e942ce16-27c2-494f-9d93-03412da980c5', 'b', '2', 'b2@test.de' ]
+ __construct: [ 'e942ce16-27c2-494f-9d93-03412da980c5', 'b', '2', 'b2', 'b2@test.de' ]
attendee_3:
- __construct: [ '4714fb8a-83d8-49af-abbf-7c68fc6c9656', 'c', '3', 'c3@test.de' ]
+ __construct: [ '4714fb8a-83d8-49af-abbf-7c68fc6c9656', 'c', '3', 'c3', 'c3@test.de' ]
attendee_4:
- __construct: [ '65445e8c-a6c6-4955-9eb2-5fb60d6a991e', 'd', '4', 'd4@test.de' ]
+ __construct: [ '65445e8c-a6c6-4955-9eb2-5fb60d6a991e', 'd', '4', 'd4', 'd4@test.de' ]
attendee_5:
- __construct: [ '3aacd688-5b81-4aba-a5ea-ac7668ba95b6', 'e', '5', 'e5@test.de' ]
+ __construct: [ '3aacd688-5b81-4aba-a5ea-ac7668ba95b6', 'e', '5', 'e5', 'e5@test.de' ]
diff --git a/tests/Controller/Attendee/fixtures/read_attendee.yaml b/tests/Controller/Attendee/fixtures/read_attendee.yaml
index 8e5ab2c..03e8e34 100644
--- a/tests/Controller/Attendee/fixtures/read_attendee.yaml
+++ b/tests/Controller/Attendee/fixtures/read_attendee.yaml
@@ -6,4 +6,4 @@ App\Entity\Workshop:
App\Entity\Attendee:
attendee_1:
- __construct: [ '17058af8-1b0f-4afe-910d-669b4bd0fd26', 'Jan', 'Schädlich', 'schaedlich.jan@gmail.com' ]
+ __construct: [ '17058af8-1b0f-4afe-910d-669b4bd0fd26', 'Jan', 'Schädlich', 'Jan Schädlich', 'schaedlich.jan@gmail.com' ]
diff --git a/tests/Controller/Attendee/fixtures/update_attendee.yaml b/tests/Controller/Attendee/fixtures/update_attendee.yaml
index 9d806bf..f354065 100644
--- a/tests/Controller/Attendee/fixtures/update_attendee.yaml
+++ b/tests/Controller/Attendee/fixtures/update_attendee.yaml
@@ -1,3 +1,3 @@
App\Entity\Attendee:
attendee_1:
- __construct: [ 'b38aa3e4-f9de-4dca-aaeb-3ec36a9feb6c', 'Jan', 'Schädlich', 'schaedlich.jan@gmail.com' ]
+ __construct: [ 'b38aa3e4-f9de-4dca-aaeb-3ec36a9feb6c', 'Jan', 'Schädlich', 'Jan Schädlich', 'schaedlich.jan@gmail.com' ]
diff --git a/tests/Controller/Workshop/__snapshots__/ListControllerTest__test_it_should_list_all_workshops with data set haljson__1.json b/tests/Controller/Workshop/__snapshots__/ListControllerTest__test_it_should_list_all_workshops with data set haljson__1.json
index ce823b4..26abc43 100644
--- a/tests/Controller/Workshop/__snapshots__/ListControllerTest__test_it_should_list_all_workshops with data set haljson__1.json
+++ b/tests/Controller/Workshop/__snapshots__/ListControllerTest__test_it_should_list_all_workshops with data set haljson__1.json
@@ -9,6 +9,7 @@
"identifier": "2a451d60-2fef-437b-838e-10edb2ade8eb",
"firstname": "Jan",
"lastname": "Sch\u00e4dlich",
+ "name": "Jan Sch\u00e4dlich",
"email": "schaedlich.jan@gmail.com",
"workshops": [
"RESTful Webservices in Symfony"
diff --git a/tests/Controller/Workshop/__snapshots__/ListControllerTest__test_it_should_list_all_workshops with data set json__1.json b/tests/Controller/Workshop/__snapshots__/ListControllerTest__test_it_should_list_all_workshops with data set json__1.json
index 46094b5..41ade64 100644
--- a/tests/Controller/Workshop/__snapshots__/ListControllerTest__test_it_should_list_all_workshops with data set json__1.json
+++ b/tests/Controller/Workshop/__snapshots__/ListControllerTest__test_it_should_list_all_workshops with data set json__1.json
@@ -9,6 +9,7 @@
"identifier": "2a451d60-2fef-437b-838e-10edb2ade8eb",
"firstname": "Jan",
"lastname": "Sch\u00e4dlich",
+ "name": "Jan Sch\u00e4dlich",
"email": "schaedlich.jan@gmail.com",
"workshops": [
"RESTful Webservices in Symfony"
diff --git a/tests/Controller/Workshop/__snapshots__/ReadControllerTest__test_it_should_show_requested_workshop with data set haljson__1.json b/tests/Controller/Workshop/__snapshots__/ReadControllerTest__test_it_should_show_requested_workshop with data set haljson__1.json
index bd4a30c..fd79d35 100644
--- a/tests/Controller/Workshop/__snapshots__/ReadControllerTest__test_it_should_show_requested_workshop with data set haljson__1.json
+++ b/tests/Controller/Workshop/__snapshots__/ReadControllerTest__test_it_should_show_requested_workshop with data set haljson__1.json
@@ -7,6 +7,7 @@
"identifier": "36ffcf19-7560-4ead-8d8e-3c40cf169784",
"firstname": "Jan",
"lastname": "Sch\u00e4dlich",
+ "name": "Jan Sch\u00e4dlich",
"email": "schaedlich.jan@gmail.com",
"workshops": [
"RESTful Webservices in Symfony"
diff --git a/tests/Controller/Workshop/__snapshots__/ReadControllerTest__test_it_should_show_requested_workshop with data set json__1.json b/tests/Controller/Workshop/__snapshots__/ReadControllerTest__test_it_should_show_requested_workshop with data set json__1.json
index 0bb7af6..7c65c50 100644
--- a/tests/Controller/Workshop/__snapshots__/ReadControllerTest__test_it_should_show_requested_workshop with data set json__1.json
+++ b/tests/Controller/Workshop/__snapshots__/ReadControllerTest__test_it_should_show_requested_workshop with data set json__1.json
@@ -7,6 +7,7 @@
"identifier": "36ffcf19-7560-4ead-8d8e-3c40cf169784",
"firstname": "Jan",
"lastname": "Sch\u00e4dlich",
+ "name": "Jan Sch\u00e4dlich",
"email": "schaedlich.jan@gmail.com",
"workshops": [
"RESTful Webservices in Symfony"
diff --git a/tests/Controller/Workshop/fixtures/add_attendee_to_workshop.yaml b/tests/Controller/Workshop/fixtures/add_attendee_to_workshop.yaml
index 43c6f2e..57ed46e 100644
--- a/tests/Controller/Workshop/fixtures/add_attendee_to_workshop.yaml
+++ b/tests/Controller/Workshop/fixtures/add_attendee_to_workshop.yaml
@@ -4,4 +4,4 @@ App\Entity\Workshop:
App\Entity\Attendee:
attendee_1:
- __construct: [ 'e9a95edb-9b49-42f4-bf2d-7206fd65bc94', 'Jan', 'Schädlich', 'schaedlich.jan@gmail.com' ]
+ __construct: [ 'e9a95edb-9b49-42f4-bf2d-7206fd65bc94', 'Jan', 'Schädlich', 'Jan Schädlich', 'schaedlich.jan@gmail.com' ]
diff --git a/tests/Controller/Workshop/fixtures/list_workshop.yaml b/tests/Controller/Workshop/fixtures/list_workshop.yaml
index 9d9cfad..214b236 100644
--- a/tests/Controller/Workshop/fixtures/list_workshop.yaml
+++ b/tests/Controller/Workshop/fixtures/list_workshop.yaml
@@ -1,6 +1,6 @@
App\Entity\Attendee:
attendee_1:
- __construct: [ '2a451d60-2fef-437b-838e-10edb2ade8eb', 'Jan', 'Schädlich', 'schaedlich.jan@gmail.com' ]
+ __construct: [ '2a451d60-2fef-437b-838e-10edb2ade8eb', 'Jan', 'Schädlich', 'Jan Schädlich', 'schaedlich.jan@gmail.com' ]
App\Entity\Workshop:
workshop_1:
diff --git a/tests/Controller/Workshop/fixtures/read_workshop.yaml b/tests/Controller/Workshop/fixtures/read_workshop.yaml
index 98a477c..0dc0db3 100644
--- a/tests/Controller/Workshop/fixtures/read_workshop.yaml
+++ b/tests/Controller/Workshop/fixtures/read_workshop.yaml
@@ -1,6 +1,6 @@
App\Entity\Attendee:
attendee_1:
- __construct: [ '36ffcf19-7560-4ead-8d8e-3c40cf169784', 'Jan', 'Schädlich', 'schaedlich.jan@gmail.com' ]
+ __construct: [ '36ffcf19-7560-4ead-8d8e-3c40cf169784', 'Jan', 'Schädlich', 'Jan Schädlich', 'schaedlich.jan@gmail.com' ]
App\Entity\Workshop:
workshop_1:
diff --git a/tests/Controller/Workshop/fixtures/remove_attendee_to_workshop.yaml b/tests/Controller/Workshop/fixtures/remove_attendee_to_workshop.yaml
index 7f551f3..fe4f633 100644
--- a/tests/Controller/Workshop/fixtures/remove_attendee_to_workshop.yaml
+++ b/tests/Controller/Workshop/fixtures/remove_attendee_to_workshop.yaml
@@ -1,6 +1,6 @@
App\Entity\Attendee:
attendee_1:
- __construct: [ 'f6ac0c74-ca77-4b3b-9829-8c0cfe29cf44', 'Jan', 'Schädlich', 'schaedlich.jan@gmail.com' ]
+ __construct: [ 'f6ac0c74-ca77-4b3b-9829-8c0cfe29cf44', 'Jan', 'Schädlich', 'Jan Schädlich', 'schaedlich.jan@gmail.com' ]
App\Entity\Workshop:
workshop_1:
diff --git a/tests/Entity/AttendeeTest.php b/tests/Entity/AttendeeTest.php
new file mode 100644
index 0000000..aa6bfb6
--- /dev/null
+++ b/tests/Entity/AttendeeTest.php
@@ -0,0 +1,60 @@
+toString(),
+ $firstname,
+ $lastname,
+ $name,
+ 'mail@janschaedlich.de'
+ );
+
+ self::assertSame($expectedName, $attendee->getName());
+ }
+
+ public static function provideValidNames(): iterable
+ {
+ yield ['firstname', 'lastname', 'fullname', 'fullname'];
+ yield ['', 'lastname', 'fullname', 'fullname'];
+ yield ['firstname', '', 'fullname', 'fullname'];
+ yield ['', '', 'fullname', 'fullname'];
+ yield ['firstname', 'lastname', '', 'firstname lastname'];
+ }
+
+ /**
+ * @dataProvider provideInvalidNames
+ */
+ public function test_it_throws_InvalidArgumentException_for_wrong_usage_of_name(string $firstname, string $lastname, string $name): void
+ {
+ $this->expectException(\InvalidArgumentException::class);
+
+ new Attendee(
+ Uuid::uuid4()->toString(),
+ $firstname,
+ $lastname,
+ $name,
+ 'mail@janschaedlich.de'
+ );
+ }
+
+ public static function provideInvalidNames(): iterable
+ {
+ yield ['', '', ''];
+ yield ['firstname', '', ''];
+ yield ['', 'lastname', ''];
+ }
+}