I'm having a hard time to fix this problem by adding roles in datafixtures using hautelook bundle. I create a provider that will add a roles to the fixtures
<?php
namespace AdminBundle\DataFixtures\Faker\Provider;
use AppBundle\Entity\AdminUserTypes;
class Roles
{
public function roleAdvocate(){
return ['ROLE_ADMIN', 'ROLE_ADVOCATE'];
}
}
in my datafixtures yml i have this code
AppBundle\Entity\AdminUser:
adminuser_101:
username: '<username()>'
email: '<email()>'
adminUserType: 2
enabled: true
roles: '<roleAdvocate()>'
when the time the I run the phpunit, i always get this result error from roles
Warning: in_array() expects parameter 2 to be array, null given
I have no idea now on how to fix it. Even I tweak the array. I get an error. I have this link but it doesn't work either. same result
In my project. I create another Entity called AdminUser Entity. This entity I inherit the abstract class User
class AdminUser extends User
Then I realize I forgot to add this method to inherit the parents constructor.
public function __construct()
{
parent::__construct();
}