-
-
Notifications
You must be signed in to change notification settings - Fork 888
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add and fix tests about relation inheritance
Previous commits fix the behavior with non api resources inherited from resource but relation management was still not ok since the update was not done on the abstract item normalizer. The resource class resolver is now used as it should in every normalizers. Most of this commit (tests) comes from @vincentchalamon and its PR #2760
- Loading branch information
Showing
7 changed files
with
418 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity; | ||
|
||
use ApiPlatform\Core\Annotation\ApiResource; | ||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
/** | ||
* @ORM\Entity | ||
* @ORM\InheritanceType("JOINED") | ||
* @ApiResource( | ||
* collectionOperations={ | ||
* "get"={"path"="/custom_users"} | ||
* }, | ||
* itemOperations={ | ||
* "get"={"path"="/custom_users/{id}"} | ||
* } | ||
* ) | ||
*/ | ||
abstract class AbstractUser | ||
{ | ||
/** | ||
* @ORM\Column(type="integer") | ||
* @ORM\Id | ||
* @ORM\GeneratedValue(strategy="AUTO") | ||
*/ | ||
private $id; | ||
/** | ||
* @ORM\Column | ||
*/ | ||
private $firstname; | ||
/** | ||
* @ORM\Column | ||
*/ | ||
private $lastname; | ||
/** | ||
* @ORM\Column | ||
*/ | ||
private $email; | ||
|
||
public function getId(): ?int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getFirstname(): ?string | ||
{ | ||
return $this->firstname; | ||
} | ||
|
||
public function setFirstname(string $firstname): self | ||
{ | ||
$this->firstname = $firstname; | ||
|
||
return $this; | ||
} | ||
|
||
public function getLastname(): ?string | ||
{ | ||
return $this->lastname; | ||
} | ||
|
||
public function setLastname(string $lastname): self | ||
{ | ||
$this->lastname = $lastname; | ||
|
||
return $this; | ||
} | ||
|
||
public function getEmail(): ?string | ||
{ | ||
return $this->email; | ||
} | ||
|
||
public function setEmail(string $email): self | ||
{ | ||
$this->email = $email; | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity; | ||
|
||
use ApiPlatform\Core\Annotation\ApiResource; | ||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
/** | ||
* @ORM\Entity | ||
* @ApiResource | ||
*/ | ||
class ExternalUser extends AbstractUser | ||
{ | ||
/** | ||
* @ORM\Column | ||
*/ | ||
private $externalId; | ||
|
||
public function getExternalId(): ?string | ||
{ | ||
return $this->externalId; | ||
} | ||
|
||
public function setExternalId(string $externalId): self | ||
{ | ||
$this->externalId = $externalId; | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
/** | ||
* @ORM\Entity | ||
*/ | ||
class InternalUser extends AbstractUser | ||
{ | ||
/** | ||
* @ORM\Column | ||
*/ | ||
private $internalId; | ||
|
||
public function getInternalId(): ?string | ||
{ | ||
return $this->internalId; | ||
} | ||
|
||
public function setInternalId(string $internalId): self | ||
{ | ||
$this->internalId = $internalId; | ||
|
||
return $this; | ||
} | ||
} |
Oops, something went wrong.