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();
 }
Exemplo n.º 2
0
 /**
  * {@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()
 {
     parent::setUp();
     $this->installEntitySchema('user');
     $this->installEntitySchema('entity_test');
     ViewTestData::createTestViews(get_class($this), array('entity_reference_test_views'));
     $field_storage = FieldStorageConfig::create(array('entity_type' => 'entity_test', 'field_name' => 'field_test', 'type' => 'entity_reference', 'settings' => array('target_type' => 'entity_test'), 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED));
     $field_storage->save();
     $field = FieldConfig::create(array('entity_type' => 'entity_test', 'field_name' => 'field_test', 'bundle' => 'entity_test', 'settings' => array('handler' => 'default', 'handler_settings' => array())));
     $field->save();
     // Create some test entities which link each other.
     $entity_storage = \Drupal::entityManager()->getStorage('entity_test');
     $referenced_entity = $entity_storage->create(array());
     $referenced_entity->save();
     $this->entities[$referenced_entity->id()] = $referenced_entity;
     $entity = $entity_storage->create(array());
     $entity->field_test->target_id = $referenced_entity->id();
     $entity->save();
     $this->assertEqual($entity->field_test[0]->entity->id(), $referenced_entity->id());
     $this->entities[$entity->id()] = $entity;
     $entity = $entity_storage->create(array());
     $entity->field_test->target_id = $referenced_entity->id();
     $entity->save();
     $this->assertEqual($entity->field_test[0]->entity->id(), $referenced_entity->id());
     $this->entities[$entity->id()] = $entity;
     Views::viewsData()->clear();
 }
Exemplo n.º 4
0
  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();

    ViewTestData::createTestViews(get_class($this), array('views_test_config'));

    // Create a Content type and some test nodes with titles that start with
    // different letters.
    $this->createContentType(['type' => 'page']);

    $titles = [
      'Page One',
      'Page Two',
      'Another page',
    ];
    foreach ($titles as $title) {
      $this->createNode([
        'title' => $title,
        'language' => 'en',
      ]);
      $this->createNode([
        'title' => $title,
        'language' => 'nl',
      ]);
    }

    // Create a user privileged enough to use exposed filters and view content.
    $user = $this->drupalCreateUser([
      'administer site configuration',
      'access content',
      'access content overview',
    ]);
    $this->drupalLogin($user);
  }
Exemplo n.º 5
0
 /**
  * Returns the views data definition.
  */
 protected function viewsData()
 {
     $data = ViewTestData::viewsData();
     // Tweak the views data to have a base for testing.
     unset($data['views_test_data']['id']['field']);
     unset($data['views_test_data']['name']['argument']);
     unset($data['views_test_data']['age']['filter']);
     unset($data['views_test_data']['job']['sort']);
     $data['views_test_data']['created']['area']['id'] = 'text';
     $data['views_test_data']['age']['area']['id'] = 'text';
     $data['views_test_data']['age']['area']['sub_type'] = 'header';
     $data['views_test_data']['job']['area']['id'] = 'text';
     $data['views_test_data']['job']['area']['sub_type'] = array('header', 'footer');
     // Duplicate the example views test data for different weight, different title,
     // and matching data.
     $data['views_test_data_2'] = $data['views_test_data'];
     $data['views_test_data_2']['table']['base']['weight'] = 50;
     $data['views_test_data_3'] = $data['views_test_data'];
     $data['views_test_data_3']['table']['base']['weight'] = -50;
     $data['views_test_data_4'] = $data['views_test_data'];
     $data['views_test_data_4']['table']['base']['title'] = 'A different title';
     $data['views_test_data_5'] = $data['views_test_data'];
     $data['views_test_data_5']['table']['base']['title'] = 'Z different title';
     $data['views_test_data_6'] = $data['views_test_data'];
     return $data;
 }
Exemplo n.º 6
0
 /**
  * {@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'));
 }
Exemplo n.º 7
0
 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'));
     }
 }
Exemplo n.º 8
0
 /**
  * {@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'));
 }
Exemplo n.º 9
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->enableModules(array('system', 'dblog'));
     $this->installSchema('dblog', array('watchdog'));
     ViewTestData::createTestViews(get_class($this), array('dblog_test_views'));
 }
Exemplo n.º 10
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp(FALSE);
     // Create Page content type.
     if ($this->profile != 'standard') {
         $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
         ViewTestData::createTestViews(get_class($this), array('node_test_views'));
     }
     // Add two new languages.
     ConfigurableLanguage::createFromLangcode('fr')->save();
     ConfigurableLanguage::createFromLangcode('es')->save();
     // Make the body field translatable. The title is already translatable by
     // definition.
     $field_storage = FieldStorageConfig::loadByName('node', 'body');
     $field_storage->setTranslatable(TRUE);
     $field_storage->save();
     // Set up node titles. They should not include the words "French",
     // "English", or "Spanish", as there is a language field in the view
     // that prints out those words.
     $this->node_titles = array('es' => array('Primero nodo es', 'Segundo nodo es', 'Tercera nodo es'), 'en' => array('First node en', 'Second node en'), 'fr' => array('Premier nœud fr'));
     // Create nodes with translations.
     foreach ($this->node_titles['es'] as $index => $title) {
         $node = $this->drupalCreateNode(array('title' => $title, 'langcode' => 'es', 'type' => 'page', 'promote' => 1));
         foreach (array('en', 'fr') as $langcode) {
             if (isset($this->node_titles[$langcode][$index])) {
                 $translation = $node->addTranslation($langcode, array('title' => $this->node_titles[$langcode][$index]));
                 $translation->body->value = $this->randomMachineName(32);
             }
         }
         $node->save();
     }
     $this->container->get('router.builder')->rebuild();
     $user = $this->drupalCreateUser(array('access content overview', 'access content'));
     $this->drupalLogin($user);
 }
Exemplo n.º 11
0
 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'));
 }
Exemplo n.º 12
0
 protected function setUp($import_test_views = TRUE)
 {
     parent::setUp($import_test_views);
     if ($import_test_views) {
         ViewTestData::createTestViews(get_class($this), ['multiversion_test_views']);
     }
 }
Exemplo n.º 13
0
 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('user');
     $this->installEntitySchema('profile');
     $this->installEntitySchema('profile_type');
     ViewTestData::createTestViews(get_class($this), ['profile_test']);
 }
Exemplo n.º 14
0
 /**
  * {@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()
 {
     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'));
 }
Exemplo n.º 17
0
 /**
  * {@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();
     // 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'));
 }
Exemplo n.º 19
0
 protected function setUp()
 {
     parent::setUp();
     // Ensure that the plugin definitions are cleared.
     foreach (ViewExecutable::getPluginTypes() as $plugin_type) {
         $this->container->get("plugin.manager.views.{$plugin_type}")->clearCachedDefinitions();
     }
     ViewTestData::createTestViews(get_class($this), array('ds_test'));
 }
 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');
 }
Exemplo n.º 21
0
 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');
 }
Exemplo n.º 22
0
 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));
 }
Exemplo n.º 23
0
 /**
  * {@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();
 }
 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($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']);
     }
 }
Exemplo n.º 26
0
 protected function setUp()
 {
     parent::setUp();
     ViewTestData::createTestViews(get_class($this), array('rest_test_views'));
     $this->adminUser = $this->drupalCreateUser(array('administer views', 'administer entity_test content', 'access user profiles', 'view test entity'));
     // Save some entity_test entities.
     for ($i = 1; $i <= 10; $i++) {
         EntityTest::create(array('name' => 'test_' . $i, 'user_id' => $this->adminUser->id()))->save();
     }
     $this->enableViewsTestModule();
 }
Exemplo n.º 27
0
 function setUp()
 {
     // @todo Use entity_type once it is has multilingual Views integration.
     $this->entityTypeId = 'user';
     parent::setUp();
     // Assign user 1  a language code so that the entity can be translated.
     $user = user_load(1);
     $user->langcode = 'en';
     $user->save();
     ViewTestData::createTestViews(get_class($this), array('content_translation_test_views'));
 }
Exemplo n.º 28
0
 /**
  * Test multiple deletion.
  */
 public function testBulkDeletion() {
   $this->drupalGet('contact');
   ViewTestData::createTestViews(get_class($this), array('contact_test_views'));
   // Check the operations are accessible to the administer permission user.
   $this->drupalLogin($this->drupalCreateUser(array('administer contact forms')));
   $this->drupalGet('test-contact-message-bulk-form');
   $elements = $this->xpath('//select[@id="edit-action"]//option');
   $this->assertIdentical(count($elements), 1, 'All contact message operations are found.');
   $this->drupalPostForm('test-contact-message-bulk-form', [], t('Apply to selected items'));
   $this->assertText(t('No message selected.'));
 }
Exemplo n.º 29
0
 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);
 }
  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();

    ViewTestData::createTestViews(get_class($this), ['views_test_config']);

    // Disable automatic live preview to make the sequence of calls clearer.
    \Drupal::configFactory()->getEditable('views.settings')->set('ui.show.advanced_column', TRUE)->save();

    $account = $this->drupalCreateUser(['administer views']);
    $this->drupalLogin($account);
  }