當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SelectInterface::expects方法代碼示例

本文整理匯總了PHP中Drupal\Core\Database\Query\SelectInterface::expects方法的典型用法代碼示例。如果您正苦於以下問題:PHP SelectInterface::expects方法的具體用法?PHP SelectInterface::expects怎麽用?PHP SelectInterface::expects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\Core\Database\Query\SelectInterface的用法示例。


在下文中一共展示了SelectInterface::expects方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUp

 /**
  * Sets up required mocks and the CommentStatistics service under test.
  */
 protected function setUp()
 {
     $this->statement = $this->getMockBuilder('Drupal\\Core\\Database\\Driver\\sqlite\\Statement')->disableOriginalConstructor()->getMock();
     $this->statement->expects($this->any())->method('fetchObject')->will($this->returnCallback(array($this, 'fetchObjectCallback')));
     $this->select = $this->getMockBuilder('Drupal\\Core\\Database\\Query\\Select')->disableOriginalConstructor()->getMock();
     $this->select->expects($this->any())->method('fields')->will($this->returnSelf());
     $this->select->expects($this->any())->method('condition')->will($this->returnSelf());
     $this->select->expects($this->any())->method('execute')->will($this->returnValue($this->statement));
     $this->database = $this->getMockBuilder('Drupal\\Core\\Database\\Connection')->disableOriginalConstructor()->getMock();
     $this->database->expects($this->once())->method('select')->will($this->returnValue($this->select));
     $this->commentStatistics = new CommentStatistics($this->database, $this->getMock('Drupal\\Core\\Session\\AccountInterface'), $this->getMock('Drupal\\Core\\Entity\\EntityManagerInterface'), $this->getMock('Drupal\\Core\\State\\StateInterface'));
 }
開發者ID:sarahwillem,項目名稱:OD8,代碼行數:15,代碼來源:CommentStatisticsUnitTest.php

示例2: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Create a Mock database connection object.
     $this->connection = $this->getMockBuilder('Drupal\\Core\\Database\\Connection')->disableOriginalConstructor()->getMock();
     // Create a Mock Statement object
     $this->statement = $this->getMockBuilder('Drupal\\Core\\Database\\Driver\\sqlite\\Statement')->disableOriginalConstructor()->getMock();
     // Create a Mock Select object and set expectations.
     $this->select = $this->getMockBuilder('Drupal\\Core\\Database\\Query\\Select')->disableOriginalConstructor()->getMock();
     $this->select->expects($this->any())->method('fields')->will($this->returnSelf());
     $this->select->expects($this->any())->method('condition')->will($this->returnSelf());
     $this->select->expects($this->any())->method('range')->will($this->returnSelf());
     $this->select->expects($this->any())->method('orderBy')->will($this->returnSelf());
     $this->select->expects($this->any())->method('execute')->will($this->returnValue($this->statement));
     $this->connection->expects($this->any())->method('select')->will($this->returnValue($this->select));
     // Create a Mock Delete object and set expectations.
     $this->delete = $this->getMockBuilder('Drupal\\Core\\Database\\Query\\Delete')->disableOriginalConstructor()->getMock();
     $this->delete->expects($this->any())->method('condition')->will($this->returnSelf());
     $this->delete->expects($this->any())->method('execute')->will($this->returnValue($this->statement));
 }
開發者ID:C4AProjects,項目名稱:c4apage,代碼行數:23,代碼來源:AuthmapTest.php


注:本文中的Drupal\Core\Database\Query\SelectInterface::expects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。