Skip to content

Commit

Permalink
Added doc to show how to use the force flag when creating a person
Browse files Browse the repository at this point in the history
  • Loading branch information
stollr committed Sep 12, 2022
1 parent 89fd8fc commit b1b03ca
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/out/PersonAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,28 @@

```

Sometimes it will happen that you have to add a person with the same name
as an existing one. ChurchTools will respond with an error to prevent you from
adding duplicates accidently.

Therefore you can add the `force` parameter and set it to `true`.

```php
use CTApi\Models\Person;
use CTApi\Requests\PersonRequest;

$newPerson = new Person();
$newPerson->setFirstName("John")
->setLastName("Doe")
->setBirthday("1970-01-01");
//add further attributes

PersonRequest::create($newPerson, force: true);

```

This will make ChurchTools to insert the record, even if there is a second John Doe.

## Update a person's data

Use the setters of the person model to modify its data and utilize the
Expand Down
10 changes: 10 additions & 0 deletions docs/src/ressources/PersonAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@

{{ \Tests\Unit\Docs\PersonRequestTest.testCreatePerson }}

Sometimes it will happen that you have to add a person with the same name
as an existing one. ChurchTools will respond with an error to prevent you from
adding duplicates accidently.

Therefore you can add the `force` parameter and set it to `true`.

{{ \Tests\Unit\Docs\PersonRequestTest.testCreatePersonWithEqualName }}

This will make ChurchTools to insert the record, even if there is a second John Doe.

## Update a person's data

Use the setters of the person model to modify its data and utilize the
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/Docs/PersonRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ public function testCreatePerson()
PersonRequest::create($newPerson);
}

/**
* @doesNotPerformAssertions
*/
public function testCreatePersonWithEqualName()
{
$newPerson = new Person();
$newPerson->setFirstName("John")
->setLastName("Doe")
->setBirthday("1970-01-01");
//add further attributes

PersonRequest::create($newPerson, force: true);
}

/**
* @doesNotPerformAssertions
*/
Expand Down

0 comments on commit b1b03ca

Please sign in to comment.