当前位置: 首页>>代码示例>>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;未经允许,请勿转载。