/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); $this->installEntitySchema('taxonomy_term'); $this->installConfig(array('taxonomy')); \Drupal::service('router.builder')->rebuild(); }
/** * {@inheritdoc} */ protected function setUp($import_test_views = TRUE) { parent::setUp($import_test_views); $this->installEntitySchema('user'); $this->installEntitySchema('comment'); // Create the anonymous role. $this->installConfig(['user']); // Create an anonymous user. $storage = \Drupal::entityManager()->getStorage('user'); // Insert a row for the anonymous user. $storage->create(array('uid' => 0, 'name' => '', 'status' => 0))->save(); $admin_role = Role::create(['id' => 'admin', 'permissions' => ['administer comments', 'access user profiles']]); $admin_role->save(); /* @var \Drupal\user\RoleInterface $anonymous_role */ $anonymous_role = Role::load(Role::ANONYMOUS_ID); $anonymous_role->grantPermission('access comments'); $anonymous_role->save(); $this->adminUser = User::create(['name' => $this->randomMachineName(), 'roles' => [$admin_role->id()]]); $this->adminUser->save(); // Create some comments. $comment = Comment::create(['subject' => 'My comment title', 'uid' => $this->adminUser->id(), 'name' => $this->adminUser->label(), 'entity_type' => 'entity_test', 'comment_type' => 'entity_test', 'status' => 1]); $comment->save(); $comment_anonymous = Comment::create(['subject' => 'Anonymous comment title', 'uid' => 0, 'name' => 'barry', 'mail' => '*****@*****.**', 'homepage' => 'https://example.com', 'entity_type' => 'entity_test', 'comment_type' => 'entity_test', 'created' => 123456, 'status' => 1]); $comment_anonymous->save(); }
protected function setUp() { parent::setUp(); $this->installConfig(array('language')); // Create another language beside English. ConfigurableLanguage::create(array('id' => 'xx-lolspeak', 'label' => 'Lolspeak'))->save(); }
/** * {@inheritdoc} */ protected function setUp($import_test_views = TRUE) { parent::setUp($import_test_views); if ($import_test_views) { ViewTestData::createTestViews(get_class($this), ['entity_module_test']); } }
/** * {@inheritdoc} */ protected function setUp($import_test_views = TRUE) { parent::setUp($import_test_views); $this->installEntitySchema('node'); $this->installEntitySchema('user'); $this->installConfig(['node', 'field']); ViewTestData::createTestViews(get_class($this), ['node_test_views']); }
protected function setUp() { parent::setUp(); $this->installEntitySchema('user'); $this->installEntitySchema('profile'); $this->installEntitySchema('profile_type'); ViewTestData::createTestViews(get_class($this), ['profile_test']); }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); // Rebuild the router, otherwise we can't generate links. $this->container->get('router.builder')->rebuild(); $this->installSchema('dblog', array('watchdog')); ViewTestData::createTestViews(get_class($this), array('dblog_test_views')); }
/** * {@inheritdoc} */ protected function setUp($import_test_views = TRUE) { parent::setUp($import_test_views); $this->installEntitySchema('node'); $this->installEntitySchema('taxonomy_term'); $this->installEntitySchema('user'); // Setup the current time properly. \Drupal::request()->server->set('REQUEST_TIME', time()); }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); $this->installEntitySchema('user'); $this->installEntitySchema('entity_test'); $this->installEntitySchema('entity_test_mul'); $this->storage = $this->container->get('entity.manager')->getStorage('entity_test'); ConfigurableLanguage::createFromLangcode('it')->save(); }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); $this->installEntitySchema('aggregator_item'); $this->installEntitySchema('aggregator_feed'); ViewTestData::createTestViews(get_class($this), array('aggregator_test_views')); $this->itemStorage = $this->container->get('entity.manager')->getStorage('aggregator_item'); $this->feedStorage = $this->container->get('entity.manager')->getStorage('aggregator_feed'); }
protected function setUp() { parent::setUp(); ViewTestData::createTestViews(get_class($this), array('user_test_views')); $this->installEntitySchema('user'); $entity_manager = $this->container->get('entity.manager'); $this->roleStorage = $entity_manager->getStorage('user_role'); $this->userStorage = $entity_manager->getStorage('user'); }
/** * {@inheritdoc} */ protected function setUp($import_test_views = TRUE) { parent::setUp($import_test_views); $this->installSchema('node', 'node_access'); $this->installEntitySchema('node'); $this->installEntitySchema('user'); if ($import_test_views) { ViewTestData::createTestViews(get_class($this), ['node_test_views']); } }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); $this->installEntitySchema('user'); $this->installEntitySchema('entity_test'); $this->installEntitySchema('entity_test_mul'); // Create reference from entity_test to entity_test_mul. $this->createEntityReferenceField('entity_test', 'entity_test', 'field_test_data', 'field_test_data', 'entity_test_mul'); // Create reference from entity_test_mul to entity_test. $this->createEntityReferenceField('entity_test_mul', 'entity_test_mul', 'field_data_test', 'field_data_test', 'entity_test'); ViewTestData::createTestViews(get_class($this), array('entity_reference_test_views')); }
/** * {@inheritdoc} */ protected function setUp($import_test_views = TRUE) { parent::setUp($import_test_views); $this->installEntitySchema('user'); $role_with_access = Role::create(['id' => 'with_access', 'permissions' => ['view test entity field']]); $role_with_access->save(); $role_without_access = Role::create(['id' => 'without_access', 'permissions' => []]); $role_without_access->save(); $this->userWithAccess = User::create(['name' => $this->randomMachineName(), 'roles' => [$role_with_access->id()]]); $this->userWithAccess->save(); $this->userWithoutAccess = User::create(['name' => $this->randomMachineName(), 'roles' => [$role_without_access->id()]]); $this->userWithoutAccess->save(); }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); ViewTestData::createTestViews(get_class($this), array('file_test_views')); $this->installEntitySchema('file'); file_put_contents('public://file.png', ''); File::create(['uri' => 'public://file.png', 'filename' => 'file.png'])->save(); file_put_contents('public://file.tar', ''); File::create(['uri' => 'public://file.tar', 'filename' => 'file.tar'])->save(); file_put_contents('public://file.tar.gz', ''); File::create(['uri' => 'public://file.tar.gz', 'filename' => 'file.tar.gz'])->save(); file_put_contents('public://file', ''); File::create(['uri' => 'public://file', 'filename' => 'file'])->save(); }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(FALSE); // Install the necessary dependencies for node type creation to work. $this->installEntitySchema('node'); $this->installConfig(array('field', 'node')); $comment_type = entity_create('comment_type', array('id' => 'comment', 'label' => 'Comment settings', 'description' => 'Comment settings', 'target_entity_type_id' => 'node')); $comment_type->save(); $content_type = entity_create('node_type', array('type' => $this->randomMachineName(), 'name' => $this->randomString())); $content_type->save(); $field_storage = entity_create('field_storage_config', array('field_name' => Unicode::strtolower($this->randomMachineName()), 'entity_type' => 'node', 'type' => 'comment')); $field_storage->save(); entity_create('field_config', array('field_storage' => $field_storage, 'bundle' => $content_type->id(), 'label' => $this->randomMachineName() . '_label', 'description' => $this->randomMachineName() . '_description', 'settings' => array('comment_type' => $comment_type->id())))->save(); entity_create('field_config', array('field_storage' => FieldStorageConfig::loadByName('node', 'body'), 'bundle' => $content_type->id(), 'label' => $this->randomMachineName() . '_body', 'settings' => array('display_summary' => TRUE)))->save(); ViewTestData::createTestViews(get_class($this), array('views_test_config')); }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); $this->eventDispatcher = $this->container->get('event_dispatcher'); $this->eventSubscriber = $this->container->get('views.entity_schema_subscriber'); $this->entityDefinitionUpdateManager = $this->container->get('entity.definition_update_manager'); $this->entityManager = $this->container->get('entity.manager'); $this->state = $this->container->get('state'); $this->database = $this->container->get('database'); // Install every entity type's schema that wasn't installed in the parent // method. foreach (array_diff_key($this->entityManager->getDefinitions(), array_flip(array('user', 'entity_test'))) as $entity_type_id => $entity_type) { $this->installEntitySchema($entity_type_id); } $this->installSchema('system', 'key_value_expire'); }
protected function setUp() { parent::setUp(); $this->mockStandardInstall(); ViewTestData::createTestViews(get_class($this), ['options_test_views']); $settings = []; $settings['type'] = 'article'; $settings['title'] = $this->randomString(); $settings['field_test_list_string'][]['value'] = $this->fieldValues[0]; $settings['field_test_list_integer'][]['value'] = 0; $node = Node::create($settings); $node->save(); $this->nodes[] = $node; $node = $node->createDuplicate(); $node->save(); $this->nodes[] = $node; }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); $this->installEntitySchema('node'); $this->installEntitySchema('user'); $this->installSchema('node', array('node_access')); $this->installConfig(array('node', 'language')); // The entity.node.canonical route must exist when nodes are rendered. $this->container->get('router.builder')->rebuild(); $this->langcodes = array(\Drupal::languageManager()->getDefaultLanguage()->getId()); for ($i = 0; $i < 2; $i++) { $langcode = 'l' . $i; $this->langcodes[] = $langcode; ConfigurableLanguage::createFromLangcode($langcode)->save(); } // Make sure we do not try to render non-existing user data. $node_type = NodeType::create(array('type' => 'test')); $node_type->setDisplaySubmitted(FALSE); $node_type->save(); $this->values = array(); $controller = \Drupal::entityManager()->getStorage('node'); $langcode_index = 0; for ($i = 0; $i < count($this->langcodes); $i++) { // Create a node with a different default language each time. $default_langcode = $this->langcodes[$langcode_index++]; $node = $controller->create(array('type' => 'test', 'uid' => 0, 'langcode' => $default_langcode)); // Ensure the default language is processed first. $langcodes = array_merge(array($default_langcode), array_diff($this->langcodes, array($default_langcode))); foreach ($langcodes as $langcode) { // Ensure we have a predictable result order. $this->values[$i][$langcode] = $i . '-' . $langcode . '-' . $this->randomMachineName(); if ($langcode != $default_langcode) { $node->addTranslation($langcode, array('title' => $this->values[$i][$langcode])); } else { $node->setTitle($this->values[$i][$langcode]); } $node->save(); } } }
protected function setUp($import_test_views = TRUE) { parent::setUp($import_test_views); ViewTestData::createTestViews(get_class($this), ['comment_test_views']); $this->installEntitySchema('user'); $this->installEntitySchema('comment'); $this->installConfig(['user']); $entity_manager = $this->container->get('entity.manager'); $this->commentStorage = $entity_manager->getStorage('comment'); $this->userStorage = $entity_manager->getStorage('user'); // Insert a row for the anonymous user. $this->userStorage->create(['uid' => 0, 'name' => '', 'status' => 0])->save(); $admin_role = Role::create(['id' => 'admin']); $admin_role->grantPermission('administer comments'); $admin_role->save(); /* @var \Drupal\user\RoleInterface $anonymous_role */ $anonymous_role = Role::load(Role::ANONYMOUS_ID); $anonymous_role->grantPermission('access comments'); $anonymous_role->save(); $this->adminUser = $this->userStorage->create(['name' => $this->randomMachineName()]); $this->adminUser->addRole('admin'); $this->adminUser->save(); }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); $this->installEntitySchema('entity_test'); $this->installEntitySchema('user'); $this->installEntitySchema('entity_test_rev'); // Bypass any field access. $this->adminUser = User::create(['name' => $this->randomString()]); $this->adminUser->save(); $this->container->get('current_user')->setAccount($this->adminUser); $this->testUsers = []; for ($i = 0; $i < 5; $i++) { $this->testUsers[$i] = User::create(['name' => 'test ' . $i, 'timezone' => User::getAllowedTimezones()[$i]]); $this->testUsers[$i]->save(); } // Setup a field storage and field, but also change the views data for the // entity_test entity type. $field_storage = FieldStorageConfig::create(['field_name' => 'field_test', 'type' => 'integer', 'entity_type' => 'entity_test']); $field_storage->save(); $field = FieldConfig::create(['field_name' => 'field_test', 'entity_type' => 'entity_test', 'bundle' => 'entity_test']); $field->save(); $field_storage_multiple = FieldStorageConfig::create(['field_name' => 'field_test_multiple', 'type' => 'integer', 'entity_type' => 'entity_test', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED]); $field_storage_multiple->save(); $field_multiple = FieldConfig::create(['field_name' => 'field_test_multiple', 'entity_type' => 'entity_test', 'bundle' => 'entity_test']); $field_multiple->save(); $random_number = (string) 30856; $random_number_multiple = (string) 1370359990; for ($i = 0; $i < 5; $i++) { $this->entities[$i] = $entity = EntityTest::create(['bundle' => 'entity_test', 'name' => 'test ' . $i, 'field_test' => $random_number[$i], 'field_test_multiple' => [$random_number_multiple[$i * 2], $random_number_multiple[$i * 2 + 1]], 'user_id' => $this->testUsers[$i]->id()]); $entity->save(); } // Setup some test data for entities with revisions. // We are testing both base field revisions and field config revisions. $field_storage = FieldStorageConfig::create(['field_name' => 'field_test', 'type' => 'integer', 'entity_type' => 'entity_test_rev']); $field_storage->save(); $field = FieldConfig::create(['field_name' => 'field_test', 'entity_type' => 'entity_test_rev', 'bundle' => 'entity_test_rev']); $field->save(); $field_storage_multiple = FieldStorageConfig::create(['field_name' => 'field_test_multiple', 'type' => 'integer', 'entity_type' => 'entity_test_rev', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED]); $field_storage_multiple->save(); $field_multiple = FieldConfig::create(['field_name' => 'field_test_multiple', 'entity_type' => 'entity_test_rev', 'bundle' => 'entity_test_rev']); $field_multiple->save(); $this->entityRevision = []; $this->entityRevision[0] = $entity = EntityTestRev::create(['name' => 'base value', 'field_test' => 1, 'field_test_multiple' => [1, 3, 7], 'user_id' => $this->testUsers[0]->id()]); $entity->save(); $original_entity = clone $entity; $entity = clone $original_entity; $entity->setNewRevision(TRUE); $entity->name->value = 'revision value1'; $entity->field_test->value = 2; $entity->field_test_multiple[0]->value = 0; $entity->field_test_multiple[1]->value = 3; $entity->field_test_multiple[2]->value = 5; $entity->user_id->target_id = $this->testUsers[1]->id(); $entity->save(); $this->entityRevision[1] = $entity; $entity = clone $original_entity; $entity->setNewRevision(TRUE); $entity->name->value = 'revision value2'; $entity->field_test->value = 3; $entity->field_test_multiple[0]->value = 9; $entity->field_test_multiple[1]->value = 9; $entity->field_test_multiple[2]->value = 9; $entity->user_id->target_id = $this->testUsers[2]->id(); $entity->save(); $this->entityRevision[2] = $entity; $this->entityRevision[3] = $entity = EntityTestRev::create(['name' => 'next entity value', 'field_test' => 4, 'field_test_multiple' => [2, 9, 9], 'user_id' => $this->testUsers[3]->id()]); $entity->save(); \Drupal::state()->set('entity_test.views_data', ['entity_test' => ['id' => ['field' => ['id' => 'field']]], 'entity_test_rev_revision' => ['id' => ['field' => ['id' => 'field']]]]); Views::viewsData()->clear(); }
protected function setUp() { parent::setUp(); $this->moduleHandler = $this->container->get('module_handler'); }
protected function setUp() { parent::setUp(); $this->installEntitySchema('user'); }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); // Setup the needed tables in order to make the drupal router working. $this->installSchema('system', array('url_alias')); }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); }
protected function setUp() { parent::setUp(); $this->installSchema('system', array('key_value_expire')); }
protected function setUp() { parent::setUp(); $this->installConfig(array('system', 'filter')); $this->installEntitySchema('user'); }
protected function setUp() { parent::setUp(); $this->installConfig(array('language')); $this->wizard = $this->container->get('plugin.manager.views.wizard')->createInstance('standard:views_test_data', array()); }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); ViewTestData::createTestViews(get_class($this), array('block_test_views')); }
protected function setUp() { parent::setUp(); $this->definitions = Views::getPluginDefinitions(); }