/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); $this->installSchema('system', 'sequences'); $this->installEntitySchema('user'); $this->manager = $this->container->get('plugin.manager.condition'); // Set up the authenticated and anonymous roles. Role::create(array('id' => DRUPAL_ANONYMOUS_RID, 'label' => 'Anonymous user'))->save(); Role::create(array('id' => DRUPAL_AUTHENTICATED_RID, 'label' => 'Authenticated user'))->save(); // Create new role. $rid = strtolower($this->randomMachineName(8)); $label = $this->randomString(8); $role = Role::create(array('id' => $rid, 'label' => $label)); $role->save(); $this->role = $role; // Setup an anonymous user for our tests. $this->anonymous = User::create(array('uid' => 0)); $this->anonymous->save(); // Loading the anonymous user adds the correct role. $this->anonymous = User::load($this->anonymous->id()); // Setup an authenticated user for our tests. $this->authenticated = User::create(array('name' => $this->randomMachineName())); $this->authenticated->save(); // Add the custom role. $this->authenticated->addRole($this->role->id()); }
/** * {@inheritdoc} */ protected function setUpFixtures() { $this->installEntitySchema('user'); $this->installConfig(array('user')); parent::setUpFixtures(); // Create a record for uid 1. $this->rootUser = User::create(['name' => $this->randomMachineName()]); $this->rootUser->save(); Views::viewsData()->clear(); }
/** * Overrides \Drupal\views\Tests\ViewUnitTestBase::setUpFixtures(). */ protected function setUpFixtures() { $this->installEntitySchema('user'); $this->installConfig(array('user')); parent::setUpFixtures(); // Create a record for uid 1. $this->installSchema('system', 'sequences'); $this->root_user = entity_create('user', array('name' => $this->randomMachineName())); $this->root_user->save(); Views::viewsData()->clear(); }
protected function setUp() { parent::setUp(); // User create needs sequence table. $this->installSchema('system', array('sequences')); // Create a test user to use as the entity owner. $this->user = \Drupal::entityManager()->getStorage('user')->create(['name' => 'serialization_test_user', 'mail' => '*****@*****.**', 'pass' => '123456']); $this->user->save(); // Create a test entity to serialize. $this->values = array('name' => $this->randomMachineName(), 'user_id' => $this->user->id(), 'field_test_text' => array('value' => $this->randomMachineName(), 'format' => 'full_html')); $this->entity = entity_create('entity_test_mulrev', $this->values); $this->entity->save(); $this->serializer = $this->container->get('serializer'); $this->installConfig(array('field')); }