本文整理汇总了PHP中Drupal\node\Tests\NodeTestBase类的典型用法代码示例。如果您正苦于以下问题:PHP NodeTestBase类的具体用法?PHP NodeTestBase怎么用?PHP NodeTestBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NodeTestBase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
parent::setUp();
node_access_test_add_field(NodeType::load('article'));
node_access_rebuild();
\Drupal::state()->set('node_access_test.private', TRUE);
}
开发者ID:nstielau,项目名称:drops-8,代码行数:7,代码来源:NodeAccessBaseTableTest.php
示例2: setUp
/**
* {@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);
}
开发者ID:nB-MDSO,项目名称:mdso-d8blog,代码行数:10,代码来源:SharethisBlockTest.php
示例3: setUp
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();
}
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:7,代码来源:NodeAccessMenuLinkTest.php
示例4: setUp
/**
* {@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;
}
开发者ID:nsp15,项目名称:Drupal8,代码行数:38,代码来源:NodeRevisionsTest.php
示例5: setUp
/**
* {@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();
}
开发者ID:eigentor,项目名称:tommiblog,代码行数:10,代码来源:NodeAccessRebuildNodeGrantsTest.php
示例6: setUp
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;
}
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:31,代码来源:NodeRevisionsTest.php
示例7: setUp
/**
* {@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);
}
开发者ID:nstielau,项目名称:drops-8,代码行数:10,代码来源:NodeRevisionsUiTest.php
示例8: setUp
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();
}
开发者ID:ddrozdik,项目名称:dmaps,代码行数:29,代码来源:PagePreviewTest.php
示例9: setUp
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'));
}
开发者ID:nstielau,项目名称:drops-8,代码行数:7,代码来源:NodeBlockFunctionalTest.php
示例10: setUp
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;
}
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:8,代码来源:NodeSaveTest.php
示例11: setUp
/**
* {@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');
}
开发者ID:318io,项目名称:318-io,代码行数:11,代码来源:NodeTitleTest.php
示例12: setUp
/**
* {@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);
}
开发者ID:nB-MDSO,项目名称:mdso-d8blog,代码行数:11,代码来源:SharethisConfigFormTest.php
示例13: setUp
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');
}
开发者ID:ddrozdik,项目名称:dmaps,代码行数:8,代码来源:NodeEditFormTest.php
示例14: setUp
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);
}
开发者ID:eigentor,项目名称:tommiblog,代码行数:9,代码来源:NodeRSSContentTest.php
示例15: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
node_access_rebuild();
// Create some content.
$this->drupalCreateNode();
$this->drupalCreateNode();
$this->drupalCreateNode();
$this->drupalCreateNode();
}
开发者ID:ddrozdik,项目名称:dmaps,代码行数:13,代码来源:NodeAccessAutoBubblingTest.php
示例16: setUp
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']);
}
开发者ID:eigentor,项目名称:tommiblog,代码行数:12,代码来源:NodeAdminTest.php
示例17: setUp
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));
}
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:52,代码来源:NodeAccessLanguageAwareTest.php
示例18: setUp
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();
}
开发者ID:eigentor,项目名称:tommiblog,代码行数:13,代码来源:NodeAccessLanguageTest.php
示例19: setUp
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))));
}
开发者ID:anatalsceo,项目名称:en-classe,代码行数:50,代码来源:NodeAccessLanguageAwareTest.php
示例20: setUp
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();
}
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:14,代码来源:NodeAccessFieldTest.php
注:本文中的Drupal\node\Tests\NodeTestBase类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论