protected function setUp() { parent::setUp(); $this->enableViewsTestModule(); // Add an admin user will full rights; $this->admin = $this->drupalCreateUser(array('administer views')); }
protected function setUp() { parent::setUp(); // Ensure the page node type exists. NodeType::create(['type' => 'page', 'name' => 'page'])->save(); ViewTestData::createTestViews(get_class($this), array('field_test_views')); }
/** * {@inheritdoc} */ protected function setUp($import_test_views = TRUE) { parent::setUp(FALSE); $this->drupalCreateContentType(array('type' => 'page')); $this->addDefaultCommentField('node', 'page'); ViewTestData::createTestViews(get_class($this), array('views_test_config')); }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); // Create users. $this->bookAuthor = $this->drupalCreateUser(array('create new books', 'create book content', 'edit own book content', 'add content to books')); ViewTestData::createTestViews(get_class($this), array('book_test_views')); }
protected function setUp($import_test_views = TRUE) { parent::setUp($import_test_views); if ($import_test_views) { ViewTestData::createTestViews(get_class($this), array('node_test_views')); } }
protected function setUp($import_test_views = TRUE) { parent::setUp($import_test_views); if ($import_test_views) { ViewTestData::createTestViews(get_class($this), ['multiversion_test_views']); } }
protected function setUp() { parent::setUp(); // Create and log in a user with administer views permission. $views_admin = $this->drupalCreateUser(array('administer views', 'administer blocks', 'bypass node access', 'access user profiles', 'view all revisions')); $this->drupalLogin($views_admin); }
function setUp() { parent::setUp(); // Add two new languages. ConfigurableLanguage::createFromLangcode('fr')->save(); ConfigurableLanguage::createFromLangcode('es')->save(); // Set up term names. $this->termNames = array('en' => 'Food in Paris', 'es' => 'Comida en Paris', 'fr' => 'Nouriture en Paris'); // Create a vocabulary. $this->vocabulary = Vocabulary::create(['name' => 'Views testing tags', 'vid' => 'views_testing_tags']); $this->vocabulary->save(); // Add a translatable field to the vocabulary. $field = FieldStorageConfig::create(array('field_name' => 'field_foo', 'entity_type' => 'taxonomy_term', 'type' => 'text')); $field->save(); FieldConfig::create(['field_name' => 'field_foo', 'entity_type' => 'taxonomy_term', 'label' => 'Foo', 'bundle' => 'views_testing_tags'])->save(); // Create term with translations. $taxonomy = $this->createTermWithProperties(array('name' => $this->termNames['en'], 'langcode' => 'en', 'description' => $this->termNames['en'], 'field_foo' => $this->termNames['en'])); foreach (array('es', 'fr') as $langcode) { $translation = $taxonomy->addTranslation($langcode, array('name' => $this->termNames[$langcode])); $translation->description->value = $this->termNames[$langcode]; $translation->field_foo->value = $this->termNames[$langcode]; } $taxonomy->save(); Views::viewsData()->clear(); ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views')); $this->container->get('router.builder')->rebuild(); }
protected function setUp() { parent::setUp(); // Create a new content type $content_type = $this->drupalCreateContentType(); // Add a node of the new content type. $node_data = array('type' => $content_type->id()); $this->addDefaultCommentField('node', $content_type->id()); $this->node = $this->drupalCreateNode($node_data); // Force a flush of the in-memory storage. $this->container->get('views.views_data')->clear(); // Create some comments and attach them to the created node. for ($i = 0; $i < $this->masterDisplayResults; $i++) { /** @var \Drupal\comment\CommentInterface $comment */ $comment = Comment::create(array('status' => CommentInterface::PUBLISHED, 'field_name' => 'comment', 'entity_type' => 'node', 'entity_id' => $this->node->id())); $comment->setOwnerId(0); $comment->setSubject('Test comment ' . $i); $comment->comment_body->value = 'Test body ' . $i; $comment->comment_body->format = 'full_html'; // Ensure comments are sorted in ascending order. $time = REQUEST_TIME + ($this->masterDisplayResults - $i); $comment->setCreatedTime($time); $comment->changed->value = $time; $comment->save(); } // Store all the nodes just created to access their properties on the tests. $this->commentsCreated = Comment::loadMultiple(); // Sort created comments in descending order. ksort($this->commentsCreated, SORT_NUMERIC); }
protected function setUp() { parent::setUp(); // Create Basic page node type. $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); $this->vocabulary = entity_create('taxonomy_vocabulary', array('name' => $this->randomMachineName(), 'description' => $this->randomMachineName(), 'vid' => drupal_strtolower($this->randomMachineName()), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'help' => '', 'nodes' => array('page' => 'page'), 'weight' => mt_rand(0, 10))); $this->vocabulary->save(); // Setup a field and instance. $this->field_name = drupal_strtolower($this->randomMachineName()); entity_create('field_storage_config', array('name' => $this->field_name, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', 'settings' => array('allowed_values' => array(array('vocabulary' => $this->vocabulary->id(), 'parent' => '0')))))->save(); entity_create('field_instance_config', array('field_name' => $this->field_name, 'entity_type' => 'node', 'bundle' => 'page'))->save(); // Create a time in the past for the archive. $time = REQUEST_TIME - 3600; $this->container->get('comment.manager')->addDefaultField('node', 'page'); $this->container->get('views.views_data')->clear(); for ($i = 0; $i <= 10; $i++) { $user = $this->drupalCreateUser(); $term = $this->createTerm($this->vocabulary); $values = array('created' => $time, 'type' => 'page'); $values[$this->field_name][]['target_id'] = $term->id(); // Make every other node promoted. if ($i % 2) { $values['promote'] = TRUE; } $values['body'][]['value'] = l('Node ' . 1, 'node/' . 1); $node = $this->drupalCreateNode($values); $comment = array('uid' => $user->id(), 'status' => CommentInterface::PUBLISHED, 'entity_id' => $node->id(), 'entity_type' => 'node', 'field_name' => 'comment'); entity_create('comment', $comment)->save(); } // Some views, such as the "Who's Online" view, only return results if at // least one user is logged in. $account = $this->drupalCreateUser(array()); $this->drupalLogin($account); }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); $this->enableViewsTestModule(); $this->adminUser = $this->drupalCreateUser(['administer views', 'administer menu']); $this->drupalPlaceBlock('system_menu_block:main'); $this->drupalCreateContentType(['type' => 'page']); }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); // Create and login user. $this->privileged_user = $this->drupalCreateUser(array('administer site configuration', 'access administration pages')); $this->drupalLogin($this->privileged_user); ViewTestData::createTestViews(get_class($this), array('sharethis_test_views')); }
protected function setUp() { parent::setUp(); // Create the user profile field and instance. entity_create('field_storage_config', array('entity_type' => 'user', 'field_name' => 'user_file', 'type' => 'file', 'translatable' => '0'))->save(); entity_create('field_config', array('label' => 'User File', 'description' => '', 'field_name' => 'user_file', 'entity_type' => 'user', 'bundle' => 'user', 'required' => 0))->save(); ViewTestData::createTestViews(get_class($this), array('file_test_views')); }
protected function setUp() { parent::setUp(); $this->enableViewsTestModule(); // Set up a render array to use. We need to copy this as drupal_render // passes by reference. $this->render = array('view' => array('#type' => 'view', '#name' => 'test_view_embed', '#display_id' => 'default', '#arguments' => array(25), '#embed' => FALSE)); }
protected function setUp() { parent::setUp(); $this->enableViewsTestModule(); $this->adminUser = $this->drupalCreateUser(array('administer views')); $this->fullAdminUser = $this->drupalCreateUser(array('administer views', 'administer blocks', 'bypass node access', 'access user profiles', 'view all revisions')); $this->drupalLogin($this->fullAdminUser); }
protected function setUp() { parent::setUp(); // Create the user profile field and instance. FieldStorageConfig::create(array('entity_type' => 'user', 'field_name' => 'user_picture', 'type' => 'image', 'translatable' => '0'))->save(); FieldConfig::create(['label' => 'User Picture', 'description' => '', 'field_name' => 'user_picture', 'entity_type' => 'user', 'bundle' => 'user', 'required' => 0])->save(); ViewTestData::createTestViews(get_class($this), array('image_test_views')); }
protected function setUp() { parent::setUp(); $this->fieldStorage = FieldStorageConfig::create(array('field_name' => strtolower($this->randomMachineName()), 'entity_type' => 'contact_message', 'type' => 'text')); $this->fieldStorage->save(); ContactForm::create(['id' => 'contact_message', 'label' => 'Test contact form'])->save(); FieldConfig::create(['field_storage' => $this->fieldStorage, 'bundle' => 'contact_message'])->save(); $this->container->get('views.views_data')->clear(); }
protected function setUp() { parent::setUp(); $this->drupalCreateContentType(array('type' => 'article')); // Create some random nodes. for ($i = 0; $i < 5; $i++) { $this->drupalCreateNode(array('type' => 'article')); } }
protected function setUp() { parent::setUp(); // Create the vocabulary for the tag field. $this->vocabulary = entity_create('taxonomy_vocabulary', array('name' => 'Views testing tags', 'vid' => 'views_testing_tags')); $this->vocabulary->save(); $this->term1 = $this->createTerm('term'); $this->term2 = $this->createTerm('another'); }
protected function setUp() { parent::setUp(); $this->field_storage = entity_create('field_storage_config', array('name' => strtolower($this->randomMachineName()), 'entity_type' => 'contact_message', 'type' => 'text')); $this->field_storage->save(); entity_create('contact_category', array('id' => 'contact_message', 'label' => 'Test contact category'))->save(); entity_create('field_instance_config', array('field_storage' => $this->field_storage, 'bundle' => 'contact_message'))->save(); $this->container->get('views.views_data')->clear(); }
protected function setUp() { parent::setUp(); ViewTestData::createTestViews(get_class($this), array('user_test_views')); $this->users[] = $this->drupalCreateUser(); $this->users[] = User::load(1); $this->nodes[] = $this->drupalCreateNode(array('uid' => $this->users[0]->id())); $this->nodes[] = $this->drupalCreateNode(array('uid' => 1)); }
protected function setUp($import_test_views = TRUE) { parent::setUp($import_test_views); // Ensure the basic bundle exists. This is provided by the standard profile. $this->createBlockContentType(array('id' => 'basic')); $this->adminUser = $this->drupalCreateUser($this->permissions); if ($import_test_views) { ViewTestData::createTestViews(get_class($this), array('block_content_test_views')); } }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); ViewTestData::createTestViews(get_class($this), array('link_test_views')); // Create Basic page node type. $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); // Create a field. FieldStorageConfig::create(array('field_name' => $this->fieldName, 'type' => 'link', 'entity_type' => 'node', 'cardinality' => 1))->save(); FieldConfig::create(array('field_name' => $this->fieldName, 'entity_type' => 'node', 'bundle' => 'page', 'label' => 'link field'))->save(); }
/** * {@inheritdoc} */ protected function setUp($import_test_views = TRUE) { parent::setUp($import_test_views); // Create 5 entities per bundle, to allow a summary overview per bundle. for ($i = 0; $i < 5; $i++) { for ($j = 0; $j < 5; $j++) { $this->entities[] = $entity = EntityTest::create(['name' => 'Entity ' . ($i * 5 + $j), 'type' => 'type' . $i]); $entity->save(); } } }
protected function setUp() { parent::setUp(); $this->enableViewsTestModule(); /** @var \Drupal\taxonomy\Entity\Vocabulary $vocabulary */ $vocabulary = $this->createVocabulary(); for ($i = 0; $i < 10; $i++) { $this->taxonomyTerms[] = $this->createTerm($vocabulary); } }
protected function setUp() { parent::setUp(); ViewTestData::createTestViews(get_class($this), array('statistics_test_views')); // Create a new user for viewing nodes. $this->webUser = $this->drupalCreateUser(array('access content')); $this->node = $this->drupalCreateNode(array('type' => 'page')); // Enable access logging. $this->container->get('config.factory')->get('statistics.settings')->set('access_log.enabled', 1)->set('count_content_views', 1)->save(); $this->drupalLogin($this->webUser); }
protected function setUp() { parent::setUp(); ViewTestData::createTestViews(get_class($this), array('user_test_views')); $this->enableViewsTestModule(); $this->accounts = array(); $this->names = array(); for ($i = 0; $i < 3; $i++) { $this->accounts[] = $account = $this->drupalCreateUser(); $this->names[] = $account->label(); } }
/** * {@inheritdoc} */ protected function setUp($import_test_views = TRUE) { parent::setUp($import_test_views); $node_type = $this->drupalCreateContentType(['type' => 'test_type']); $node = Node::create(['title' => 'test title 1', 'type' => $node_type->id()]); $node->save(); $this->nodes[] = $node; $node = Node::create(['title' => 'test title 2', 'type' => $node_type->id()]); $node->save(); $this->nodes[] = $node; $this->placeBlock('views_block:node_id_argument-block_1', ['region' => 'header']); }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); // Add the geolocation field to the article content type. entity_create('field_storage_config', array('field_name' => 'field_geolocation_test', 'entity_type' => 'node', 'type' => 'geolocation'))->save(); entity_create('field_config', array('field_name' => 'field_geolocation_test', 'label' => 'Geolocation', 'entity_type' => 'node', 'bundle' => 'article'))->save(); entity_get_form_display('node', 'article', 'default')->setComponent('field_geolocation_test', array('type' => 'geolocation_latlng'))->save(); entity_get_display('node', 'article', 'default')->setComponent('field_geolocation_test', array('type' => 'geolocation_latlng', 'weight' => 1))->save(); $this->container->get('views.views_data')->clear(); ViewTestData::createTestViews(get_class($this), ['geolocation_test_views']); }
protected function setUp() { parent::setUp(); // Create Basic page node type. $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); $vocabulary = entity_create('taxonomy_vocabulary', array('name' => $this->randomMachineName(), 'description' => $this->randomMachineName(), 'vid' => Unicode::strtolower($this->randomMachineName()), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'help' => '', 'nodes' => array('page' => 'page'), 'weight' => mt_rand(0, 10))); $vocabulary->save(); // Create a field. $field_name = Unicode::strtolower($this->randomMachineName()); $handler_settings = array('target_bundles' => array($vocabulary->id() => $vocabulary->id()), 'auto_create' => TRUE); $this->createEntityReferenceField('node', 'page', $field_name, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED); // Create a time in the past for the archive. $time = REQUEST_TIME - 3600; $this->addDefaultCommentField('node', 'page'); for ($i = 0; $i <= 10; $i++) { $user = $this->drupalCreateUser(); $term = $this->createTerm($vocabulary); $values = array('created' => $time, 'type' => 'page'); $values[$field_name][]['target_id'] = $term->id(); // Make every other node promoted. if ($i % 2) { $values['promote'] = TRUE; } $values['body'][]['value'] = \Drupal::l('Node ' . 1, new Url('entity.node.canonical', ['node' => 1])); $node = $this->drupalCreateNode($values); $comment = array('uid' => $user->id(), 'status' => CommentInterface::PUBLISHED, 'entity_id' => $node->id(), 'entity_type' => 'node', 'field_name' => 'comment'); entity_create('comment', $comment)->save(); } // Some views, such as the "Who's Online" view, only return results if at // least one user is logged in. $account = $this->drupalCreateUser(array()); $this->drupalLogin($account); }