本文整理汇总了PHP中PHPUnit_Framework_TestCase::assertArrayHasKey方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_TestCase::assertArrayHasKey方法的具体用法?PHP PHPUnit_Framework_TestCase::assertArrayHasKey怎么用?PHP PHPUnit_Framework_TestCase::assertArrayHasKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_TestCase
的用法示例。
在下文中一共展示了PHPUnit_Framework_TestCase::assertArrayHasKey方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assertArrayHasKey
public static function assertArrayHasKey($key, $value)
{
try {
return parent::assertArrayHasKey($key, $value);
} catch (Exception $e) {
return;
}
}
示例2: testGetSkypeButton
/**
* @dataProvider optionsDataProvider
* @param string $username
* @param array $options
* @param array $expectedOptions
* @param string $expectedTemplate
*/
public function testGetSkypeButton($username, $options, $expectedOptions, $expectedTemplate)
{
$env = $this->getMockBuilder('\\Twig_Environment')->disableOriginalConstructor()->getMock();
$env->expects($this->once())->method('render')->with($expectedTemplate, $this->anything())->will($this->returnCallback(function ($template, $options) use($expectedOptions, $username) {
\PHPUnit_Framework_TestCase::assertArrayHasKey('name', $options['options']);
\PHPUnit_Framework_TestCase::assertEquals($expectedOptions['name'], $options['options']['name']);
\PHPUnit_Framework_TestCase::assertArrayHasKey('participants', $options['options']);
\PHPUnit_Framework_TestCase::assertEquals($expectedOptions['participants'], $options['options']['participants']);
\PHPUnit_Framework_TestCase::assertArrayHasKey('element', $options['options']);
\PHPUnit_Framework_TestCase::assertContains('skype_button_' . md5($username), $options['options']['element']);
return 'BUTTON_CODE';
}));
$this->assertEquals('BUTTON_CODE', $this->extension->getSkypeButton($env, $username, $options));
}
示例3: testInvokesDefaultErrorFormatterWhenDebugIsEnabledAndThrowableCaught
/**
* @dataProvider throwables
*/
public function testInvokesDefaultErrorFormatterWhenDebugIsEnabledAndThrowableCaught($throwable)
{
$next = function () use($throwable) {
throw $throwable;
};
$this->renderer->render(ErrorHandler::TEMPLATE_ERROR, Argument::that(function ($argument) use($throwable) {
TestCase::assertInternalType('array', $argument);
TestCase::assertArrayHasKey('error', $argument);
$error = $argument['error'];
TestCase::assertContains($throwable->getMessage(), $error);
TestCase::assertContains((string) $throwable->getCode(), $error);
TestCase::assertContains($throwable->getTraceAsString(), $error);
return true;
}))->willReturn('error content');
$handler = new ErrorHandler($this->renderer->reveal(), true);
$result = $handler($this->createRequestMock()->reveal(), $this->createResponseMock()->reveal(), $next);
$this->assertInstanceOf(HtmlResponse::class, $result);
$this->assertEquals(500, $result->getStatusCode());
$this->assertEquals('error content', (string) $result->getBody());
}
示例4: assertTraitExists
/**
* Assert Trait Exists
*
* @param string $expected
* @param Object $object
* @param string $message
*
* @return void
* @throws
*/
public function assertTraitExists($expected, $object, $message = '')
{
$traits = class_uses($object);
$message = $message ?: sprintf("Failed asserting not exists Trait instance of interface '%s'.", $expected);
PHPUnit::assertArrayHasKey($expected, $traits, $message);
}
示例5: log
/**
* Logs with an arbitrary level.
*
* @param mixed $level
* @param string $message
* @param array $context
* @return null
*/
public function log($level, $message, array $context = array())
{
$this->owner->assertArrayHasKey($this->index, $this->expected);
$this->owner->assertStringStartsWith($this->expected[$this->index++], $message);
}
示例6: iShouldSeeAJsonField
/**
* @Then I should see a JSON field :name
*/
public function iShouldSeeAJsonField($name)
{
$this->iShouldGetJson();
$data = json_decode($this->getSession()->getPage()->getContent(), true);
Assertions::assertArrayHasKey($name, $data);
}