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


PHP PHPUnit_Framework_TestCase::expects方法代码示例

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


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

示例1: testMainFlow

 /**
  * @dataProvider callbackDataProvider
  *
  * @param string $expectedMessage
  * @param string $expectedMethod
  * @param string $exceptionClass
  * @throws
  */
 public function testMainFlow($expectedMessage, $expectedMethod, $exceptionClass)
 {
     $this->_testCase->expects($this->any())->method($expectedMethod)->with($this->stringStartsWith($expectedMessage));
     $this->_invoker->__invoke(function () use($exceptionClass) {
         throw new $exceptionClass('Some meaningful message.');
     }, [[0]]);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:AggregateInvokerTest.php

示例2: testMerge

 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testMerge()
 {
     $fieldData = $this->createFieldData();
     $fieldMetadataData = $this->createFieldMetadata();
     $entityData = $this->createEntityData();
     $masterEntity = new EntityStub(1);
     $sourceEntity = new EntityStub(2);
     $collectionItem1 = new CollectionItemStub(1);
     $collectionItem2 = new CollectionItemStub(2);
     $masterEntity->addCollectionItem($collectionItem1);
     $sourceEntity->addCollectionItem($collectionItem2);
     $entities = [$masterEntity, $sourceEntity];
     $relatedEntities = [$collectionItem1, $collectionItem2];
     $fieldData->expects($this->once())->method('getEntityData')->will($this->returnValue($entityData));
     $fieldData->expects($this->once())->method('getMetadata')->will($this->returnValue($fieldMetadataData));
     $entityData->expects($this->once())->method('getEntities')->will($this->returnValue($entities));
     $entityData->expects($this->once())->method('getMasterEntity')->will($this->returnValue($masterEntity));
     $this->doctrineHelper->expects($this->any())->method('getEntityIdentifierValue')->will($this->returnCallback(function ($value) {
         return $value->getId();
     }));
     $fieldDoctrineMetadata = $this->createDoctrineMetadata();
     $fieldDoctrineMetadata->expects($this->any())->method('getFieldName')->will($this->returnValue('field_name'));
     $fieldMetadataData->expects($this->any())->method('getDoctrineMetadata')->will($this->returnValue($fieldDoctrineMetadata));
     $fieldMetadataData->expects($this->any())->method('getFieldName')->will($this->returnValue('collection'));
     $fieldMetadataData->expects($this->any())->method('has')->will($this->returnValue(true));
     $fieldMetadataData->expects($this->any())->method('get')->will($this->returnValue('setEntityStub'));
     $repository = $this->getMockBuilder('Doctrine\\Common\\Persistence\\ObjectRepository')->disableOriginalConstructor()->getMock();
     $this->doctrineHelper->expects($this->any())->method('getEntityRepository')->will($this->returnValue($repository));
     $repository->expects($this->any())->method('findBy')->will($this->returnCallback(function ($values) use($relatedEntities) {
         return [$relatedEntities[$values['field_name']->getId() - 1]];
     }));
     $this->strategy->merge($fieldData);
     $this->assertEquals($masterEntity, $collectionItem1->getEntityStub());
     $this->assertEquals($masterEntity, $collectionItem2->getEntityStub());
 }
开发者ID:Maksold,项目名称:platform,代码行数:38,代码来源:UniteStrategyTest.php

示例3: testShouldAcceptOnlyREQSockets

 /**
  * @test should accept only REQ sockets
  */
 public function testShouldAcceptOnlyREQSockets()
 {
     $this->socket = $this->getMockBuilder('\\ZMQSocket')->disableOriginalConstructor()->getMock();
     $this->socket->expects($this->any())->method('getSocketType')->will($this->returnValue(\ZMQ::SOCKET_PUSH));
     $this->setExpectedException('\\InvalidArgumentException', 'Invalid socket type');
     new ZeroMQClientTransport($this->socket);
 }
开发者ID:wookieb,项目名称:zorro-rpc,代码行数:10,代码来源:ZeroMQClientTransportTest.php

示例4: testConstructorAndGetters

 /**
  * Test constructor and getters
  *
  * @dataProvider constructorAndGettersDataProvider
  */
 public function testConstructorAndGetters($method, $key, $expectedValue)
 {
     $this->builderMock->expects($this->once())->method('getData')->will($this->returnValue([$key => $expectedValue]));
     $attributeMetadata = new AttributeMetadata($this->builderMock);
     $this->assertEquals($expectedValue, $attributeMetadata->{$method}());
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:11,代码来源:AttributeMetadataTest.php

示例5: testEndTest

 /**
  * @covers Mage_Testlink_Annotation::endTest
  */
 public function testEndTest()
 {
     $this->_testCaseMock->expects($this->never())->method('getAnnotations');
     $this->_connectorMock->expects($this->never())->method('report');
     $this->assertNull($this->_annotationMock->endTest());
 }
开发者ID:venkateshcontus,项目名称:taf,代码行数:9,代码来源:AnnotationTest.php


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