亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

子實體鏈接不會在 ApiTestCase 中返回,而是在其他地方工作

子實體鏈接不會在 ApiTestCase 中返回,而是在其他地方工作

PHP
米脂 2022-10-28 15:12:50
我有兩個實體,一個客戶端(訪問器被剪斷)<?phpnamespace App\Entity;use ApiPlatform\Core\Annotation\ApiResource;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation\Groups;use Symfony\Component\Validator\Constraints as Assert;/** * @ApiResource( *     collectionOperations={ *         "get"={"normalization_context"={"groups"="client:list"}}, *         "post" *     }, *     itemOperations={ *         "get"={"normalization_context"={"groups"="client:item"}}, *     }, *     paginationEnabled=false, *     order={"name"="ASC"} * ) * @ORM\Entity(repositoryClass="App\Repository\ClientRepository") */class Client{    /**     * @ORM\Id()     * @ORM\GeneratedValue()     * @ORM\Column(type="integer")     * @Groups({"client:list", "client:item"})     */    private $id;    /**     * @ORM\Column(type="string", length=255)     * @Assert\NotBlank     * @Groups({"client:list", "client:item"})     */    private $name;    /**     * @ORM\OneToMany(targetEntity="App\Entity\Package", mappedBy="client")     * @Groups({"client:item"})     */    private $packages;    public function __construct()    {        $this->packages = new ArrayCollection();    }
查看完整描述

1 回答

?
四季花海

TA貢獻1811條經驗 獲得超5個贊

問題一直出在我的固定裝置上,感謝@ihsan 指導我進行調試。


我之前假設我需要做的就是在一個包中鏈接到客戶端:


App\Entity\Package:

  package_1:

    name: 'Inactive Package For First Client'

    createdAt: <dateTime('today -1 year')>

    status: 'INACTIVE'

    client: '@client_1'

  package_2:

    name: 'Active Package For First Client'

    createdAt: <dateTime('today -1 week')>

    status: 'ACTIVE'

    client: '@client_1'

但是,為了使測試正常工作,我還必須將包關聯到客戶端:


App\Entity\Client:

  client_1:

    name: First Client

    packages:

      - '@package_1'

      - '@package_2'


查看完整回答
反對 回復 2022-10-28
  • 1 回答
  • 0 關注
  • 93 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號