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


PHP PHPUnit_Framework_Assert::assertArrayHasKey方法代码示例

本文整理汇总了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));
 }
开发者ID:php-lug,项目名称:lug,代码行数:14,代码来源:GridApiContext.php

示例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);
 }
开发者ID:elifesciences,项目名称:isolated-drupal-behat-extension,代码行数:31,代码来源:InstallSiteListenerTest.php

示例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);
     }
 }
开发者ID:pago,项目名称:pantr,代码行数:8,代码来源:Matcher.php

示例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.');
     }
 }
开发者ID:hientruong90,项目名称:magento2_installer,代码行数:15,代码来源:Assert3dSecureInfoIsPresent.php

示例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']);
 }
开发者ID:nikitgs,项目名称:oauth2-server-laravel,代码行数:12,代码来源:FeatureContext.php

示例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']);
     }
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:14,代码来源:OperationsProviderTestTrait.php

示例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}";
     }
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:16,代码来源:ApiModuleTestHelper.php

示例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();
 }
开发者ID:treehouselabs,项目名称:behat-common,代码行数:17,代码来源:RedirectContext.php

示例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'));
 }
开发者ID:videodock,项目名称:enum,代码行数:14,代码来源:EnumTest.php

示例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]);
         }
     }
 }
开发者ID:N3m1s,项目名称:ElasticsearchBundle,代码行数:17,代码来源:TestHelperTrait.php

示例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}");
     }
 }
开发者ID:robinhood-zz,项目名称:WebDriver-PHP,代码行数:11,代码来源:Driver.php

示例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});
     }
 }
开发者ID:hilmysyarif,项目名称:sisfito,代码行数:21,代码来源:AssertionsTrait.php

示例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;
     }
 }
开发者ID:Combination,项目名称:BehatDatabaseFixtureExtension,代码行数:25,代码来源:CoreContext.php

示例14: toHaveKey

 public function toHaveKey($key)
 {
     if ($this->negate) {
         a::assertArrayNotHasKey($key, $this->actual);
     } else {
         a::assertArrayHasKey($key, $this->actual);
     }
 }
开发者ID:jasonmccreary,项目名称:expect,代码行数:8,代码来源:Expect.php

示例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());
 }
开发者ID:mgdigital,项目名称:busque,代码行数:12,代码来源:RedisDriverSpec.php


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