本文整理汇总了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]]);
}
示例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());
}
示例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);
}
示例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}());
}
示例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());
}