当前位置: 首页>>代码示例>>PHP>>正文


PHP Entity\Comment类代码示例

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


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

示例1: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->drupalPlaceBlock('page_title_block');
     // Create Basic page node type.
     $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
     $vocabulary = Vocabulary::create(['name' => $this->randomMachineName(), 'description' => $this->randomMachineName(), 'vid' => Unicode::strtolower($this->randomMachineName()), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'help' => '', 'nodes' => array('page' => 'page'), 'weight' => mt_rand(0, 10)]);
     $vocabulary->save();
     // Create a field.
     $field_name = Unicode::strtolower($this->randomMachineName());
     $handler_settings = array('target_bundles' => array($vocabulary->id() => $vocabulary->id()), 'auto_create' => TRUE);
     $this->createEntityReferenceField('node', 'page', $field_name, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
     // Create a time in the past for the archive.
     $time = REQUEST_TIME - 3600;
     $this->addDefaultCommentField('node', 'page');
     for ($i = 0; $i <= 10; $i++) {
         $user = $this->drupalCreateUser();
         $term = $this->createTerm($vocabulary);
         $values = array('created' => $time, 'type' => 'page');
         $values[$field_name][]['target_id'] = $term->id();
         // Make every other node promoted.
         if ($i % 2) {
             $values['promote'] = TRUE;
         }
         $values['body'][]['value'] = \Drupal::l('Node ' . 1, new Url('entity.node.canonical', ['node' => 1]));
         $node = $this->drupalCreateNode($values);
         $comment = array('uid' => $user->id(), 'status' => CommentInterface::PUBLISHED, 'entity_id' => $node->id(), 'entity_type' => 'node', 'field_name' => 'comment');
         Comment::create($comment)->save();
     }
     // Some views, such as the "Who's Online" view, only return results if at
     // least one user is logged in.
     $account = $this->drupalCreateUser(array());
     $this->drupalLogin($account);
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:34,代码来源:DefaultViewsTest.php

示例2: setUp

 protected function setUp()
 {
     parent::setUp();
     // Create a new content type
     $content_type = $this->drupalCreateContentType();
     // Add a node of the new content type.
     $node_data = array('type' => $content_type->id());
     $this->addDefaultCommentField('node', $content_type->id());
     $this->node = $this->drupalCreateNode($node_data);
     // Force a flush of the in-memory storage.
     $this->container->get('views.views_data')->clear();
     // Create some comments and attach them to the created node.
     for ($i = 0; $i < $this->masterDisplayResults; $i++) {
         /** @var \Drupal\comment\CommentInterface $comment */
         $comment = Comment::create(array('status' => CommentInterface::PUBLISHED, 'field_name' => 'comment', 'entity_type' => 'node', 'entity_id' => $this->node->id()));
         $comment->setOwnerId(0);
         $comment->setSubject('Test comment ' . $i);
         $comment->comment_body->value = 'Test body ' . $i;
         $comment->comment_body->format = 'full_html';
         // Ensure comments are sorted in ascending order.
         $time = REQUEST_TIME + ($this->masterDisplayResults - $i);
         $comment->setCreatedTime($time);
         $comment->changed->value = $time;
         $comment->save();
     }
     // Store all the nodes just created to access their properties on the tests.
     $this->commentsCreated = Comment::loadMultiple();
     // Sort created comments in descending order.
     ksort($this->commentsCreated, SORT_NUMERIC);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:30,代码来源:DefaultViewRecentCommentsTest.php

示例3: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp($import_test_views = TRUE)
 {
     parent::setUp($import_test_views);
     $this->installEntitySchema('user');
     $this->installEntitySchema('comment');
     // Create the anonymous role.
     $this->installConfig(['user']);
     // Create an anonymous user.
     $storage = \Drupal::entityManager()->getStorage('user');
     // Insert a row for the anonymous user.
     $storage->create(array('uid' => 0, 'name' => '', 'status' => 0))->save();
     $admin_role = Role::create(['id' => 'admin', 'permissions' => ['administer comments', 'access user profiles']]);
     $admin_role->save();
     /* @var \Drupal\user\RoleInterface $anonymous_role */
     $anonymous_role = Role::load(Role::ANONYMOUS_ID);
     $anonymous_role->grantPermission('access comments');
     $anonymous_role->save();
     $this->adminUser = User::create(['name' => $this->randomMachineName(), 'roles' => [$admin_role->id()]]);
     $this->adminUser->save();
     // Create some comments.
     $comment = Comment::create(['subject' => 'My comment title', 'uid' => $this->adminUser->id(), 'name' => $this->adminUser->label(), 'entity_type' => 'entity_test', 'comment_type' => 'entity_test', 'status' => 1]);
     $comment->save();
     $comment_anonymous = Comment::create(['subject' => 'Anonymous comment title', 'uid' => 0, 'name' => 'barry', 'mail' => 'test@example.com', 'homepage' => 'https://example.com', 'entity_type' => 'entity_test', 'comment_type' => 'entity_test', 'created' => 123456, 'status' => 1]);
     $comment_anonymous->save();
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:28,代码来源:CommentUserNameTest.php

示例4: setUp

 /**
  * Performs setup tasks before each individual test method is run.
  */
 public function setUp()
 {
     parent::setUp('content_access');
     // The parent method already installs most needed node and comment schemas,
     // but here we also need the comment statistics.
     $this->installSchema('comment', array('comment_entity_statistics'));
     // Create a node type for testing.
     $type = NodeType::create(array('type' => 'page', 'name' => 'page'));
     $type->save();
     // Create anonymous user role.
     $role = Role::create(array('id' => 'anonymous', 'label' => 'anonymous'));
     $role->save();
     // Insert the anonymous user into the database, as the user table is inner
     // joined by \Drupal\comment\CommentStorage.
     User::create(array('uid' => 0, 'name' => ''))->save();
     // Create a node with attached comment.
     $this->nodes[0] = Node::create(array('status' => NODE_PUBLISHED, 'type' => 'page', 'title' => 'test title'));
     $this->nodes[0]->save();
     $comment_type = CommentType::create(array('id' => 'comment', 'target_entity_type_id' => 'node'));
     $comment_type->save();
     $this->installConfig(array('comment'));
     $this->addDefaultCommentField('node', 'page');
     $comment = Comment::create(array('entity_type' => 'node', 'entity_id' => $this->nodes[0]->id(), 'field_name' => 'comment', 'body' => 'test body', 'comment_type' => $comment_type->id()));
     $comment->save();
     $this->comments[] = $comment;
     $this->nodes[1] = Node::create(array('status' => NODE_PUBLISHED, 'type' => 'page', 'title' => 'some title'));
     $this->nodes[1]->save();
     $this->nodes[2] = Node::create(array('status' => NODE_NOT_PUBLISHED, 'type' => 'page', 'title' => 'other title'));
     $this->nodes[2]->save();
     // Also index users, to verify that they are unaffected by the processor.
     $this->index->set('datasources', array('entity:comment', 'entity:node', 'entity:user'));
     $this->index->save();
     $this->index = entity_load('search_api_index', $this->index->id(), TRUE);
 }
开发者ID:alexku,项目名称:travisintegrationtest,代码行数:37,代码来源:ContentAccessTest.php

示例5: testCommentNodeCommentStatistics

 /**
  * Tests the node comment statistics.
  */
 function testCommentNodeCommentStatistics()
 {
     $node_storage = $this->container->get('entity.manager')->getStorage('node');
     // Set comments to have subject and preview disabled.
     $this->drupalLogin($this->adminUser);
     $this->setCommentPreview(DRUPAL_DISABLED);
     $this->setCommentForm(TRUE);
     $this->setCommentSubject(FALSE);
     $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Comment paging changed.');
     $this->drupalLogout();
     // Checks the initial values of node comment statistics with no comment.
     $node = $node_storage->load($this->node->id());
     $this->assertEqual($node->get('comment')->last_comment_timestamp, $this->node->getCreatedTime(), 'The initial value of node last_comment_timestamp is the node created date.');
     $this->assertEqual($node->get('comment')->last_comment_name, NULL, 'The initial value of node last_comment_name is NULL.');
     $this->assertEqual($node->get('comment')->last_comment_uid, $this->webUser->id(), 'The initial value of node last_comment_uid is the node uid.');
     $this->assertEqual($node->get('comment')->comment_count, 0, 'The initial value of node comment_count is zero.');
     // Post comment #1 as web_user2.
     $this->drupalLogin($this->webUser2);
     $comment_text = $this->randomMachineName();
     $this->postComment($this->node, $comment_text);
     // Checks the new values of node comment statistics with comment #1.
     // The node cache needs to be reset before reload.
     $node_storage->resetCache(array($this->node->id()));
     $node = $node_storage->load($this->node->id());
     $this->assertEqual($node->get('comment')->last_comment_name, NULL, 'The value of node last_comment_name is NULL.');
     $this->assertEqual($node->get('comment')->last_comment_uid, $this->webUser2->id(), 'The value of node last_comment_uid is the comment #1 uid.');
     $this->assertEqual($node->get('comment')->comment_count, 1, 'The value of node comment_count is 1.');
     // Prepare for anonymous comment submission (comment approval enabled).
     $this->drupalLogin($this->adminUser);
     user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array('access comments' => TRUE, 'post comments' => TRUE, 'skip comment approval' => FALSE));
     // Ensure that the poster can leave some contact info.
     $this->setCommentAnonymous('1');
     $this->drupalLogout();
     // Post comment #2 as anonymous (comment approval enabled).
     $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
     $anonymous_comment = $this->postComment($this->node, $this->randomMachineName(), '', TRUE);
     // Checks the new values of node comment statistics with comment #2 and
     // ensure they haven't changed since the comment has not been moderated.
     // The node needs to be reloaded with the cache reset.
     $node_storage->resetCache(array($this->node->id()));
     $node = $node_storage->load($this->node->id());
     $this->assertEqual($node->get('comment')->last_comment_name, NULL, 'The value of node last_comment_name is still NULL.');
     $this->assertEqual($node->get('comment')->last_comment_uid, $this->webUser2->id(), 'The value of node last_comment_uid is still the comment #1 uid.');
     $this->assertEqual($node->get('comment')->comment_count, 1, 'The value of node comment_count is still 1.');
     // Prepare for anonymous comment submission (no approval required).
     $this->drupalLogin($this->adminUser);
     user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array('access comments' => TRUE, 'post comments' => TRUE, 'skip comment approval' => TRUE));
     $this->drupalLogout();
     // Post comment #3 as anonymous.
     $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
     $anonymous_comment = $this->postComment($this->node, $this->randomMachineName(), '', array('name' => $this->randomMachineName()));
     $comment_loaded = Comment::load($anonymous_comment->id());
     // Checks the new values of node comment statistics with comment #3.
     // The node needs to be reloaded with the cache reset.
     $node_storage->resetCache(array($this->node->id()));
     $node = $node_storage->load($this->node->id());
     $this->assertEqual($node->get('comment')->last_comment_name, $comment_loaded->getAuthorName(), 'The value of node last_comment_name is the name of the anonymous user.');
     $this->assertEqual($node->get('comment')->last_comment_uid, 0, 'The value of node last_comment_uid is zero.');
     $this->assertEqual($node->get('comment')->comment_count, 2, 'The value of node comment_count is 2.');
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:63,代码来源:CommentStatisticsTest.php

示例6: testCommentForm_2698811

    /**
     * Ensure comment form works with history and big_pipe modules.
     *
     * @see https://www.drupal.org/node/2698811
     */
    public function testCommentForm_2698811()
    {
        $this->assertTrue($this->container->get('module_installer')->install(['comment', 'history', 'ckeditor'], TRUE), 'Installed modules.');
        // Ensure an `article` node type exists.
        $this->createContentType(['type' => 'article']);
        $this->addDefaultCommentField('node', 'article');
        // Enable CKEditor.
        $format = $this->randomMachineName();
        FilterFormat::create(['format' => $format, 'name' => $this->randomString(), 'weight' => 1, 'filters' => []])->save();
        $settings['toolbar']['rows'] = [[['name' => 'Links', 'items' => ['DrupalLink', 'DrupalUnlink']]]];
        $editor = Editor::create(['format' => $format, 'editor' => 'ckeditor']);
        $editor->setSettings($settings);
        $editor->save();
        $admin_user = $this->drupalCreateUser(['access comments', 'post comments', 'use text format ' . $format]);
        $this->drupalLogin($admin_user);
        $node = $this->createNode(['type' => 'article', 'comment' => CommentItemInterface::OPEN]);
        // Create some comments.
        foreach (range(1, 5) as $i) {
            $comment = Comment::create(['status' => CommentInterface::PUBLISHED, 'field_name' => 'comment', 'entity_type' => 'node', 'entity_id' => $node->id()]);
            $comment->save();
        }
        $this->drupalGet($node->toUrl()->toString());
        // Confirm that CKEditor loaded.
        $javascript = <<<JS
    (function(){
      return Object.keys(CKEDITOR.instances).length > 0;
    }());
JS;
        $this->assertJsCondition($javascript);
    }
开发者ID:DrupalCamp-NYC,项目名称:dcnyc16,代码行数:35,代码来源:BigPipeRegressionTest.php

示例7: testGetEntity

 /**
  * Tests the getEntity method.
  */
 public function testGetEntity()
 {
     // The view is a view of comments, their nodes and their authors, so there
     // are three layers of entities.
     $account = User::create(['name' => $this->randomMachineName(), 'bundle' => 'user']);
     $account->save();
     $node = Node::create(['uid' => $account->id(), 'type' => 'page', 'title' => $this->randomString()]);
     $node->save();
     $comment = Comment::create(array('uid' => $account->id(), 'entity_id' => $node->id(), 'entity_type' => 'node', 'field_name' => 'comment'));
     $comment->save();
     $user = $this->drupalCreateUser(['access comments']);
     $this->drupalLogin($user);
     $view = Views::getView('test_field_get_entity');
     $this->executeView($view);
     $row = $view->result[0];
     // Tests entities on the base level.
     $entity = $view->field['cid']->getEntity($row);
     $this->assertEqual($entity->id(), $comment->id(), 'Make sure the right comment entity got loaded.');
     // Tests entities as relationship on first level.
     $entity = $view->field['nid']->getEntity($row);
     $this->assertEqual($entity->id(), $node->id(), 'Make sure the right node entity got loaded.');
     // Tests entities as relationships on second level.
     $entity = $view->field['uid']->getEntity($row);
     $this->assertEqual($entity->id(), $account->id(), 'Make sure the right user entity got loaded.');
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:28,代码来源:FieldEntityTest.php

示例8: setUp

 function setUp()
 {
     parent::setUp();
     $this->drupalLogin($this->drupalCreateUser(['access comments']));
     // Add two new languages.
     ConfigurableLanguage::createFromLangcode('fr')->save();
     ConfigurableLanguage::createFromLangcode('es')->save();
     // Set up comment titles.
     $this->commentTitles = array('en' => 'Food in Paris', 'es' => 'Comida en Paris', 'fr' => 'Nouriture en Paris');
     // Create a new comment. Using the one created earlier will not work,
     // as it predates the language set-up.
     $comment = array('uid' => $this->loggedInUser->id(), 'entity_id' => $this->nodeUserCommented->id(), 'entity_type' => 'node', 'field_name' => 'comment', 'cid' => '', 'pid' => '', 'node_type' => '');
     $this->comment = Comment::create($comment);
     // Add field values and translate the comment.
     $this->comment->subject->value = $this->commentTitles['en'];
     $this->comment->comment_body->value = $this->commentTitles['en'];
     $this->comment->langcode = 'en';
     $this->comment->save();
     foreach (array('es', 'fr') as $langcode) {
         $translation = $this->comment->addTranslation($langcode, array());
         $translation->comment_body->value = $this->commentTitles[$langcode];
         $translation->subject->value = $this->commentTitles[$langcode];
     }
     $this->comment->save();
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:25,代码来源:CommentFieldFilterTest.php

示例9: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->addDefaultCommentField('node', 'page', $this->fieldName);
     $this->customComment = Comment::create(['entity_id' => $this->nodeUserCommented->id(), 'entity_type' => 'node', 'field_name' => $this->fieldName]);
     $this->customComment->save();
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:10,代码来源:CommentFieldNameTest.php

示例10: setUp

 protected function setUp()
 {
     parent::setUp();
     ViewTestData::createTestViews(get_class($this), array('comment_test_views'));
     // Add two users, create a node with the user1 as author and another node
     // with user2 as author. For the second node add a comment from user1.
     $this->account = $this->drupalCreateUser(array('skip comment approval'));
     $this->account2 = $this->drupalCreateUser();
     $this->drupalLogin($this->account);
     $this->drupalCreateContentType(array('type' => 'page', 'name' => t('Basic page')));
     $this->addDefaultCommentField('node', 'page');
     $this->nodeUserPosted = $this->drupalCreateNode();
     $this->nodeUserCommented = $this->drupalCreateNode(array('uid' => $this->account2->id()));
     $comment = array('uid' => $this->loggedInUser->id(), 'entity_id' => $this->nodeUserCommented->id(), 'entity_type' => 'node', 'field_name' => 'comment', 'subject' => 'How much wood would a woodchuck chuck', 'cid' => '', 'pid' => '', 'mail' => 'someone@example.com');
     $this->comment = Comment::create($comment);
     $this->comment->save();
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:17,代码来源:CommentTestBase.php

示例11: testForumUninstallWithField

 /**
  * Tests if forum module uninstallation properly deletes the field.
  */
 public function testForumUninstallWithField()
 {
     $this->drupalLogin($this->drupalCreateUser(['administer taxonomy', 'administer nodes', 'administer modules', 'delete any forum content', 'administer content types']));
     // Ensure that the field exists before uninstallation.
     $field_storage = FieldStorageConfig::loadByName('node', 'taxonomy_forums');
     $this->assertNotNull($field_storage, 'The taxonomy_forums field storage exists.');
     // Create a taxonomy term.
     $term = Term::create(['name' => t('A term'), 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(), 'description' => '', 'parent' => array(0), 'vid' => 'forums', 'forum_container' => 0]);
     $term->save();
     // Create a forum node.
     $node = $this->drupalCreateNode(array('title' => 'A forum post', 'type' => 'forum', 'taxonomy_forums' => array(array('target_id' => $term->id()))));
     // Create at least one comment against the forum node.
     $comment = Comment::create(array('entity_id' => $node->nid->value, 'entity_type' => 'node', 'field_name' => 'comment_forum', 'pid' => 0, 'uid' => 0, 'status' => CommentInterface::PUBLISHED, 'subject' => $this->randomMachineName(), 'hostname' => '127.0.0.1'));
     $comment->save();
     // Attempt to uninstall forum.
     $this->drupalGet('admin/modules/uninstall');
     // Assert forum is required.
     $this->assertNoFieldByName('uninstall[forum]');
     $this->assertText('To uninstall Forum, first delete all Forum content');
     // Delete the node.
     $this->drupalPostForm('node/' . $node->id() . '/delete', array(), t('Delete'));
     // Attempt to uninstall forum.
     $this->drupalGet('admin/modules/uninstall');
     // Assert forum is still required.
     $this->assertNoFieldByName('uninstall[forum]');
     $this->assertText('To uninstall Forum, first delete all Forums terms');
     // Delete any forum terms.
     $vid = $this->config('forum.settings')->get('vocabulary');
     $terms = entity_load_multiple_by_properties('taxonomy_term', ['vid' => $vid]);
     foreach ($terms as $term) {
         $term->delete();
     }
     // Ensure that the forum node type can not be deleted.
     $this->drupalGet('admin/structure/types/manage/forum');
     $this->assertNoLink(t('Delete'));
     // Now attempt to uninstall forum.
     $this->drupalGet('admin/modules/uninstall');
     // Assert forum is no longer required.
     $this->assertFieldByName('uninstall[forum]');
     $this->drupalPostForm('admin/modules/uninstall', array('uninstall[forum]' => 1), t('Uninstall'));
     $this->drupalPostForm(NULL, [], t('Uninstall'));
     // Check that the field is now deleted.
     $field_storage = FieldStorageConfig::loadByName('node', 'taxonomy_forums');
     $this->assertNull($field_storage, 'The taxonomy_forums field storage has been deleted.');
     // Check that a node type with a machine name of forum can be created after
     // uninstalling the forum module and the node type is not locked.
     $edit = array('name' => 'Forum', 'title_label' => 'title for forum', 'type' => 'forum');
     $this->drupalPostForm('admin/structure/types/add', $edit, t('Save content type'));
     $this->assertTrue((bool) NodeType::load('forum'), 'Node type with machine forum created.');
     $this->drupalGet('admin/structure/types/manage/forum');
     $this->clickLink(t('Delete'));
     $this->drupalPostForm(NULL, array(), t('Delete'));
     $this->assertResponse(200);
     $this->assertFalse((bool) NodeType::load('forum'), 'Node type with machine forum deleted.');
     // Double check everything by reinstalling the forum module again.
     $this->drupalPostForm('admin/modules', ['modules[Core][forum][enable]' => 1], 'Install');
     $this->assertText('Module Forum has been enabled.');
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:61,代码来源:ForumUninstallTest.php

示例12: setUp

 protected function setUp()
 {
     parent::setUp();
     // Add another anonymous comment.
     $comment = array('uid' => 0, 'entity_id' => $this->nodeUserCommented->id(), 'entity_type' => 'node', 'field_name' => 'comment', 'subject' => 'A lot, apparently', 'cid' => '', 'pid' => $this->comment->id(), 'mail' => 'someone@example.com', 'name' => 'bobby tables', 'hostname' => 'public.example.com');
     $this->comment = Comment::create($comment);
     $this->comment->save();
     $user = $this->drupalCreateUser(['access comments']);
     $this->drupalLogin($user);
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:10,代码来源:CommentRestExportTest.php

示例13: setUp

 protected function setUp()
 {
     parent::setUp();
     ViewTestData::createTestViews(get_class($this), array('tracker_test_views'));
     $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
     // Add a comment field.
     $this->addDefaultCommentField('node', 'page');
     $permissions = array('access comments', 'create page content', 'post comments', 'skip comment approval');
     $account = $this->drupalCreateUser($permissions);
     $this->drupalLogin($account);
     $this->node = $this->drupalCreateNode(array('title' => $this->randomMachineName(8), 'uid' => $account->id(), 'status' => 1));
     $this->comment = Comment::create(array('entity_id' => $this->node->id(), 'entity_type' => 'node', 'field_name' => 'comment', 'subject' => $this->randomMachineName(), 'comment_body[' . LanguageInterface::LANGCODE_NOT_SPECIFIED . '][0][value]' => $this->randomMachineName(20)));
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:13,代码来源:TrackerTestBase.php

示例14: testCommentUserUIDTest

 function testCommentUserUIDTest()
 {
     // Add an additional comment which is not created by the user.
     $new_user = User::create(['name' => 'new user']);
     $new_user->save();
     $comment = Comment::create(['uid' => $new_user->uid->value, 'entity_id' => $this->nodeUserCommented->id(), 'entity_type' => 'node', 'field_name' => 'comment', 'subject' => 'if a woodchuck could chuck wood.']);
     $comment->save();
     $view = Views::getView('test_comment_user_uid');
     $this->executeView($view, array($this->account->id()));
     $result_set = array(array('nid' => $this->nodeUserPosted->id()), array('nid' => $this->nodeUserCommented->id()));
     $column_map = array('nid' => 'nid');
     $this->assertIdenticalResultset($view, $result_set, $column_map);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:13,代码来源:ArgumentUserUIDTest.php

示例15: testCommentUnpublishByKeyword

 /**
  * Tests the unpublish comment by keyword action.
  */
 function testCommentUnpublishByKeyword()
 {
     $this->drupalLogin($this->adminUser);
     $keyword_1 = $this->randomMachineName();
     $keyword_2 = $this->randomMachineName();
     $action = entity_create('action', array('id' => 'comment_unpublish_by_keyword_action', 'label' => $this->randomMachineName(), 'type' => 'comment', 'configuration' => array('keywords' => array($keyword_1, $keyword_2)), 'plugin' => 'comment_unpublish_by_keyword_action'));
     $action->save();
     $comment = $this->postComment($this->node, $keyword_2, $this->randomMachineName());
     // Load the full comment so that status is available.
     $comment = Comment::load($comment->id());
     $this->assertTrue($comment->isPublished() === TRUE, 'The comment status was set to published.');
     $action->execute(array($comment));
     $this->assertTrue($comment->isPublished() === FALSE, 'The comment status was set to not published.');
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:17,代码来源:CommentActionsTest.php


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