本文整理匯總了PHP中Prophecy\Prophecy\ObjectProphecy::addHeader方法的典型用法代碼示例。如果您正苦於以下問題:PHP ObjectProphecy::addHeader方法的具體用法?PHP ObjectProphecy::addHeader怎麽用?PHP ObjectProphecy::addHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Prophecy\Prophecy\ObjectProphecy
的用法示例。
在下文中一共展示了ObjectProphecy::addHeader方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testParse
/**
* @dataProvider getDataProvider
*
* @param string $name
* @param array $options
*/
public function testParse($name, array $options)
{
$classMetadataMock = $this->prophesize('Dunglas\\ApiBundle\\Mapping\\ClassMetadataInterface');
$resourceMock = $this->prophesize('Dunglas\\ApiBundle\\Api\\ResourceInterface');
$reflectionClassMock = $this->prophesize('\\ReflectionClass');
$reflectionPropertyMock = $this->prophesize('\\ReflectionProperty');
$attributeMetadataMock = $this->prophesize('Dunglas\\ApiBundle\\Mapping\\AttributeMetadata');
$groupsMock = $this->prophesize('Symfony\\Component\\Serializer\\Annotation\\Groups');
$resourceMock->getEntityClass()->willReturn('\\User')->shouldBeCalledTimes(1);
$resourceMock->getNormalizationGroups()->willReturn(['user_output'])->shouldBeCalledTimes(1);
$resourceMock->getDenormalizationGroups()->willReturn(['user_input'])->shouldBeCalled();
$resourceMock->getValidationGroups()->shouldBeCalledTimes(1);
$this->requestMock->getResource()->willReturn($resourceMock->reveal())->shouldBeCalledTimes(1);
$this->classMetadataFactoryMock->getMetadataFor('\\User', ['user_output'], ['user_input'], null)->willReturn($classMetadataMock->reveal())->shouldBeCalledTimes(1);
$this->requestMock->addHeader('Content-Type', 'application/json')->shouldBeCalledTimes(1);
$this->requestMock->setDataMode(Request::DATA_MODE_RAW)->shouldBeCalledTimes(1);
$classMetadataMock->getAttributes()->willReturn([$attributeMetadataMock->reveal()])->shouldBeCalledTimes(1);
$attributeMetadataMock->getName()->willReturn($name)->shouldBeCalled();
$classMetadataMock->getReflectionClass()->willReturn($reflectionClassMock->reveal())->shouldBeCalled();
$reflectionClassMock->hasProperty($name)->willReturn($options['property'])->shouldBeCalledTimes(1);
if ($options['property']) {
$reflectionClassMock->getProperty($name)->willReturn($reflectionPropertyMock->reveal())->shouldBeCalledTimes(1);
$this->readerMock->getPropertyAnnotation($reflectionPropertyMock->reveal(), 'Symfony\\Component\\Serializer\\Annotation\\Groups')->willReturn($groupsMock->reveal())->shouldBeCalledTimes(1);
$attributeMetadataMock->isIdentifier()->willReturn($options['identifier'])->shouldBeCalledTimes(1);
if (!$options['identifier']) {
$attributeMetadataMock->isReadable()->willReturn($options['readable'])->shouldBeCalledTimes(1);
if ($options['readable']) {
$groupsMock->getGroups()->willReturn($options['groups'])->shouldBeCalledTimes(1);
if (in_array('user_input', $options['groups'])) {
$this->guesserMock->guess($attributeMetadataMock->reveal())->willReturn('bar')->shouldBeCalledTimes(1);
}
}
}
}
$this->requestMock->setRawModeData($options['value'])->shouldBeCalledTimes(1);
$this->parser->parse($this->requestMock->reveal());
}
示例2: testParse
public function testParse()
{
$this->requestMock->addHeader('Authorization', 'Bearer {{oauth2_access_token}}')->shouldBeCalledTimes(1);
$parser = new OAuth2RequestParser('oauth2');
$parser->parse($this->requestMock->reveal());
}