本文整理汇总了PHP中PHPUnit_Framework_Assert::assertArrayHasKey方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_Assert::assertArrayHasKey方法的具体用法?PHP PHPUnit_Framework_Assert::assertArrayHasKey怎么用?PHP PHPUnit_Framework_Assert::assertArrayHasKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_Assert
的用法示例。
在下文中一共展示了PHPUnit_Framework_Assert::assertArrayHasKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: decodeByProperty
/**
* @param string $property
* @param string $format
*
* @return mixed[]
*/
private function decodeByProperty($property, $format)
{
return array_map(function ($entry) use($property) {
\PHPUnit_Framework_Assert::assertInternalType('array', $entry);
\PHPUnit_Framework_Assert::assertArrayHasKey($property, $entry);
return $entry[$property];
}, $this->decode($format));
}
示例2: itInstallsASite
/**
* @test
* @dataProvider eventProvider
*/
public function itInstallsASite($eventName, LifecycleEvent $event)
{
$dispatcher = $this->prophesize('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
$drupal = $this->generateDrupal();
$processRunner = $this->prophesize('eLife\\IsolatedDrupalBehatExtension\\Process\\ProcessRunner');
$listener = new InstallSiteListener($dispatcher->reveal(), $drupal, '/path/to/drush', $processRunner->reveal());
$dispatcher->dispatch(InstallingSite::NAME, Argument::type('eLife\\IsolatedDrupalBehatExtension\\Event\\InstallingSite'))->shouldBeCalledTimes(1)->should(new CallbackPrediction(function (array $calls) use($drupal) {
/** @var Call $call */
$call = $calls[0];
/** @var InstallingSite $event */
$event = $call->getArguments()[1];
$process = $event->getCommand()->getProcess();
Assert::assertSame("'/path/to/drush' 'site-install' 'standard' " . "'--sites-subdir=localhost' '--account-name=admin' " . "'--account-pass=password' '--yes'", $process->getCommandLine());
Assert::assertArrayHasKey('PHP_OPTIONS', $process->getEnv());
Assert::assertSame('-d sendmail_path=' . `which true`, $process->getEnv()['PHP_OPTIONS']);
Assert::assertSame($drupal->getPath(), $process->getWorkingDirectory());
}));
$processRunner->run(Argument::type('Symfony\\Component\\Process\\Process'))->shouldBeCalledTimes(1);
$dispatcher->dispatch(SiteInstalled::NAME, Argument::type('eLife\\IsolatedDrupalBehatExtension\\Event\\SiteInstalled'))->shouldBeCalledTimes(1)->should(new CallbackPrediction(function (array $calls) use($drupal) {
/** @var Call $call */
$call = $calls[0];
/** @var SiteInstalled $event */
$event = $call->getArguments()[1];
Assert::assertEquals($drupal, $event->getDrupal());
}));
$this->getDispatcher($listener)->dispatch($eventName, $event);
}
示例3: shouldHaveKey
public function shouldHaveKey($key)
{
if ($this->it instanceof \ArrayAccess) {
Assert::assertEquals(isset($this->it[$key]), true, 'key ' . $key . ' does not exist');
} else {
Assert::assertArrayHasKey($key, $this->it);
}
}
示例4: processAssert
/**
* Assert that 3D Secure information is present on order page in Admin.
*
* @param SalesOrderView $salesOrderView
* @param array $paymentInformation
* @return void
*/
public function processAssert(SalesOrderView $salesOrderView, array $paymentInformation)
{
$actualPaymentInformation = $salesOrderView->getBraintreeInfoBlock()->getPaymentInfo();
foreach ($paymentInformation as $key => $value) {
\PHPUnit_Framework_Assert::assertArrayHasKey($key, $actualPaymentInformation, '3D Secure information is not present.');
\PHPUnit_Framework_Assert::assertEquals($paymentInformation[$key], $value, '3D Secure information is not equal to information from data set.');
}
}
示例5: iShouldGetAnAccessToken
/**
* @Then /^I should get an access token\.$/
*/
public function iShouldGetAnAccessToken()
{
$this->assertResponseStatus(200);
$content = json_decode($this->client->getResponse()->getContent(), true);
PHPUnit::assertArrayHasKey('access_token', $content);
PHPUnit::assertArrayHasKey('expires_in', $content);
PHPUnit::assertArrayHasKey('token_type', $content);
PHPUnit::assertEquals('Bearer', $content['token_type']);
}
示例6: assertOperationsLinks
/**
* Checks the integrity of operations links.
*
* @param mixed[] $operations_links
*/
protected function assertOperationsLinks(array $operations_links)
{
foreach ($operations_links as $link) {
\PHPUnit_Framework_Assert::assertArrayHasKey('title', $link);
\PHPUnit_Framework_Assert::assertNotEmpty($link['title']);
\PHPUnit_Framework_Assert::assertArrayHasKey('url', $link);
\PHPUnit_Framework_Assert::assertInstanceOf(Url::class, $link['url']);
}
}
示例7: assertResultHasKeyInPath
/**
* Asserts the existence of some path in the result, represented by any additional parameters.
*
* @param string[] $path
* @param array $response
*/
public function assertResultHasKeyInPath(array $path, array $response)
{
$obj = $response;
$p = '/';
foreach ($path as $key) {
Assert::assertArrayHasKey($key, $obj, "Expected key {$key} under path {$p} in the response.");
$obj = $obj[$key];
$p .= "/{$key}";
}
}
示例8: iAmRedirected
/**
* @Then I should be redirected to :url
* @Then I should be redirected to :url with :status
*
* @param string $url
* @param int $status
*/
public function iAmRedirected($url, $status = 302)
{
$headers = $this->getSession()->getResponseHeaders();
Assert::assertEquals($status, $this->getSession()->getStatusCode());
Assert::assertArrayHasKey('location', $headers, 'The response contains a "location" header');
Assert::assertEquals($url, $headers['location'][0], 'The "location" header does not point to the correct URI');
$client = $this->getClient();
$client->followRedirects(true);
$client->followRedirect();
}
示例9: it_detects_proper_values_and_constants
/**
* @test
*/
public function it_detects_proper_values_and_constants()
{
$enum = new FakeEnum();
\PHPUnit_Framework_Assert::assertContains('SOME_KEY', $enum->keys());
\PHPUnit_Framework_Assert::assertArrayHasKey('SOME_KEY', $enum->values());
\PHPUnit_Framework_Assert::assertArrayNotHasKey('some-value', $enum->values());
\PHPUnit_Framework_Assert::assertContains('some-value', $enum->values());
\PHPUnit_Framework_Assert::assertSame('SOME_KEY', $enum->getConstantForValue('some-value'));
\PHPUnit_Framework_Assert::assertTrue($enum->has('some-value'));
\PHPUnit_Framework_Assert::assertFalse($enum->has('SOME-VALUE'));
}
示例10: assertArrayContainsArray
/**
* Check if one array is subset of another.
*
* @param array $needle Subset.
* @param array $haystack Set.
*/
protected function assertArrayContainsArray($needle, $haystack)
{
foreach ($needle as $key => $val) {
\PHPUnit_Framework_Assert::assertArrayHasKey($key, $haystack);
if (is_array($val)) {
$this->assertArrayContainsArray($val, $haystack[$key]);
} else {
\PHPUnit_Framework_Assert::assertEquals($val, $haystack[$key]);
}
}
}
示例11: check_response_status
private function check_response_status($body, $command_info)
{
$array = json_decode(trim($body), true);
if (!is_null($array)) {
$response_status_code = $array["status"];
PHPUnit_Framework_Assert::assertArrayHasKey($response_status_code, self::$status_codes, "Unknown status code {$response_status_code} returned from server.\n{$body}");
$response_info = $response_status_code . " - " . self::$status_codes[$response_status_code][0] . " - " . self::$status_codes[$response_status_code][1];
$additional_info = isset($array['value']['message']) ? "Message: " . $array['value']['message'] : "Response: " . $body;
PHPUnit_Framework_Assert::assertEquals(0, $response_status_code, "Unsuccessful WebDriver command: {$response_info}\nCommand: {$command_info}\n{$additional_info}");
}
}
示例12: assertViewHas
/**
* Assert that the response view has a given piece of bound data.
*
* @param string|array $key
* @param mixed $value
* @return void
*/
public function assertViewHas($key, $value = null)
{
if (is_array($key)) {
return $this->assertViewHasAll($key);
}
if (!isset($this->response->original) || !$this->response->original instanceof View) {
return PHPUnit::assertTrue(false, 'The response was not a view.');
}
if (is_null($value)) {
PHPUnit::assertArrayHasKey($key, $this->response->original->getData());
} else {
PHPUnit::assertEquals($value, $this->response->original->{$key});
}
}
示例13: thereAreRecordsInWhere
/**
* @Given /^Records in \'([^\']+)\' where \'([^\']+)\', has data$/
* @param $tableName
* @param $where
* @param TableNode $table
* @throws \Doctrine\DBAL\DBALException
* @throws \Exception
*/
public function thereAreRecordsInWhere($tableName, $where, TableNode $table)
{
/** @var Connection $connection */
$connection = $this->container->get('doctrine')->getConnection();
$exists = new ArrayCollection($connection->query("SELECT * FROM {$tableName} WHERE {$where}")->fetchAll());
$criteria = new Criteria();
$recordsMatching = $exists->matching($criteria);
$record = $recordsMatching->first();
$i = 1;
foreach ($table as $row) {
foreach ($row as $key => $value) {
\PHPUnit_Framework_Assert::assertArrayHasKey($key, $record, "Column '{$key}' doesn't exists in database");
\PHPUnit_Framework_Assert::assertEquals($value, $record[$key], "Invalid value for '{$key}' in row {$i}");
}
++$i;
}
}
示例14: toHaveKey
public function toHaveKey($key)
{
if ($this->negate) {
a::assertArrayNotHasKey($key, $this->actual);
} else {
a::assertArrayHasKey($key, $this->actual);
}
}
示例15: it_can_receive_due_scheduled_commands
public function it_can_receive_due_scheduled_commands()
{
$date = new \DateTimeImmutable();
$timestamp = $date->getTimestamp();
$lua = $this->getLua('receive_due_messages');
$this->adapter->evalLua($lua, ['test', 0, $timestamp, SchedulerWorker::DEFAULT_THROTTLE])->shouldBeCalled()->willReturn([['test', 'test', 'test', $timestamp]]);
$commandsWrapper = $this->receiveDueCommands($date);
$commands = $commandsWrapper->getWrappedObject();
\PHPUnit_Framework_Assert::assertArrayHasKey(0, $commands);
\PHPUnit_Framework_Assert::assertArrayNotHasKey(1, $commands);
\PHPUnit_Framework_Assert::assertEquals('test', $commands[0]->getId());
}