作者:nstiela
项目:drops-
protected function setUp()
{
parent::setUp();
node_access_test_add_field(NodeType::load('article'));
node_access_rebuild();
\Drupal::state()->set('node_access_test.private', TRUE);
}
作者:nB-MDS
项目:mdso-d8blo
/**
* {@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);
}
作者:aWEBoLab
项目:tax
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();
}
作者:nsp1
项目:Drupal
/**
* {@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;
}
作者:eigento
项目:tommiblo
/**
* {@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();
}
作者:Nikola-xii
项目:d8intrane
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;
}
作者:nstiela
项目:drops-
/**
* {@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);
}
作者:ddrozdi
项目:dmap
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();
}
作者:nstiela
项目:drops-
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'));
}
作者:aWEBoLab
项目:tax
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;
}
作者:318i
项目:318-i
/**
* {@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');
}
作者:nB-MDS
项目:mdso-d8blo
/**
* {@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);
}
作者:ddrozdi
项目:dmap
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');
}
作者:eigento
项目:tommiblo
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);
}
作者:ddrozdi
项目:dmap
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
node_access_rebuild();
// Create some content.
$this->drupalCreateNode();
$this->drupalCreateNode();
$this->drupalCreateNode();
$this->drupalCreateNode();
}
作者:eigento
项目:tommiblo
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']);
}
作者:soj
项目:d8_friendsofsilenc
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));
}
作者:eigento
项目:tommiblo
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();
}
作者:anatalsce
项目:en-class
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))));
}
作者:aWEBoLab
项目:tax
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();
}