/** * {@inheritdoc} */ function setUp() { parent::setUp(); $this->role1 = entity_create('user_role', array('id' => strtolower($this->randomMachineName(8)), 'label' => $this->randomMachineName(8))); $this->role1->save(); $this->role2 = entity_create('user_role', array('id' => strtolower($this->randomMachineName(8)), 'label' => $this->randomMachineName(8))); $this->role2->save(); entity_reference_create_instance('user', 'user', 'user_reference', 'User reference', 'user'); }
public function role_create($role_machine_name, $role_human_readable_name = '') { // In D6 and D7, when we create a new role, the role // machine name is specified, and the numeric rid is // auto-assigned (next available id); in D8, when we // create a new role, we need to specify both the rid, // which is now the role machine name, and also a human-readable // role name. If the client did not provide a human-readable // name, then we'll use the role machine name in its place. if (empty($role_human_readable_name)) { $role_human_readable_name = ucfirst($role_machine_name); } $role = new Role(array('id' => $role_machine_name, 'label' => $role_human_readable_name), 'user_role'); $role->save(); return $role; }