Skip to content
Commits on Source (59)
......@@ -38,24 +38,19 @@ test-php8.0:
PHP: "php8.0"
<<: *test_defaults
psalm:
test-php8.1:
stage: test
script:
- sudo update-alternatives --set php /usr/bin/php7.4
- composer install
- composer run psalm
phpstan:
stage: test
script:
- sudo update-alternatives --set php /usr/bin/php7.4
- composer install
- composer run phpstan
variables:
PHP: "php8.1"
<<: *test_defaults
cs-fixer:
linting:
stage: test
allow_failure: true
script:
- sudo update-alternatives --set php /usr/bin/php7.4
- composer install
- composer run cs
- result=0
- composer run cs || result=1
- composer run phpstan || result=1
- composer run psalm || result=1
- exit $result
......@@ -58,13 +58,6 @@ class PersonProvider implements PersonProviderInterface
return $people;
}
public function getPersonsByNameAndBirthDate(string $givenName, string $familyName, string $birthDate): array
{
$people = some_method_to_fetch_persons_by_name_and_birthday($givenName, $familyName, $birthDate);
return $people;
}
public function getPerson(string $id): Person
{
return some_method_to_fetch_person_by_id($id);
......
......@@ -3,10 +3,10 @@
"type": "symfony-bundle",
"license": "AGPL-3.0-or-later",
"require": {
"php": "^7.3",
"php": ">=7.3",
"ext-json": "*",
"api-platform/core": "^2.6.3",
"dbp/relay-core-bundle": "^0.1.11",
"dbp/relay-core-bundle": "^0.1.25",
"guzzlehttp/guzzle": "^7.0",
"nelmio/cors-bundle": "^2.1.0",
"phpdocumentor/reflection-docblock": "^3.0 || ^4.0 || ^5.0",
......@@ -22,8 +22,9 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.0",
"phpstan/phpstan": "^0.12.33",
"phpstan/phpstan-phpunit": "^0.12.13",
"phpstan/phpstan": "^1.0.0",
"phpstan/phpstan-phpunit": "^1.0.0",
"phpunit/phpunit": "^9",
"symfony/browser-kit": "^5.2",
"symfony/http-client": "^5.2",
"symfony/monolog-bundle": "^3.7",
......@@ -48,14 +49,12 @@
},
"scripts": {
"test": [
"@php vendor/bin/simple-phpunit"
"@php vendor/bin/phpunit"
],
"phpstan": [
"@php vendor/bin/simple-phpunit --atleast-version 0",
"@php vendor/bin/phpstan analyze --ansi"
],
"psalm": [
"@php vendor/bin/simple-phpunit --atleast-version 0",
"@php vendor/bin/psalm"
],
"lint": [
......
This diff is collapsed.
......@@ -6,9 +6,6 @@ parameters:
level: 3
paths:
- src
- tests
bootstrapFiles:
- vendor/bin/.phpunit/phpunit-9-0/vendor/autoload.php
excludes_analyse:
excludePaths:
- tests/bootstrap.php
ignoreErrors:
......@@ -12,9 +12,7 @@
<server name="APP_ENV" value="test" force="true"/>
<server name="KERNEL_CLASS" value="App\Kernel"/>
<server name="SHELL_VERBOSITY" value="-1"/>
<server name="SYMFONY_PHPUNIT_REMOVE" value=""/>
<server name="SYMFONY_PHPUNIT_VERSION" value="9"/>
<server name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
<server name="SYMFONY_DEPRECATIONS_HELPER" value='max[direct]=0&amp;quiet[]=indirect'/>
<server name="KERNEL_CLASS" value="Dbp\Relay\BasePersonBundle\Tests\Kernel"/>
</php>
<testsuites>
......
......@@ -15,11 +15,6 @@ interface PersonProviderInterface
*/
public function getPersons(array $filters): array;
/**
* @return Person[]
*/
public function getPersonsByNameAndBirthDate(string $givenName, string $familyName, string $birthDate): array;
public function getPerson(string $id): Person;
/**
......
......@@ -9,7 +9,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('dbp_relay_base');
......
......@@ -37,7 +37,7 @@ use ApiPlatform\Core\Annotation\ApiResource;
* }
* )
*/
class Person
class Person implements PersonInterface
{
use PersonTrait;
}
<?php
declare(strict_types=1);
namespace Dbp\Relay\BasePersonBundle\Entity;
interface PersonInterface
{
public function setIdentifier(string $identifier): void;
public function getIdentifier(): ?string;
public function getGivenName(): ?string;
public function setGivenName(string $givenName): void;
public function getFamilyName(): ?string;
public function setFamilyName(string $familyName): void;
public function getEmail(): ?string;
public function setEmail(string $email): void;
public function getBirthDate(): ?string;
public function setBirthDate(string $birthDate): void;
}
......@@ -59,7 +59,7 @@ trait PersonTrait
$this->extraData = [];
}
public function setIdentifier(string $identifier)
public function setIdentifier(string $identifier): void
{
$this->identifier = $identifier;
}
......@@ -74,7 +74,7 @@ trait PersonTrait
return $this->givenName;
}
public function setGivenName(?string $givenName)
public function setGivenName(string $givenName): void
{
$this->givenName = $givenName;
}
......@@ -84,7 +84,7 @@ trait PersonTrait
return $this->familyName;
}
public function setFamilyName(?string $familyName)
public function setFamilyName(string $familyName): void
{
$this->familyName = $familyName;
}
......@@ -94,7 +94,7 @@ trait PersonTrait
return $this->email;
}
public function setEmail(?string $email)
public function setEmail(string $email): void
{
$this->email = $email;
}
......@@ -123,7 +123,7 @@ trait PersonTrait
return $this->birthDate;
}
public function setBirthDate(string $birthDate)
public function setBirthDate(string $birthDate): void
{
$this->birthDate = $birthDate;
}
......
......@@ -15,7 +15,7 @@ services:
autowire: true
autoconfigure: true
# This alias exist so we can replace the service during tests
# This alias exists, so we can replace the service during tests
test.PersonProviderInterface:
alias: 'Dbp\Relay\BasePersonBundle\API\PersonProviderInterface'
public: true
......@@ -26,6 +26,9 @@ class PersonAttributeNormalizer implements ContextAwareNormalizerInterface, Norm
$this->security = $security;
}
/**
* @return array|string|int|float|bool|\ArrayObject|null
*/
public function normalize($object, $format = null, array $context = [])
{
// set the group "Person:current-user" for the current user
......@@ -38,7 +41,7 @@ class PersonAttributeNormalizer implements ContextAwareNormalizerInterface, Norm
return $this->normalizer->normalize($object, $format, $context);
}
public function supportsNormalization($data, $format = null, array $context = [])
public function supportsNormalization($data, $format = null, array $context = []): bool
{
// Make sure we're not called twice
if (isset($context[self::ALREADY_CALLED])) {
......
......@@ -29,11 +29,6 @@ class DummyPersonProvider implements PersonProviderInterface
return [];
}
public function getPersonsByNameAndBirthDate(string $givenName, string $familyName, string $birthDate): array
{
return [];
}
public function getPerson(string $id): Person
{
$person = new Person();
......
......@@ -43,11 +43,6 @@ class DummyPersonProvider implements PersonProviderInterface
throw new ItemNotFoundException();
}
public function getPersonsByNameAndBirthDate(string $givenName, string $familyName, string $birthDate): array
{
return [];
}
public function setCurrentIdentifier(string $identifier): void
{
$this->person->setIdentifier($identifier);
......
......@@ -21,4 +21,29 @@ class PersonTest extends TestCase
$this->assertSame(null, $person->getExtraData('nope'));
}
public function testGettersSetters()
{
$person = new Person();
$this->assertNull($person->getIdentifier());
$person->setIdentifier('foo');
$this->assertSame('foo', $person->getIdentifier());
$this->assertNull($person->getGivenName());
$person->setGivenName('foo');
$this->assertSame('foo', $person->getGivenName());
$this->assertNull($person->getFamilyName());
$person->setFamilyName('foo');
$this->assertSame('foo', $person->getFamilyName());
$this->assertNull($person->getEmail());
$person->setEmail('foo@invalid.com');
$this->assertSame('foo@invalid.com', $person->getEmail());
$this->assertNull($person->getBirthDate());
$person->setBirthDate('1970-01-01');
$this->assertSame('1970-01-01', $person->getBirthDate());
}
}