{"action":"closed","issue":{"url":"https://api.github.com/repos/Codeception/Codeception/issues/5133","repository_url":"https://api.github.com/repos/Codeception/Codeception","labels_url":"https://api.github.com/repos/Codeception/Codeception/issues/5133/labels{/name}","comments_url":"https://api.github.com/repos/Codeception/Codeception/issues/5133/comments","events_url":"https://api.github.com/repos/Codeception/Codeception/issues/5133/events","html_url":"https://github.com/Codeception/Codeception/issues/5133","id":353417266,"node_id":"MDU6SXNzdWUzNTM0MTcyNjY=","number":5133,"title":"[Doctrine2 + DataFactory]  [Error] Cannot access private property App\\Entity\\Entity::$property ","user":{"login":"joelmedeiros","id":5870140,"node_id":"MDQ6VXNlcjU4NzAxNDA=","avatar_url":"https://avatars2.githubusercontent.com/u/5870140?v=4","gravatar_id":"","url":"https://api.github.com/users/joelmedeiros","html_url":"https://github.com/joelmedeiros","followers_url":"https://api.github.com/users/joelmedeiros/followers","following_url":"https://api.github.com/users/joelmedeiros/following{/other_user}","gists_url":"https://api.github.com/users/joelmedeiros/gists{/gist_id}","starred_url":"https://api.github.com/users/joelmedeiros/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joelmedeiros/subscriptions","organizations_url":"https://api.github.com/users/joelmedeiros/orgs","repos_url":"https://api.github.com/users/joelmedeiros/repos","events_url":"https://api.github.com/users/joelmedeiros/events{/privacy}","received_events_url":"https://api.github.com/users/joelmedeiros/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-08-23T14:48:25Z","updated_at":"2018-08-30T20:16:19Z","closed_at":"2018-08-30T20:16:19Z","author_association":"NONE","body":"#### What are you trying to achieve?\r\nI'm trying to generate a fake entity with relationed entities such as:\r\n\r\nUser has N permissions\r\n\r\nWorking with ManyToMany or OneToMany on Doctrine2 and SF4 the entity generated for this relationship is: \r\n\r\n```php\r\n\r\nclass User {\r\n    \r\n     /**\r\n     * @var \\Doctrine\\Common\\Collections\\ArrayCollection|Contract[]\r\n     * @ORM\\OneToMany(targetEntity=\"UserPermission\",inversedBy=\"user\")\r\n     * @ORM\\JoinColumns({\r\n     *   @ORM\\JoinColumn(name=\"id\", referencedColumnName=\"user_id\")\r\n     * })\r\n     */\r\n     private $permissions;\r\n\r\n    /**\r\n     * @return Collection|UserPermission[]\r\n     */\r\n    public function getPermissions(): Collection\r\n    {\r\n        return $this->permissions;\r\n    }\r\n\r\n    /**\r\n     * @param UserPermission $permission\r\n     * @return self\r\n     */\r\n    public function addPermission(UserPermission $permission): self\r\n    {\r\n        if (!$this->permissions->contains($permission)) {\r\n            $this->permissions[] = $permission;\r\n            $permission->setUser($this);\r\n        }\r\n\r\n        return $this;\r\n    }\r\n\r\n    /**\r\n     * @param UserPermission $permission\r\n     * @return self\r\n     */\r\n    public function removePermission(UserPermission $permission): self\r\n    {\r\n        if ($this->permissions->contains($permission)) {\r\n            $this->permissions->removeElement($permission);\r\n            // set the owning side to null (unless already changed)\r\n            if ($permission->getUser() === $this) {\r\n                $permission->setUser(null);\r\n            }\r\n        }\r\n\r\n        return $this;\r\n    }\r\n}\r\n\r\nclass UserPermission {\r\n ...\r\n}\r\n```\r\nAs you can see, User class does not have \"setPermission\", and I think that's the problem. \r\n\r\n#### What do you get instead?\r\n\r\n```bash\r\n#  [Error] Cannot access private property App\\Entity\\User::$permissions  \r\n```\r\non _beforeSuite method:\r\n\r\n```php\r\n\r\n$factory = $this->getModule('DataFactory');\r\n\r\n$factory->_define(UserPermission::class, ['fieldx'=> Faker::fieldx()]);\r\n$factory->_define(User::class, ['permissions'=> 'entity|' . UserPermission::class]);\r\n// neither $factory->_define(User::class, ['permissions'=> 'entity[2]|' . UserPermission::class]);\r\n\r\n```\r\n### Details\r\n\r\n* Codeception version: v2.4.5\r\n* PHP Version: 7.1\r\n* Operating System: CentOs\r\n* Installation type: Composer\r\n* List of installed packages (`composer show`) : \r\nleague/factory-muffin                v3.0.1             The goal of this pa...\r\nleague/factory-muffin-faker          v2.0.0             The goal of this pa...\r\ncodeception/codeception              2.4.5              BDD-style testing f...\r\ncodeception/phpunit-wrapper          7.2.0              PHPUnit classes use...\r\ncodeception/stub                     2.0.4              Flexible Stub wrapp...\r\n\r\n* Suite configuration:\r\n\r\n```yml\r\nmodules:\r\n    enabled:\r\n        - Asserts\r\n        - \\Helper\\Unit\r\n        - Db\r\n        - Doctrine2:\r\n            depends: Symfony\r\n            cleanup: true\r\n            em: master\r\n        - DataFactory:\r\n            depends: Doctrine2\r\n        - \\Helper\\Factories\r\n        - Symfony:\r\n            app_path: 'src'\r\n            var_path: 'var'\r\n            environment: 'local'\r\n        - MongoDb\r\n```\r\n"}}
{"actor":{"display_login":"joelmedeiros"}}