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


PHP NodeInterface::delete方法代码示例

本文整理汇总了PHP中Drupal\node\NodeInterface::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeInterface::delete方法的具体用法?PHP NodeInterface::delete怎么用?PHP NodeInterface::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\node\NodeInterface的用法示例。


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

示例1: testSearchText

 /**
  * Tests the presence of the expected cache tag in various situations.
  */
 function testSearchText()
 {
     $this->drupalLogin($this->searchingUser);
     // Initial page for searching nodes.
     $this->drupalGet('search/node');
     $this->assertCacheTag('config:search.page.node_search');
     $this->assertCacheTag('search_index:node_search');
     $this->assertCacheTag('node_list');
     // Node search results.
     $edit = array();
     $edit['keys'] = 'bike shed';
     $this->drupalPostForm('search/node', $edit, t('Search'));
     $this->assertText('bike shed shop');
     $this->assertCacheTag('config:search.page.node_search');
     $this->assertCacheTag('search_index');
     $this->assertCacheTag('search_index:node_search');
     $this->assertCacheTag('node:1');
     $this->assertCacheTag('user:2');
     $this->assertCacheTag('rendered');
     $this->assertCacheTag('node_list');
     // Updating a node should invalidate the search plugin's index cache tag.
     $this->node->title = 'bike shop';
     $this->node->save();
     $this->drupalPostForm('search/node', $edit, t('Search'));
     $this->assertText('bike shop');
     $this->assertCacheTag('config:search.page.node_search');
     $this->assertCacheTag('search_index');
     $this->assertCacheTag('search_index:node_search');
     $this->assertCacheTag('node:1');
     $this->assertCacheTag('user:2');
     $this->assertCacheTag('rendered');
     $this->assertCacheTag('node_list');
     // Deleting a node should invalidate the search plugin's index cache tag.
     $this->node->delete();
     $this->drupalPostForm('search/node', $edit, t('Search'));
     $this->assertText('Your search yielded no results.');
     $this->assertCacheTag('config:search.page.node_search');
     $this->assertCacheTag('search_index');
     $this->assertCacheTag('search_index:node_search');
     $this->assertCacheTag('node_list');
     // Initial page for searching users.
     $this->drupalGet('search/user');
     $this->assertCacheTag('config:search.page.user_search');
     $this->assertCacheTag('user_list');
     $this->assertNoCacheTag('search_index');
     $this->assertNoCacheTag('search_index:user_search');
     // User search results.
     $edit['keys'] = $this->searchingUser->getUsername();
     $this->drupalPostForm('search/user', $edit, t('Search'));
     $this->assertCacheTag('config:search.page.user_search');
     $this->assertCacheTag('user_list');
     $this->assertCacheTag('user:2');
     $this->assertNoCacheTag('search_index');
     $this->assertNoCacheTag('search_index:user_search');
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:58,代码来源:SearchPageCacheTagsTest.php

示例2: testDeleteNode

 /**
  * Tests that when a node is deleted, the node counter is deleted too.
  */
 function testDeleteNode()
 {
     $this->config('statistics.settings')->set('count_content_views', 1)->save();
     $this->drupalGet('node/' . $this->testNode->id());
     // Manually calling statistics.php, simulating ajax behavior.
     $nid = $this->testNode->id();
     $post = array('nid' => $nid);
     global $base_url;
     $stats_path = $base_url . '/' . drupal_get_path('module', 'statistics') . '/statistics.php';
     $this->client->post($stats_path, array('body' => $post));
     $result = db_select('node_counter', 'n')->fields('n', array('nid'))->condition('n.nid', $this->testNode->id())->execute()->fetchAssoc();
     $this->assertEqual($result['nid'], $this->testNode->id(), 'Verifying that the node counter is incremented.');
     $this->testNode->delete();
     $result = db_select('node_counter', 'n')->fields('n', array('nid'))->condition('n.nid', $this->testNode->id())->execute()->fetchAssoc();
     $this->assertFalse($result, 'Verifying that the node counter is deleted.');
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:19,代码来源:StatisticsAdminTest.php


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