• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP node_add_body_field函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中node_add_body_field函数的典型用法代码示例。如果您正苦于以下问题:PHP node_add_body_field函数的具体用法?PHP node_add_body_field怎么用?PHP node_add_body_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了node_add_body_field函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: prepareTranslationSuggestions

 /**
  * Prepare a node to get suggestions from.
  *
  * Creates a node with two file fields. The first one is not translatable,
  * the second one is. Both fields got two files attached, where one has
  * translatable content (title and atl-text) and the other one not.
  *
  * @return object
  *   The node which is prepared with all needed fields for the suggestions.
  */
 protected function prepareTranslationSuggestions()
 {
     // Create a content type with fields.
     // Only the first field is a translatable reference.
     $type = NodeType::create(['type' => $this->randomMachineName()]);
     $type->save();
     $content_translation_manager = \Drupal::service('content_translation.manager');
     $content_translation_manager->setEnabled('node', $type->id(), TRUE);
     $field1 = FieldStorageConfig::create(array('field_name' => 'field1', 'entity_type' => 'node', 'type' => 'entity_reference', 'cardinality' => -1, 'settings' => array('target_type' => 'node')));
     $field1->save();
     $field2 = FieldStorageConfig::create(array('field_name' => 'field2', 'entity_type' => 'node', 'type' => 'entity_reference', 'cardinality' => -1, 'settings' => array('target_type' => 'node')));
     $field2->save();
     // Create field instances on the content type.
     FieldConfig::create(array('field_storage' => $field1, 'bundle' => $type->id(), 'label' => 'Field 1', 'translatable' => FALSE, 'settings' => array()))->save();
     FieldConfig::create(array('field_storage' => $field2, 'bundle' => $type->id(), 'label' => 'Field 2', 'translatable' => TRUE, 'settings' => array()))->save();
     // Create a translatable body field.
     node_add_body_field($type);
     $field = FieldConfig::loadByName('node', $type->id(), 'body');
     $field->setTranslatable(TRUE);
     $field->save();
     // Create 4 nodes to be referenced.
     $references = array();
     for ($i = 0; $i < 4; $i++) {
         $references[$i] = Node::create(array('title' => $this->randomMachineName(), 'body' => $this->randomMachineName(), 'type' => $type->id()));
         $references[$i]->save();
     }
     // Create a node with two translatable and two non-translatable references.
     $node = Node::create(array('title' => $this->randomMachineName(), 'type' => $type->id(), 'language' => 'en', 'body' => $this->randomMachineName(), $field1->getName() => array(array('target_id' => $references[0]->id()), array('target_id' => $references[1]->id())), $field2->getName() => array(array('target_id' => $references[2]->id()), array('target_id' => $references[3]->id()))));
     $node->save();
     $link = MenuLinkContent::create(['link' => [['uri' => 'entity:node/' . $node->id()]], 'title' => 'Node menu link', 'menu_name' => 'main']);
     $link->save();
     $node->link = $link;
     return $node;
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:44,代码来源:ContentEntitySuggestionsTest.php


示例2: setUp

  public function setUp() {
    parent::setup();

    $this->installConfig(array('pathauto', 'taxonomy', 'system', 'node'));

    $this->installEntitySchema('user');
    $this->installEntitySchema('node');
    $this->installEntitySchema('taxonomy_term');

    ConfigurableLanguage::createFromLangcode('fr')->save();

    $this->installSchema('node', array('node_access'));
    $this->installSchema('system', array('url_alias', 'sequences', 'router'));

    $type = NodeType::create(['type' => 'page']);
    $type->save();
    node_add_body_field($type);

    $this->nodePattern = $this->createPattern('node', '/content/[node:title]');
    $this->userPattern = $this->createPattern('user', '/users/[user:name]');

    \Drupal::service('router.builder')->rebuild();

    $this->currentUser = entity_create('user', array('name' => $this->randomMachineName()));
    $this->currentUser->save();
  }
开发者ID:AshishNaik021,项目名称:iimisac-d8,代码行数:26,代码来源:PathautoUnitTest.php


示例3: webformUserCreateType

 /**
  * Create a petition content type and webform user enable it.
  */
 protected function webformUserCreateType()
 {
     $type = node_type_set_defaults();
     $type->name = t('Petition');
     $type->type = 'petition';
     $type->description = t('Webform user petition type.');
     $type->title_label = t('Title');
     $type->has_title = $type->title_label != '';
     $type->base = 'node_content';
     $type->custom = TRUE;
     $type->modified = TRUE;
     // Save or reset persistent variable values.
     $variables = array('node_submitted' => 0, 'comment' => COMMENT_NODE_HIDDEN, 'webform_user' => 1, 'webform_user_default_fields' => array('webform_user_all_profile_fields' => 'webform_user_all_profile_fields'));
     foreach ($variables as $key => $value) {
         $variable_new = $key . '_' . $type->type;
         if (is_array($value)) {
             $value = array_keys(array_filter($value));
         }
         variable_set($variable_new, $value);
     }
     $status = node_type_save($type);
     node_types_rebuild();
     node_add_body_field($type);
     // Add as a webform.
     $webform_node_types = variable_get('webform_node_types', array('webform'));
     $webform_node_types_primary = variable_get('webform_node_types_primary', array('webform'));
     $webform_node_types = array_merge($webform_node_types, array('petition'));
     $webform_node_types_primary = array_merge($webform_node_types_primary, array('petition'));
     variable_set('webform_node_types', array_unique($webform_node_types));
     variable_set('webform_node_types_primary', array_unique($webform_node_types_primary));
 }
开发者ID:JacksonRiver,项目名称:springboard_modules,代码行数:34,代码来源:webform_user_test_setup.php


示例4: testRecreateEntity

 public function testRecreateEntity()
 {
     $type_name = Unicode::strtolower($this->randomMachineName(16));
     $content_type = entity_create('node_type', array('type' => $type_name, 'name' => 'Node type one'));
     $content_type->save();
     node_add_body_field($content_type);
     /** @var \Drupal\Core\Config\StorageInterface $active */
     $active = $this->container->get('config.storage');
     /** @var \Drupal\Core\Config\StorageInterface $sync */
     $sync = $this->container->get('config.storage.sync');
     $config_name = $content_type->getEntityType()->getConfigPrefix() . '.' . $content_type->id();
     $this->copyConfig($active, $sync);
     // Delete the content type. This will also delete a field storage, a field,
     // an entity view display and an entity form display.
     $content_type->delete();
     $this->assertFalse($active->exists($config_name), 'Content type\'s old name does not exist active store.');
     // Recreate with the same type - this will have a different UUID.
     $content_type = entity_create('node_type', array('type' => $type_name, 'name' => 'Node type two'));
     $content_type->save();
     node_add_body_field($content_type);
     $this->configImporter->reset();
     // A node type, a field, an entity view display and an entity form display
     // will be recreated.
     $creates = $this->configImporter->getUnprocessedConfiguration('create');
     $deletes = $this->configImporter->getUnprocessedConfiguration('delete');
     $this->assertEqual(5, count($creates), 'There are 5 configuration items to create.');
     $this->assertEqual(5, count($deletes), 'There are 5 configuration items to delete.');
     $this->assertEqual(0, count($this->configImporter->getUnprocessedConfiguration('update')), 'There are no configuration items to update.');
     $this->assertIdentical($creates, array_reverse($deletes), 'Deletes and creates contain the same configuration names in opposite orders due to dependencies.');
     $this->configImporter->import();
     // Verify that there is nothing more to import.
     $this->assertFalse($this->configImporter->reset()->hasUnprocessedConfigurationChanges());
     $content_type = NodeType::load($type_name);
     $this->assertEqual('Node type one', $content_type->label());
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:35,代码来源:ConfigImportRecreateTest.php


示例5: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('node');
     $this->installConfig(['node']);
     $this->installSchema('node', ['node_access']);
     $this->installSchema('system', ['sequences']);
     // Create a new user which needs to have UID 1, because that is expected by
     // the assertions from
     // \Drupal\migrate_drupal\Tests\d6\MigrateNodeRevisionTest.
     User::create(['uid' => 1, 'name' => $this->randomMachineName(), 'status' => 1])->enforceIsNew(TRUE)->save();
     $node_type = entity_create('node_type', array('type' => 'test_planet'));
     $node_type->save();
     node_add_body_field($node_type);
     $node_type = entity_create('node_type', array('type' => 'story'));
     $node_type->save();
     node_add_body_field($node_type);
     $id_mappings = array('d6_node_type' => array(array(array('test_story'), array('story'))), 'd6_filter_format' => array(array(array(1), array('filtered_html')), array(array(2), array('full_html'))), 'd6_user' => array(array(array(1), array(1)), array(array(2), array(2))), 'd6_field_instance_widget_settings' => array(array(array('page', 'field_test'), array('node', 'page', 'default', 'test'))), 'd6_field_formatter_settings' => array(array(array('page', 'default', 'node', 'field_test'), array('node', 'page', 'default', 'field_test'))));
     $this->prepareMigrations($id_mappings);
     $migration = entity_load('migration', 'd6_node_settings');
     $migration->setMigrationResult(MigrationInterface::RESULT_COMPLETED);
     // Create a test node.
     $node = entity_create('node', array('type' => 'story', 'nid' => 1, 'vid' => 1, 'revision_log' => '', 'title' => $this->randomString()));
     $node->enforceIsNew();
     $node->save();
     $node = entity_create('node', array('type' => 'test_planet', 'nid' => 3, 'vid' => 4, 'revision_log' => '', 'title' => $this->randomString()));
     $node->enforceIsNew();
     $node->save();
 }
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:32,代码来源:MigrateNodeTestBase.php


示例6: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installConfig(array('filter', 'node'));
     $node_type = entity_create('node_type', array('type' => 'article', 'name' => 'Article'));
     $node_type->save();
     node_add_body_field($node_type);
 }
开发者ID:RealLukeMartin,项目名称:drupal8tester,代码行数:11,代码来源:NodeTokenReplaceTest.php


示例7: createTestContentType

 /**
  * Create test content type.
  */
 protected static function createTestContentType()
 {
     $name = self::randomName(8);
     $type = (object) array('type' => $name, 'name' => $name, 'base' => 'node_content', 'description' => '', 'help' => '', 'title_label' => 'Title', 'body_label' => 'Body', 'has_title' => 1, 'has_body' => 1, 'orig_type' => '', 'old_type' => '', 'module' => 'node', 'custom' => 1, 'modified' => 1, 'locked' => 0);
     node_type_save($type);
     node_types_rebuild();
     node_add_body_field($type);
     self::$contentType = $type;
 }
开发者ID:janoka,项目名称:platform-dev,代码行数:12,代码来源:TokenHandlerAbstractTest.php


示例8: import

 /**
  * {@inheritdoc}
  */
 public function import(Row $row, array $old_destination_id_values = array())
 {
     $entity_ids = parent::import($row, $old_destination_id_values);
     if ($row->getDestinationProperty('create_body')) {
         $node_type = $this->storage->load(reset($entity_ids));
         node_add_body_field($node_type, $row->getDestinationProperty('create_body_label'));
     }
     return $entity_ids;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:12,代码来源:EntityNodeType.php


示例9: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $node_type = entity_create('node_type', array('type' => 'story'));
     $node_type->save();
     node_add_body_field($node_type);
     $id_mappings = array('d6_node_type' => array(array(array('test_story'), array('story'))), 'd6_filter_format' => array(array(array(1), array('filtered_html')), array(array(2), array('full_html'))));
     $this->prepareIdMappings($id_mappings);
     // Create a test node.
     $node = entity_create('node', array('type' => 'story', 'nid' => 1, 'vid' => 1));
     $node->enforceIsNew();
     $node->save();
     // Load dumps.
     $dumps = array($this->getDumpDirectory() . '/Drupal6Node.php', $this->getDumpDirectory() . '/Drupal6NodeType.php', $this->getDumpDirectory() . '/Drupal6FieldInstance.php');
     $this->loadDumps($dumps);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:19,代码来源:MigrateNodeTestBase.php


示例10: setUp

 public function setUp()
 {
     parent::setup();
     $this->installConfig(array('pathauto', 'taxonomy', 'system', 'node'));
     $this->installEntitySchema('user');
     $this->installEntitySchema('node');
     $this->installEntitySchema('taxonomy_term');
     $this->installSchema('node', array('node_access'));
     $this->installSchema('system', array('url_alias', 'sequences', 'router'));
     $type = NodeType::create(['type' => 'page']);
     $type->save();
     node_add_body_field($type);
     \Drupal::service('router.builder')->rebuild();
     $this->currentUser = entity_create('user', array('name' => $this->randomMachineName()));
     $this->currentUser->save();
 }
开发者ID:aakb,项目名称:cfia,代码行数:16,代码来源:PathautoUnitTest.php


示例11: testFieldOverrides

 /**
  * Tests node body field storage persistence even if there are no instances.
  */
 public function testFieldOverrides()
 {
     $field_storage = FieldStorageConfig::loadByName('node', 'body');
     $this->assertTrue($field_storage, 'Node body field storage exists.');
     $type = NodeType::create(['name' => 'Ponies', 'type' => 'ponies']);
     $type->save();
     node_add_body_field($type);
     $field_storage = FieldStorageConfig::loadByName('node', 'body');
     $this->assertTrue(count($field_storage->getBundles()) == 1, 'Node body field storage is being used on the new node type.');
     $field = FieldConfig::loadByName('node', 'ponies', 'body');
     $field->delete();
     $field_storage = FieldStorageConfig::loadByName('node', 'body');
     $this->assertTrue(count($field_storage->getBundles()) == 0, 'Node body field storage exists after deleting the only instance of a field.');
     \Drupal::service('module_installer')->uninstall(array('node'));
     $field_storage = FieldStorageConfig::loadByName('node', 'body');
     $this->assertFalse($field_storage, 'Node body field storage does not exist after uninstalling the Node module.');
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:20,代码来源:NodeBodyFieldStorageTest.php


示例12: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('file');
     $this->installSchema('node', array('node_access'));
     $this->installSchema('file', array('file_usage'));
     $this->installConfig(['node']);
     // Add text formats.
     $filtered_html_format = entity_create('filter_format', array('format' => 'filtered_html', 'name' => 'Filtered HTML', 'weight' => 0, 'filters' => array()));
     $filtered_html_format->save();
     // Set up text editor.
     $editor = entity_create('editor', array('format' => 'filtered_html', 'editor' => 'unicorn'));
     $editor->save();
     // Create a node type for testing.
     $type = entity_create('node_type', array('type' => 'page', 'name' => 'page'));
     $type->save();
     node_add_body_field($type);
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:18,代码来源:EditorFileUsageTest.php


示例13: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp($processor = NULL)
 {
     parent::setUp('rendered_item');
     // Load configuration and needed schemas. (The necessary schemas for using
     // nodes are already installed by the parent method.)
     $this->installConfig(array('system', 'filter', 'node', 'comment'));
     $this->installSchema('system', array('router'));
     \Drupal::service('router.builder')->rebuild();
     // Create a node type for testing.
     $type = NodeType::create(array('type' => 'page', 'name' => 'page'));
     $type->save();
     node_add_body_field($type);
     // Create anonymous user role.
     $role = Role::create(array('id' => 'anonymous', 'label' => 'anonymous'));
     $role->save();
     // Insert the anonymous user into the database.
     $anonymous_user = User::create(array('uid' => 0, 'name' => ''));
     $anonymous_user->save();
     // Default node values for all nodes we create below.
     $node_data = array('status' => NODE_PUBLISHED, 'type' => 'page', 'title' => '', 'body' => array('value' => '', 'summary' => '', 'format' => 'plain_text'), 'uid' => $anonymous_user->id());
     // Create some test nodes with valid user on it for rendering a picture.
     $node_data['title'] = 'Title for node 1';
     $node_data['body']['value'] = 'value for node 1';
     $node_data['body']['summary'] = 'summary for node 1';
     $this->nodes[1] = Node::create($node_data);
     $this->nodes[1]->save();
     $node_data['title'] = 'Title for node 2';
     $node_data['body']['value'] = 'value for node 2';
     $node_data['body']['summary'] = 'summary for node 2';
     $this->nodes[2] = Node::create($node_data);
     $this->nodes[2]->save();
     // Set proper configuration for the tested processor.
     $config = $this->processor->getConfiguration();
     $config['view_mode'] = array('entity:node' => ['page' => 'full', 'article' => 'teaser'], 'entity:user' => 'compact', 'entity:comment' => 'teaser');
     $config['roles'] = array($role->id());
     $this->processor->setConfiguration($config);
     $this->index->save();
     $this->index->getDatasources();
     // Enable the classy theme as the tests rely on markup from that.
     \Drupal::service('theme_handler')->install(array('classy'));
     \Drupal::theme()->setActiveTheme(\Drupal::service('theme.initialization')->initTheme('classy'));
 }
开发者ID:curveagency,项目名称:intranet,代码行数:45,代码来源:RenderedItemTest.php


示例14: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('file');
     $this->installSchema('node', array('node_access'));
     $this->installSchema('file', array('file_usage'));
     $this->installConfig(['node']);
     // Add text formats.
     $filtered_html_format = FilterFormat::create(array('format' => 'filtered_html', 'name' => 'Filtered HTML', 'weight' => 0, 'filters' => array()));
     $filtered_html_format->save();
     // Set cardinality for body field.
     FieldStorageConfig::loadByName('node', 'body')->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)->save();
     // Set up text editor.
     $editor = Editor::create(['format' => 'filtered_html', 'editor' => 'unicorn']);
     $editor->save();
     // Create a node type for testing.
     $type = NodeType::create(['type' => 'page', 'name' => 'page']);
     $type->save();
     node_add_body_field($type);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:20,代码来源:EditorFileUsageTest.php


示例15: setUp

 /**
  * Sets up the test.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('file');
     $this->installSchema('system', ['key_value_expire']);
     $this->installSchema('node', array('node_access'));
     $this->installSchema('file', array('file_usage'));
     $this->installConfig(['node']);
     // Add text formats.
     $this->format = FilterFormat::create(['format' => 'filtered_html', 'name' => 'Filtered HTML', 'weight' => 0, 'filters' => ['filter_align' => ['status' => TRUE], 'filter_caption' => ['status' => TRUE]]]);
     $this->format->save();
     // Set up text editor.
     $editor = Editor::create(['format' => 'filtered_html', 'editor' => 'unicorn', 'image_upload' => ['max_size' => 100, 'scheme' => 'public', 'directory' => '', 'status' => TRUE]]);
     $editor->save();
     // Create a node type for testing.
     $type = NodeType::create(['type' => 'page', 'name' => 'page']);
     $type->save();
     node_add_body_field($type);
     $this->installEntitySchema('user');
     \Drupal::service('router.builder')->rebuild();
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:24,代码来源:EditorImageDialogTest.php


示例16: createContentType

 /**
  * Creates a custom content type based on default settings.
  *
  * @param array $values
  *   An array of settings to change from the defaults.
  *   Example: 'type' => 'foo'.
  *
  * @return \Drupal\node\Entity\NodeType
  *   Created content type.
  */
 protected function createContentType(array $values = array())
 {
     // Find a non-existent random type name.
     if (!isset($values['type'])) {
         do {
             $id = strtolower($this->randomMachineName(8));
         } while (NodeType::load($id));
     } else {
         $id = $values['type'];
     }
     $values += array('type' => $id, 'name' => $id);
     $type = NodeType::create($values);
     $status = $type->save();
     node_add_body_field($type);
     if ($this instanceof \PHPUnit_Framework_TestCase) {
         $this->assertSame($status, SAVED_NEW, (new FormattableMarkup('Created content type %type.', array('%type' => $type->id())))->__toString());
     } else {
         $this->assertEqual($status, SAVED_NEW, (new FormattableMarkup('Created content type %type.', array('%type' => $type->id())))->__toString());
     }
     return $type;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:31,代码来源:ContentTypeCreationTrait.php


示例17: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     entity_create('node_type', array('type' => 'test_planet'))->save();
     $node_type = entity_create('node_type', array('type' => 'story'));
     $node_type->save();
     node_add_body_field($node_type);
     $id_mappings = array('d6_node_type' => array(array(array('test_story'), array('story'))), 'd6_filter_format' => array(array(array(1), array('filtered_html')), array(array(2), array('full_html'))), 'd6_field_instance_widget_settings' => array(array(array('page', 'field_test'), array('node', 'page', 'default', 'test'))), 'd6_field_formatter_settings' => array(array(array('page', 'default', 'node', 'field_test'), array('node', 'page', 'default', 'field_test'))));
     $this->prepareMigrations($id_mappings);
     $migration = entity_load('migration', 'd6_node_settings');
     $migration->setMigrationResult(MigrationInterface::RESULT_COMPLETED);
     // Create a test node.
     $node = entity_create('node', array('type' => 'story', 'nid' => 1, 'vid' => 1));
     $node->enforceIsNew();
     $node->save();
     $node = entity_create('node', array('type' => 'test_planet', 'nid' => 3, 'vid' => 4));
     $node->enforceIsNew();
     $node->save();
     // Load dumps.
     $dumps = array($this->getDumpDirectory() . '/Drupal6Node.php', $this->getDumpDirectory() . '/Drupal6NodeType.php', $this->getDumpDirectory() . '/Drupal6FieldInstance.php');
     $this->loadDumps($dumps);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:25,代码来源:MigrateNodeTestBase.php


示例18: testMandrillEmail

 /**
  * Checks whether emails get sent when a user creates a new article node.
  */
 function testMandrillEmail()
 {
     $this->installEntitySchema('node');
     $this->installEntitySchema('user');
     \Drupal::service('module_installer')->install(array('dblog', 'field'));
     // Use the state system collector mail backend.
     $config = \Drupal::configFactory()->getEditable('system.mail');
     $mail_plugins = array('default' => 'test_mail_collector');
     $config->set('interface', $mail_plugins)->save();
     // Reset the state variable that holds sent messages.
     \Drupal::state()->set('system.test_mail_collector', array());
     // Create a user account and set it as the current user.
     $user = entity_create('user', array('uid' => 1, 'mail' => '[email protected]'));
     $user->save();
     \Drupal::currentUser()->setAccount($user);
     // Set the site email address.
     \Drupal::configFactory()->getEditable('system.site')->set('mail', '[email protected]')->save();
     // Create the article content type and add the body field to it.
     $type = array('type' => 'article', 'name' => 'Article');
     $type = entity_create('node_type', $type);
     $type->save();
     $article = NodeType::load('article');
     node_add_body_field($article);
     // Create a random article node.
     $title = $this->randomMachineName();
     $values = array('uid' => $user->id(), 'title' => $title, 'body' => [['value' => 'test_body']], 'type' => 'article');
     $node = entity_create('node', $values);
     $node->save();
     // Check the latest captured emails.
     $captured_emails = \Drupal::state()->get('system.test_mail_collector');
     $sent_message = end($captured_emails);
     $this->assertTrue(!empty($sent_message));
     $this->assertEqual($sent_message['id'], 'd8mail_node_insert', 'Correct mail id.');
     $this->assertEqual($sent_message['to'], '[email protected]', 'Correct mail to.');
     $this->assertEqual($sent_message['from'], '[email protected]', 'Correct mail from.');
     $this->assertEqual($sent_message['subject'], sprintf("Node created: %s", $title), 'Correct mail subject.');
     $this->assertEqual($sent_message['body'], 'test_body' . PHP_EOL, 'Correct mail body.');
 }
开发者ID:btesterltda,项目名称:d8mail,代码行数:41,代码来源:MandrillMailTest.php


示例19: testViewsTokenReplacement

 /**
  * Tests token replacement for Views tokens supplied by the Node module.
  */
 public function testViewsTokenReplacement()
 {
     // Create the Article content type with a standard body field.
     /* @var $node_type \Drupal\node\NodeTypeInterface */
     $node_type = entity_create('node_type', ['type' => 'article', 'name' => 'Article']);
     $node_type->save();
     node_add_body_field($node_type);
     // Create a user and a node.
     $account = $this->createUser();
     $body = $this->randomMachineName(32);
     $summary = $this->randomMachineName(16);
     /** @var $node \Drupal\node\NodeInterface */
     $node = entity_create('node', ['type' => 'article', 'tnid' => 0, 'uid' => $account->id(), 'title' => 'Testing Views tokens', 'body' => [['value' => $body, 'summary' => $summary, 'format' => 'plain_text']]]);
     $node->save();
     $this->drupalGet('test_node_tokens');
     // Body: {{ body }}<br />
     $this->assertRaw("Body: <p>{$body}</p>");
     // Raw value: {{ body__value }}<br />
     $this->assertRaw("Raw value: {$body}");
     // Raw summary: {{ body__summary }}<br />
     $this->assertRaw("Raw summary: {$summary}");
     // Raw format: {{ body__format }}<br />
     $this->assertRaw("Raw format: plain_text");
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:27,代码来源:NodeFieldTokensTest.php


示例20: testDisabledFormat

 /**
  * Tests whether a field using a disabled format is rendered.
  */
 public function testDisabledFormat()
 {
     // Create a node type and add a standard body field.
     $node_type = NodeType::create(['type' => Unicode::strtolower($this->randomMachineName())]);
     $node_type->save();
     node_add_body_field($node_type, $this->randomString());
     // Create a text format with a filter that returns a static string.
     $format = FilterFormat::create(['name' => $this->randomString(), 'format' => $format_id = Unicode::strtolower($this->randomMachineName())]);
     $format->setFilterConfig('filter_static_text', ['status' => TRUE]);
     $format->save();
     // Create a new node of the new node type.
     $node = Node::create(['type' => $node_type->id(), 'title' => $this->randomString()]);
     $body_value = $this->randomString();
     $node->body->value = $body_value;
     $node->body->format = $format_id;
     $node->save();
     // The format is used and we should see the static text instead of the body
     // value.
     $this->drupalGet($node->urlInfo());
     $this->assertText('filtered text');
     // Disable the format.
     $format->disable()->save();
     $this->drupalGet($node->urlInfo());
     // The format is not used anymore.
     $this->assertNoText('filtered text');
     // The text is not displayed unfiltered or escaped.
     $this->assertNoRaw($body_value);
     $this->assertNoEscaped($body_value);
     // Visit the dblog report page.
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('admin/reports/dblog');
     // The correct message has been logged.
     $this->assertRaw(sprintf('Disabled text format: %s.', $format_id));
     // Programmatically change the text format to something random so we trigger
     // the missing text format message.
     $format_id = $this->randomMachineName();
     $node->body->format = $format_id;
     $node->save();
     $this->drupalGet($node->urlInfo());
     // The text is not displayed unfiltered or escaped.
     $this->assertNoRaw($body_value);
     $this->assertNoEscaped($body_value);
     // Visit the dblog report page.
     $this->drupalGet('admin/reports/dblog');
     // The missing text format message has been logged.
     $this->assertRaw(sprintf('Missing text format: %s.', $format_id));
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:50,代码来源:FilterAdminTest.php



注:本文中的node_add_body_field函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP node_build_content函数代码示例发布时间:2022-05-15
下一篇:
PHP node_access_view_all_nodes函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap