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


PHP Connection::expects方法代碼示例

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


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

 /**
  * Tests ContentEntityDatabaseStorage::onEntityTypeCreate().
  *
  * @covers ::__construct
  * @covers ::onEntityTypeCreate
  * @covers ::getTableMapping
  */
 public function testOnEntityTypeCreate()
 {
     $columns = array('value' => array('type' => 'int'));
     $this->fieldDefinitions = $this->mockFieldDefinitions(array('id'));
     $this->fieldDefinitions['id']->expects($this->any())->method('getColumns')->will($this->returnValue($columns));
     $this->fieldDefinitions['id']->expects($this->once())->method('getSchema')->will($this->returnValue(array('columns' => $columns)));
     $this->entityType->expects($this->once())->method('getKeys')->will($this->returnValue(array('id' => 'id')));
     $this->entityType->expects($this->any())->method('getKey')->will($this->returnValueMap(array(array('id', 'id'), array('uuid', NULL), array('bundle', NULL), array('id' => 'id'), array('id' => 'id'))));
     $this->setUpEntityStorage();
     $expected = array('description' => 'The base table for entity_test entities.', 'fields' => array('id' => array('type' => 'serial', 'not null' => TRUE)), 'primary key' => array('id'), 'unique keys' => array(), 'indexes' => array(), 'foreign keys' => array());
     $schema_handler = $this->getMockBuilder('Drupal\\Core\\Database\\Schema')->disableOriginalConstructor()->getMock();
     $schema_handler->expects($this->any())->method('createTable')->with($this->equalTo('entity_test'), $this->equalTo($expected));
     $this->connection->expects($this->once())->method('schema')->will($this->returnValue($schema_handler));
     $storage = $this->getMockBuilder('Drupal\\Core\\Entity\\Sql\\SqlContentEntityStorage')->setConstructorArgs(array($this->entityType, $this->connection, $this->entityManager, $this->cache, $this->languageManager))->setMethods(array('getStorageSchema'))->getMock();
     $key_value = $this->getMock('Drupal\\Core\\KeyValueStore\\KeyValueStoreInterface');
     $schema_handler = $this->getMockBuilder('Drupal\\Core\\Entity\\Sql\\SqlContentEntityStorageSchema')->setConstructorArgs(array($this->entityManager, $this->entityType, $storage, $this->connection))->setMethods(array('installedStorageSchema', 'createSharedTableSchema'))->getMock();
     $schema_handler->expects($this->any())->method('installedStorageSchema')->will($this->returnValue($key_value));
     $storage->expects($this->any())->method('getStorageSchema')->will($this->returnValue($schema_handler));
     $storage->onEntityTypeCreate($this->entityType);
 }
開發者ID:ddrozdik,項目名稱:dmaps,代碼行數:27,代碼來源:SqlContentEntityStorageTest.php

示例3: testDeleteProviders

 /**
  * @covers ::deleteProvider
  * @covers ::__construct
  */
 function testDeleteProviders()
 {
     $this->connection->expects($this->once())->method('delete')->with($this->equalTo('authmap'))->will($this->returnValue($this->delete));
     $authmap = new Authmap($this->connection);
     $authmap->delete("test_provider");
 }
開發者ID:C4AProjects,項目名稱:c4apage,代碼行數:10,代碼來源:AuthmapTest.php


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