protected function setUp()
 {
     parent::setUp();
     node_access_test_add_field(NodeType::load('article'));
     node_access_rebuild();
     \Drupal::state()->set('node_access_test.private', TRUE);
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Create and login user.
     $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer site configuration', 'access administration pages', 'administer sharethis', 'administer nodes'));
     $this->drupalLogin($admin_user);
 }
 protected function setUp()
 {
     parent::setUp();
     $this->drupalPlaceBlock('system_menu_block:main');
     $this->contentAdminUser = $this->drupalCreateUser(array('access content', 'administer content types', 'administer menu'));
     $this->config('user.role.' . RoleInterface::ANONYMOUS_ID)->set('permissions', array())->save();
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     ConfigurableLanguage::createFromLangcode('it')->save();
     /** @var \Drupal\content_translation\ContentTranslationManagerInterface $manager */
     $manager = \Drupal::service('content_translation.manager');
     $manager->setEnabled('node', 'article', TRUE);
     // Create and log in user.
     $web_user = $this->drupalCreateUser(array('view page revisions', 'revert page revisions', 'delete page revisions', 'edit any page content', 'delete any page content', 'translate any entity'));
     $this->drupalLogin($web_user);
     // Create initial node.
     $node = $this->drupalCreateNode();
     $settings = get_object_vars($node);
     $settings['revision'] = 1;
     $settings['isDefaultRevision'] = TRUE;
     $nodes = array();
     $logs = array();
     // Get original node.
     $nodes[] = clone $node;
     // Create three revisions.
     $revision_count = 3;
     for ($i = 0; $i < $revision_count; $i++) {
         $logs[] = $node->revision_log = $this->randomMachineName(32);
         // Create revision with a random title and body and update variables.
         $node->title = $this->randomMachineName();
         $node->body = array('value' => $this->randomMachineName(32), 'format' => filter_default_format());
         $node->setNewRevision();
         $node->save();
         $node = Node::load($node->id());
         // Make sure we get revision information.
         $nodes[] = clone $node;
     }
     $this->nodes = $nodes;
     $this->revisionLogs = $logs;
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->adminUser = $this->drupalCreateUser(array('administer site configuration', 'access administration pages', 'access site reports'));
     $this->drupalLogin($this->adminUser);
     $this->webUser = $this->drupalCreateUser();
 }
 protected function setUp()
 {
     parent::setUp();
     // Create and log in user.
     $web_user = $this->drupalCreateUser(array('view page revisions', 'revert page revisions', 'delete page revisions', 'edit any page content', 'delete any page content'));
     $this->drupalLogin($web_user);
     // Create initial node.
     $node = $this->drupalCreateNode();
     $settings = get_object_vars($node);
     $settings['revision'] = 1;
     $settings['isDefaultRevision'] = TRUE;
     $nodes = array();
     $logs = array();
     // Get original node.
     $nodes[] = clone $node;
     // Create three revisions.
     $revision_count = 3;
     for ($i = 0; $i < $revision_count; $i++) {
         $logs[] = $node->revision_log = $this->randomMachineName(32);
         // Create revision with a random title and body and update variables.
         $node->title = $this->randomMachineName();
         $node->body = array('value' => $this->randomMachineName(32), 'format' => filter_default_format());
         $node->setNewRevision();
         $node->save();
         $node = Node::load($node->id());
         // Make sure we get revision information.
         $nodes[] = clone $node;
     }
     $this->nodes = $nodes;
     $this->revisionLogs = $logs;
 }
Example #7
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Create and log in user.
     $web_user = $this->drupalCreateUser(array('administer nodes', 'edit any page content'));
     $this->drupalLogin($web_user);
 }
Example #8
0
 protected function setUp()
 {
     parent::setUp();
     $this->addDefaultCommentField('node', 'page');
     $web_user = $this->drupalCreateUser(array('edit own page content', 'create page content'));
     $this->drupalLogin($web_user);
     // Add a vocabulary so we can test different view modes.
     $vocabulary = entity_create('taxonomy_vocabulary', array('name' => $this->randomMachineName(), 'description' => $this->randomMachineName(), 'vid' => $this->randomMachineName(), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'help' => ''));
     $vocabulary->save();
     $this->vocabulary = $vocabulary;
     // Add a term to the vocabulary.
     $term = entity_create('taxonomy_term', array('name' => $this->randomMachineName(), 'description' => $this->randomMachineName(), 'vid' => $this->vocabulary->id(), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
     $term->save();
     $this->term = $term;
     // Create an image field.
     FieldStorageConfig::create(['field_name' => 'field_image', 'entity_type' => 'node', 'type' => 'image', 'settings' => [], 'cardinality' => FieldStorageConfig::CARDINALITY_UNLIMITED])->save();
     $field_config = FieldConfig::create(['field_name' => 'field_image', 'label' => 'Images', 'entity_type' => 'node', 'bundle' => 'page', 'required' => FALSE, 'settings' => []]);
     $field_config->save();
     // Create a field.
     $this->fieldName = Unicode::strtolower($this->randomMachineName());
     $handler_settings = array('target_bundles' => array($this->vocabulary->id() => $this->vocabulary->id()), 'auto_create' => TRUE);
     $this->createEntityReferenceField('node', 'page', $this->fieldName, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
     entity_get_form_display('node', 'page', 'default')->setComponent($this->fieldName, array('type' => 'entity_reference_autocomplete_tags'))->save();
     // Show on default display and teaser.
     entity_get_display('node', 'page', 'default')->setComponent($this->fieldName, array('type' => 'entity_reference_label'))->save();
     entity_get_display('node', 'page', 'teaser')->setComponent($this->fieldName, array('type' => 'entity_reference_label'))->save();
     entity_get_form_display('node', 'page', 'default')->setComponent('field_image', array('type' => 'image_image', 'settings' => []))->save();
     entity_get_display('node', 'page', 'default')->setComponent('field_image')->save();
 }
 protected function setUp()
 {
     parent::setUp();
     // Create users and test node.
     $this->adminUser = $this->drupalCreateUser(array('administer content types', 'administer nodes', 'administer blocks', 'access content overview'));
     $this->webUser = $this->drupalCreateUser(array('access content', 'create article content'));
 }
Example #10
0
 protected function setUp()
 {
     parent::setUp();
     // Create a user that is allowed to post; we'll use this to test the submission.
     $web_user = $this->drupalCreateUser(array('create article content'));
     $this->drupalLogin($web_user);
     $this->webUser = $web_user;
 }
Example #11
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->drupalPlaceBlock('system_breadcrumb_block');
     $this->adminUser = $this->drupalCreateUser(array('administer nodes', 'create article content', 'create page content', 'post comments'));
     $this->drupalLogin($this->adminUser);
     $this->addDefaultCommentField('node', 'page');
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->config = \Drupal::configFactory()->getEditable('sharethis.settings');
     // Create and log in admin user.
     $this->adminUser = $this->drupalCreateUser(['administer sharethis', 'administer nodes']);
     $this->drupalLogin($this->adminUser);
 }
Example #13
0
 protected function setUp()
 {
     parent::setUp();
     $this->webUser = $this->drupalCreateUser(array('edit own page content', 'create page content'));
     $this->adminUser = $this->drupalCreateUser(array('bypass node access', 'administer nodes'));
     $this->drupalPlaceBlock('local_tasks_block');
     $this->nodeStorage = $this->container->get('entity.manager')->getStorage('node');
 }
Example #14
0
 protected function setUp()
 {
     parent::setUp();
     // Use bypass node access permission here, because the test class uses
     // hook_grants_alter() to deny access to everyone on node_access
     // queries.
     $user = $this->drupalCreateUser(array('bypass node access', 'access content', 'create article content'));
     $this->drupalLogin($user);
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     node_access_rebuild();
     // Create some content.
     $this->drupalCreateNode();
     $this->drupalCreateNode();
     $this->drupalCreateNode();
     $this->drupalCreateNode();
 }
Example #16
0
 protected function setUp()
 {
     parent::setUp();
     // Remove the "view own unpublished content" permission which is set
     // by default for authenticated users so we can test this permission
     // correctly.
     user_role_revoke_permissions(RoleInterface::AUTHENTICATED_ID, array('view own unpublished content'));
     $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'access content overview', 'administer nodes', 'bypass node access'));
     $this->baseUser1 = $this->drupalCreateUser(['access content overview']);
     $this->baseUser2 = $this->drupalCreateUser(['access content overview', 'view own unpublished content']);
     $this->baseUser3 = $this->drupalCreateUser(['access content overview', 'bypass node access']);
 }
 protected function setUp()
 {
     parent::setUp();
     // Create the 'private' field, which allows the node to be marked as private
     // (restricted access) in a given translation.
     $field_storage = FieldStorageConfig::create(array('field_name' => 'field_private', 'entity_type' => 'node', 'type' => 'boolean', 'cardinality' => 1));
     $field_storage->save();
     FieldConfig::create(['field_storage' => $field_storage, 'bundle' => 'page', 'widget' => array('type' => 'options_buttons'), 'settings' => array('on_label' => 'Private', 'off_label' => 'Not private')])->save();
     // After enabling a node access module, the access table has to be rebuild.
     node_access_rebuild();
     // Create a normal authenticated user.
     $this->webUser = $this->drupalCreateUser(array('access content'));
     // Load the user 1 user for later use as an admin user with permission to
     // see everything.
     $this->adminUser = User::load(1);
     // Add Hungarian and Catalan.
     ConfigurableLanguage::createFromLangcode('hu')->save();
     ConfigurableLanguage::createFromLangcode('ca')->save();
     // The node_access_test_language module allows individual translations of a
     // node to be marked private (not viewable by normal users).
     // Create six nodes:
     // 1. Four Hungarian nodes with Catalan translations
     //   - One with neither language marked as private.
     //   - One with only the Hungarian translation private.
     //   - One with only the Catalan translation private.
     //   - One with both the Hungarian and Catalan translations private.
     // 2. Two nodes with no language specified.
     //   - One public.
     //   - One private.
     $this->nodes['both_public'] = $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'field_private' => array(array('value' => 0))));
     $translation = $node->addTranslation('ca');
     $translation->title->value = $this->randomString();
     $translation->field_private->value = 0;
     $node->save();
     $this->nodes['ca_private'] = $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'field_private' => array(array('value' => 0))));
     $translation = $node->addTranslation('ca');
     $translation->title->value = $this->randomString();
     $translation->field_private->value = 1;
     $node->save();
     $this->nodes['hu_private'] = $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'field_private' => array(array('value' => 1))));
     $translation = $node->addTranslation('ca');
     $translation->title->value = $this->randomString();
     $translation->field_private->value = 0;
     $node->save();
     $this->nodes['both_private'] = $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'field_private' => array(array('value' => 1))));
     $translation = $node->addTranslation('ca');
     $translation->title->value = $this->randomString();
     $translation->field_private->value = 1;
     $node->save();
     $this->nodes['no_language_public'] = $this->drupalCreateNode(array('field_private' => array(array('value' => 0)), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
     $this->nodes['no_language_private'] = $this->drupalCreateNode(array('field_private' => array(array('value' => 1)), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
 }
 protected function setUp()
 {
     parent::setUp();
     node_access_test_add_field(NodeType::load('page'));
     // After enabling a node access module, the access table has to be rebuild.
     node_access_rebuild();
     // Enable the private node feature of the node_access_test module.
     \Drupal::state()->set('node_access_test.private', TRUE);
     // Add Hungarian, Catalan and Croatian.
     ConfigurableLanguage::createFromLangcode('hu')->save();
     ConfigurableLanguage::createFromLangcode('ca')->save();
     ConfigurableLanguage::createFromLangcode('hr')->save();
 }
 public function setUp()
 {
     parent::setUp();
     // Create the 'private' field, which allows the node to be marked as private
     // (restricted access) in a given translation.
     $field_storage = entity_create('field_storage_config', array('name' => 'field_private', 'entity_type' => 'node', 'type' => 'boolean', 'cardinality' => 1, 'translatable' => TRUE, 'settings' => array('on_label' => 'Private', 'off_label' => 'Not private')));
     $field_storage->save();
     entity_create('field_instance_config', array('field_storage' => $field_storage, 'bundle' => 'page', 'widget' => array('type' => 'options_buttons')))->save();
     // After enabling a node access module, the access table has to be rebuild.
     node_access_rebuild();
     // Create a normal authenticated user.
     $this->web_user = $this->drupalCreateUser(array('access content'));
     // Load the user 1 user for later use as an admin user with permission to
     // see everything.
     $this->admin_user = user_load(1);
     // Add Hungarian and Catalan.
     $language = new Language(array('id' => 'hu'));
     language_save($language);
     $language = new Language(array('id' => 'ca'));
     language_save($language);
     // The node_access_test_language module allows individual translations of a
     // node to be marked private (not viewable by normal users).
     // Create six nodes:
     // 1. Four Hungarian nodes with Catalan translations
     //   - One with neither language marked as private.
     //   - One with only the Hungarian translation private.
     //   - One with only the Catalan translation private.
     //   - One with both the Hungarian and Catalan translations private.
     // 2. Two nodes with no language specified.
     //   - One public.
     //   - One private.
     $this->nodes['both_public'] = $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'field_private' => array(array('value' => 0))));
     $translation = $node->getTranslation('ca');
     $translation->field_private[0]->value = 0;
     $node->save();
     $this->nodes['ca_private'] = $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'field_private' => array(array('value' => 0))));
     $translation = $node->getTranslation('ca');
     $translation->field_private[0]->value = 1;
     $node->save();
     $this->nodes['hu_private'] = $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'field_private' => array(array('value' => 1))));
     $translation = $node->getTranslation('ca');
     $translation->field_private[0]->value = 0;
     $node->save();
     $this->nodes['both_private'] = $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'field_private' => array(array('value' => 1))));
     $translation = $node->getTranslation('ca');
     $translation->field_private[0]->value = 1;
     $node->save();
     $this->nodes['no_language_public'] = $this->drupalCreateNode(array('field_private' => array(array('value' => 0))));
     $this->nodes['no_language_private'] = $this->drupalCreateNode(array('field_private' => array(array('value' => 1))));
 }
Example #20
0
 protected function setUp()
 {
     parent::setUp();
     node_access_rebuild();
     // Create some users.
     $this->adminUser = $this->drupalCreateUser(array('access content', 'bypass node access'));
     $this->contentAdminUser = $this->drupalCreateUser(array('access content', 'administer content types', 'administer node fields'));
     // Add a custom field to the page content type.
     $this->fieldName = Unicode::strtolower($this->randomMachineName() . '_field_name');
     FieldStorageConfig::create(array('field_name' => $this->fieldName, 'entity_type' => 'node', 'type' => 'text'))->save();
     FieldConfig::create(['field_name' => $this->fieldName, 'entity_type' => 'node', 'bundle' => 'page'])->save();
     entity_get_display('node', 'page', 'default')->setComponent($this->fieldName)->save();
     entity_get_form_display('node', 'page', 'default')->setComponent($this->fieldName)->save();
 }
Example #21
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Enable additional languages.
     ConfigurableLanguage::createFromLangcode('de')->save();
     ConfigurableLanguage::createFromLangcode('it')->save();
     $field_storage_definition = array('field_name' => 'untranslatable_string_field', 'entity_type' => 'node', 'type' => 'string', 'cardinality' => 1, 'translatable' => FALSE);
     $field_storage = FieldStorageConfig::create($field_storage_definition);
     $field_storage->save();
     $field_definition = array('field_storage' => $field_storage, 'bundle' => 'page');
     $field = FieldConfig::create($field_definition);
     $field->save();
     // Create and log in user.
     $web_user = $this->drupalCreateUser(array('view page revisions', 'revert page revisions', 'delete page revisions', 'edit any page content', 'delete any page content', 'access contextual links', 'translate any entity', 'administer content types'));
     $this->drupalLogin($web_user);
     // Create initial node.
     $node = $this->drupalCreateNode();
     $settings = get_object_vars($node);
     $settings['revision'] = 1;
     $settings['isDefaultRevision'] = TRUE;
     $nodes = array();
     $logs = array();
     // Get original node.
     $nodes[] = clone $node;
     // Create three revisions.
     $revision_count = 3;
     for ($i = 0; $i < $revision_count; $i++) {
         $logs[] = $node->revision_log = $this->randomMachineName(32);
         // Create revision with a random title and body and update variables.
         $node->title = $this->randomMachineName();
         $node->body = array('value' => $this->randomMachineName(32), 'format' => filter_default_format());
         $node->untranslatable_string_field->value = $this->randomString();
         $node->setNewRevision();
         // Edit the 2nd revision with a different user.
         if ($i == 1) {
             $editor = $this->drupalCreateUser();
             $node->setRevisionUserId($editor->id());
         } else {
             $node->setRevisionUserId($web_user->id());
         }
         $node->save();
         $node = Node::load($node->id());
         // Make sure we get revision information.
         $nodes[] = clone $node;
     }
     $this->nodes = $nodes;
     $this->revisionLogs = $logs;
 }
 function setUp()
 {
     parent::setUp();
     node_access_test_add_field(entity_load('node_type', 'page'));
     // After enabling a node access module, the access table has to be rebuild.
     node_access_rebuild();
     // Enable the private node feature of the node_access_test module.
     \Drupal::state()->set('node_access_test.private', TRUE);
     // Add Hungarian and Catalan.
     $language = new Language(array('id' => 'hu'));
     language_save($language);
     $language = new Language(array('id' => 'ca'));
     language_save($language);
     $language = new Language(array('id' => 'hr'));
     language_save($language);
 }
 protected function setUp()
 {
     parent::setUp();
     // Enable additional languages.
     $langcodes = ['es', 'ast'];
     foreach ($langcodes as $langcode) {
         ConfigurableLanguage::createFromLangcode($langcode)->save();
     }
     // Enable translation for the current entity type and ensure the change is
     // picked up.
     \Drupal::service('content_translation.manager')->setEnabled('node', 'article', TRUE);
     drupal_static_reset();
     \Drupal::entityManager()->clearCachedDefinitions();
     \Drupal::service('router.builder')->rebuild();
     \Drupal::service('entity.definition_update_manager')->applyUpdates();
     $this->baseUser1 = $this->drupalCreateUser(['access content overview']);
     $this->baseUser2 = $this->drupalCreateUser(['access content overview', 'create content translations', 'update content translations', 'delete content translations']);
 }
Example #24
0
 function setUp()
 {
     parent::setUp();
     $web_user = $this->drupalCreateUser(array('edit own page content', 'create page content'));
     $this->drupalLogin($web_user);
     // Add a vocabulary so we can test different view modes.
     $vocabulary = entity_create('taxonomy_vocabulary', array('name' => $this->randomName(), 'description' => $this->randomName(), 'vid' => $this->randomName(), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'help' => ''));
     $vocabulary->save();
     $this->vocabulary = $vocabulary;
     // Add a term to the vocabulary.
     $term = entity_create('taxonomy_term', array('name' => $this->randomName(), 'description' => $this->randomName(), 'vid' => $this->vocabulary->id(), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
     $term->save();
     $this->term = $term;
     // Set up a field and instance.
     $this->field_name = drupal_strtolower($this->randomName());
     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'))), 'cardinality' => '-1'))->save();
     entity_create('field_instance_config', array('field_name' => $this->field_name, 'entity_type' => 'node', 'bundle' => 'page'))->save();
     entity_get_form_display('node', 'page', 'default')->setComponent($this->field_name, array('type' => 'taxonomy_autocomplete'))->save();
     // Show on default display and teaser.
     entity_get_display('node', 'page', 'default')->setComponent($this->field_name, array('type' => 'taxonomy_term_reference_link'))->save();
     entity_get_display('node', 'page', 'teaser')->setComponent($this->field_name, array('type' => 'taxonomy_term_reference_link'))->save();
 }
 protected function setUp()
 {
     parent::setUp();
     // Create and log in user.
     $web_user = $this->drupalCreateUser(array('view page revisions', 'revert page revisions', 'delete page revisions', 'edit any page content', 'delete any page content'));
     $this->drupalLogin($web_user);
     // Create an initial node.
     $node = $this->drupalCreateNode();
     $settings = get_object_vars($node);
     $settings['revision'] = 1;
     $nodes = array();
     $logs = array();
     // Get the original node.
     $nodes[] = clone $node;
     // Create three revisions.
     $revision_count = 3;
     for ($i = 0; $i < $revision_count; $i++) {
         $logs[] = $node->revision_log = $this->randomMachineName(32);
         $node = $this->createNodeRevision($node);
         $nodes[] = clone $node;
     }
     $this->nodes = $nodes;
     $this->revisionLogs = $logs;
 }
 /**
  * Perform any initial set up tasks that run before every test method.
  */
 public function setUp()
 {
     parent::setUp();
     $user = $this->drupalCreateUser(array('create page content', 'edit own page content', 'view printer friendly versions', 'administer printable'));
     $this->drupalLogin($user);
 }
 protected function setUp()
 {
     parent::setUp();
     $web_user = $this->drupalCreateUser(array('create page content', 'edit own page content'));
     $this->drupalLogin($web_user);
 }
Example #28
0
 protected function setUp()
 {
     parent::setUp();
     rdf_get_mapping('node', 'article')->setBundleMapping(array('types' => array('sioc:Item', 'foaf:Document')))->setFieldMapping('title', array('properties' => array('dc:title')))->setFieldMapping('created', array('properties' => array('dc:date', 'dc:created'), 'datatype' => 'xsd:dateTime', 'datatype_callback' => array('callable' => 'Drupal\\rdf\\CommonDataConverter::dateIso8601Value')))->save();
 }
 protected function setUp()
 {
     parent::setUp();
     node_access_test_add_field(NodeType::load('page'));
     // Create the 'private' field, which allows the node to be marked as private
     // (restricted access) in a given translation.
     $field_storage = entity_create('field_storage_config', array('field_name' => 'field_private', 'entity_type' => 'node', 'type' => 'boolean', 'cardinality' => 1));
     $field_storage->save();
     entity_create('field_config', array('field_storage' => $field_storage, 'bundle' => 'page', 'widget' => array('type' => 'options_buttons'), 'settings' => array('on_label' => 'Private', 'off_label' => 'Not private')))->save();
     // After enabling a node access module, the access table has to be rebuild.
     node_access_rebuild();
     // Add Hungarian and Catalan.
     ConfigurableLanguage::createFromLangcode('hu')->save();
     ConfigurableLanguage::createFromLangcode('ca')->save();
     // Create a normal authenticated user.
     $this->webUser = $this->drupalCreateUser(array('access content'));
     // Load the user 1 user for later use as an admin user with permission to
     // see everything.
     $this->adminUser = User::load(1);
     // The node_access_test_language module allows individual translations of a
     // node to be marked private (not viewable by normal users), and the
     // node_access_test module allows whole nodes to be marked private. (In a
     // real-world implementation, hook_node_access_records_alter() might be
     // implemented by one or both modules to enforce that private nodes or
     // translations are always private, but we want to test the default,
     // additive behavior of node access).
     // Create six Hungarian nodes with Catalan translations:
     // 1. One public with neither language marked as private.
     // 2. One private with neither language marked as private.
     // 3. One public with only the Hungarian translation private.
     // 4. One public with only the Catalan translation private.
     // 5. One public with both the Hungarian and Catalan translations private.
     // 6. One private with both the Hungarian and Catalan translations private.
     $this->nodes['public_both_public'] = $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'field_private' => array(array('value' => 0)), 'private' => FALSE));
     $translation = $node->addTranslation('ca');
     $translation->title->value = $this->randomString();
     $translation->field_private->value = 0;
     $node->save();
     $this->nodes['private_both_public'] = $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'field_private' => array(array('value' => 0)), 'private' => TRUE));
     $translation = $node->addTranslation('ca');
     $translation->title->value = $this->randomString();
     $translation->field_private->value = 0;
     $node->save();
     $this->nodes['public_hu_private'] = $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'field_private' => array(array('value' => 1)), 'private' => FALSE));
     $translation = $node->addTranslation('ca');
     $translation->title->value = $this->randomString();
     $translation->field_private->value = 0;
     $node->save();
     $this->nodes['public_ca_private'] = $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'field_private' => array(array('value' => 0)), 'private' => FALSE));
     $translation = $node->addTranslation('ca');
     $translation->title->value = $this->randomString();
     $translation->field_private->value = 1;
     $node->save();
     $this->nodes['public_both_private'] = $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'field_private' => array(array('value' => 1)), 'private' => FALSE));
     $translation = $node->addTranslation('ca');
     $translation->title->value = $this->randomString();
     $translation->field_private->value = 1;
     $node->save();
     $this->nodes['private_both_private'] = $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'field_private' => array(array('value' => 1)), 'private' => TRUE));
     $translation = $node->addTranslation('ca');
     $translation->title->value = $this->randomString();
     $translation->field_private->value = 1;
     $node->save();
     $this->nodes['public_no_language_private'] = $this->drupalCreateNode(array('field_private' => array(array('value' => 1)), 'private' => FALSE, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
     $this->nodes['public_no_language_public'] = $this->drupalCreateNode(array('field_private' => array(array('value' => 0)), 'private' => FALSE, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
     $this->nodes['private_no_language_private'] = $this->drupalCreateNode(array('field_private' => array(array('value' => 1)), 'private' => TRUE, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
     $this->nodes['private_no_language_public'] = $this->drupalCreateNode(array('field_private' => array(array('value' => 1)), 'private' => TRUE, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
 }
Example #30
0
 protected function setUp()
 {
     parent::setUp();
     // Clear permissions for authenticated users.
     $this->config('user.role.' . RoleInterface::AUTHENTICATED_ID)->set('permissions', array())->save();
 }