Loading module/Oscar/src/Oscar/Factory/JsonToOrganization.php +2 −2 Changes for module/Oscar/src/Oscar/Factory/JsonToOrganization.php: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -26,9 +26,9 @@ class JsonToOrganization extends JsonToObject implements IJsonToOrganisation private ?array $types; protected function getTypeObj(string $typeLabel): ?OrganizationType public function getTypeObj(?string $typeLabel = null): ?OrganizationType { if (is_array($this->types) && array_key_exists($typeLabel, $this->types)) { if (!is_null($typeLabel) && is_array($this->types) && array_key_exists($typeLabel, $this->types)) { return $this->types[$typeLabel]; } return null; Loading tests/Oscar/Connector/JsonToOrganizationTest.php 0 → 100644 +20 −0 Changes for tests/Oscar/Connector/JsonToOrganizationTest.php: 20 added lines, 0 removed lines. Original line number Diff line number Diff line <?php use PHPUnit\Framework\TestCase; class JsonToOrganizationTest extends TestCase { public function testType() { $type = new \Oscar\Entity\OrganizationType(); $type->setLabel("Type d'organisation"); $types = ["foo" => $type]; $json = new \Oscar\Factory\JsonToOrganization($types); $this->assertNull($json->getTypeObj(null), 'Les types NULL retournent NULL'); $this->assertNull($json->getTypeObj(""), 'Les types "chaîne vide" retournent NULL'); $this->assertNull($json->getTypeObj("nexistepas"), 'Les types non référencés retournent NULL'); $extractedType = $json->getTypeObj("foo"); $this->assertEquals($extractedType, $type); } } Loading
module/Oscar/src/Oscar/Factory/JsonToOrganization.php +2 −2 Changes for module/Oscar/src/Oscar/Factory/JsonToOrganization.php: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -26,9 +26,9 @@ class JsonToOrganization extends JsonToObject implements IJsonToOrganisation private ?array $types; protected function getTypeObj(string $typeLabel): ?OrganizationType public function getTypeObj(?string $typeLabel = null): ?OrganizationType { if (is_array($this->types) && array_key_exists($typeLabel, $this->types)) { if (!is_null($typeLabel) && is_array($this->types) && array_key_exists($typeLabel, $this->types)) { return $this->types[$typeLabel]; } return null; Loading
tests/Oscar/Connector/JsonToOrganizationTest.php 0 → 100644 +20 −0 Changes for tests/Oscar/Connector/JsonToOrganizationTest.php: 20 added lines, 0 removed lines. Original line number Diff line number Diff line <?php use PHPUnit\Framework\TestCase; class JsonToOrganizationTest extends TestCase { public function testType() { $type = new \Oscar\Entity\OrganizationType(); $type->setLabel("Type d'organisation"); $types = ["foo" => $type]; $json = new \Oscar\Factory\JsonToOrganization($types); $this->assertNull($json->getTypeObj(null), 'Les types NULL retournent NULL'); $this->assertNull($json->getTypeObj(""), 'Les types "chaîne vide" retournent NULL'); $this->assertNull($json->getTypeObj("nexistepas"), 'Les types non référencés retournent NULL'); $extractedType = $json->getTypeObj("foo"); $this->assertEquals($extractedType, $type); } }