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


PHP Assertion::same方法代码示例

本文整理汇总了PHP中Assert\Assertion::same方法的典型用法代码示例。如果您正苦于以下问题:PHP Assertion::same方法的具体用法?PHP Assertion::same怎么用?PHP Assertion::same使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Assert\Assertion的用法示例。


在下文中一共展示了Assertion::same方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: withTypes

 /**
  * @param array $types
  *
  * @throws \InvalidArgumentException
  *
  * @return static
  */
 public function withTypes(array $types)
 {
     $choices = [PlatformInterface::TYPE_MOBILE, PlatformInterface::TYPE_TV, PlatformInterface::TYPE_WEB];
     Assertion::allChoice($types, $choices);
     Assertion::same($types, array_unique($types));
     $instance = clone $this;
     $instance->types = $types;
     return $instance;
 }
开发者ID:refinery29,项目名称:sitemap,代码行数:16,代码来源:Platform.php

示例2: deserialize

 public function deserialize($rawData, $format)
 {
     Assertion::same('json', $format, 'No other format is supported');
     $coupons = json_decode($rawData, true);
     $dto = new Coupons();
     foreach ($coupons as $couponArray) {
         $dto->addCoupon($this->createCouponFromArray($couponArray));
     }
     return $dto;
 }
开发者ID:matthiasnoback,项目名称:leanpub-api-client,代码行数:10,代码来源:CouponsDeserializer.php

示例3: deserialize

 public function deserialize($rawData, $format)
 {
     Assertion::same('json', $format, 'No other format is supported');
     $purchases = json_decode($rawData, true);
     $dto = new IndividualPurchases();
     foreach ($purchases as $purchaseArray) {
         $dto->addPurchase($this->createPurchaseFromArray($purchaseArray));
     }
     return $dto;
 }
开发者ID:matthiasnoback,项目名称:leanpub-api-client,代码行数:10,代码来源:IndividualPurchasesDeserializer.php

示例4: retrieveExchangeRateFor

 /**
  * Retrieves exchange rates from http://fixer.io
  *
  * @param Currency $currency
  */
 private function retrieveExchangeRateFor(Currency $currency)
 {
     $response = $this->client->request('GET', self::EXCHANGE_RATE_API_URL . '/latest', ['query' => ['base' => $this->baseCurrency->getName()]]);
     Assert::same($response->getStatusCode(), 200);
     $rawExchangeRates = $response->getBody();
     $exchangeRates = json_decode($rawExchangeRates, true);
     Assert::isArray($exchangeRates);
     Assert::keyExists($exchangeRates, 'rates');
     Assert::keyExists($exchangeRates['rates'], $currency->getName());
     Assert::numeric($exchangeRates['rates'][$currency->getName()]);
     $this->exchangeRates[$currency->getName()] = $exchangeRates['rates'][$currency->getName()];
 }
开发者ID:rgeraads,项目名称:exchange-rate,代码行数:17,代码来源:FixerIoExchangeRateRetriever.php

示例5: heShouldSeeTheFollowingData

 /**
  * @Then he should see the following data:
  *
  * @param TableNode $table
  */
 public function heShouldSeeTheFollowingData(TableNode $table)
 {
     $hash = $table->getHash();
     $em = $this->getEntityManager();
     Assertion::count($this->response, count($hash));
     foreach ($hash as $row) {
         $username = $row['username'];
         $isOnline = $row['is_online'] === 'true';
         $userId = $em->getRepository('Account:User')->findOneBy(['username' => $username])->getId();
         Assertion::keyExists($this->response, $userId);
         Assertion::same($isOnline, $this->response[$userId]);
     }
 }
开发者ID:thomasmodeneis,项目名称:Sententiaregum,代码行数:18,代码来源:OnlineUsersContext.php

示例6: retrieveExchangeRateFor

 /**
  * Retrieves exchange rates from http://free.currencyconverterapi.com
  *
  * @param Currency $currency
  */
 private function retrieveExchangeRateFor(Currency $currency)
 {
     $conversion = sprintf('%s_%s', $currency->getName(), $this->baseCurrency->getName());
     $response = $this->client->request('GET', self::EXCHANGE_RATE_API_URL . '/api/v3/convert', ['query' => ['q' => $conversion]]);
     Assert::same($response->getStatusCode(), 200);
     $rawExchangeRates = $response->getBody();
     $exchangeRates = json_decode($rawExchangeRates, true);
     Assert::isArray($exchangeRates);
     Assert::keyExists($exchangeRates, 'results');
     Assert::keyExists($exchangeRates['results'], $conversion);
     Assert::keyExists($exchangeRates['results'][$conversion], 'val');
     Assert::numeric($exchangeRates['results'][$conversion]['val']);
     $this->exchangeRates[$currency->getName()] = (double) $exchangeRates['results'][$conversion]['val'];
 }
开发者ID:rgeraads,项目名称:exchange-rate,代码行数:19,代码来源:CurrencyConverterApiExchangeRateRetriever.php

示例7: __construct

 /**
  * @param int|null $userId
  * @param int $rightId
  * @param null|string $forObjectGroup
  * @param null|string $withId
  */
 public function __construct($userId, $rightId, $forObjectGroup, $withId)
 {
     Assertion::nullOrInteger($userId);
     Assertion::integer($rightId);
     Assertion::nullOrString($forObjectGroup);
     //If there is no object group, there can not be an id
     if ($forObjectGroup === null) {
         Assertion::same($withId, null);
     } else {
         Assertion::nullOrString($withId);
     }
     $this->userId = $userId;
     $this->rightId = $rightId;
     $this->forObjectGroup = $forObjectGroup;
     $this->withId = $withId;
 }
开发者ID:jonasrudolph,项目名称:php-component-user,代码行数:22,代码来源:UserRight.php

示例8: evaluate

 public function evaluate($expected, $message)
 {
     switch ($this->strategy) {
         case 0:
             $message = sprintf($message, $this->value, $expected);
             Assertion::same($this->value, $expected, $message);
             break;
         case 1:
             $message = sprintf('Expected `%s` to match regex `%s`, but it didn\'t`', $expected, $this->value);
             Assertion::regex($expected, $this->value, $message);
             break;
         case 2:
             $message = sprintf($message, $this->value, gettype($expected));
             Assertion::same($this->value, gettype($expected), $message);
             break;
     }
 }
开发者ID:alexbilbie,项目名称:fizzfuzz,代码行数:17,代码来源:Expectation.php

示例9: existsUserRight

 public function existsUserRight($userId, $rightId, $forObject, $withId)
 {
     Assertion::nullOrInteger($userId);
     Assertion::integer($rightId);
     Assertion::nullOrString($forObject);
     //If there is no forObject, there can not be an withId
     if ($forObject === null) {
         Assertion::same($withId, null);
     } else {
         Assertion::nullOrString($withId);
     }
     if ($userId !== null && !$this->userService->existsUserById($userId)) {
         throw new UserDoesNotExistException();
     }
     if (!$this->rightService->existsRightById($rightId)) {
         throw new RightNotFoundException();
     }
     return $this->getORMUserRight($userId, $rightId, $forObject, $withId) !== null;
 }
开发者ID:jonasrudolph,项目名称:php-component-user-propel,代码行数:19,代码来源:UserRightService.php

示例10: theCommandHasFinishedSuccessfully

 /**
  * @Then /^the command has finished successfully$/
  */
 public function theCommandHasFinishedSuccessfully()
 {
     Assertion::same($this->tester->getStatusCode(), 0);
 }
开发者ID:stof,项目名称:symfony-console-form,代码行数:7,代码来源:FeatureContext.php

示例11: getValue

 /**
  * @return mixed
  */
 public function getValue()
 {
     Assertion::same(null, $this->formErrorSequence, 'Value can only be retrieved when bind result was successful');
     return $this->value;
 }
开发者ID:dasprid,项目名称:formidable,代码行数:8,代码来源:BindResult.php

示例12: testSame

 public function testSame()
 {
     Assertion::same(1, 1);
     Assertion::same("foo", "foo");
     Assertion::same($obj = new \stdClass(), $obj);
     $this->setExpectedException('Assert\\AssertionFailedException', null, Assertion::INVALID_SAME);
     Assertion::same(new \stdClass(), new \stdClass());
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:8,代码来源:AssertTest.php

示例13: theResponseCodeShouldBe

 /**
  * @Then the response code should be :code
  */
 public function theResponseCodeShouldBe($code)
 {
     $expected = intval($code);
     $actual = intval($this->client->getResponse()->getStatusCode());
     Assertion::same($expected, $actual);
 }
开发者ID:Im0rtality,项目名称:rest-api-bundle,代码行数:9,代码来源:FeatureContext.php

示例14: performRequest

 /**
  * Performs a request to the symfony application and returns the response.
  *
  * @param string   $method
  * @param string   $uri
  * @param mixed[]  $parameters
  * @param bool     $expectSuccess
  * @param string[] $headers
  * @param mixed[]  $files
  * @param int      $expectedStatus
  * @param bool     $toJson
  * @param string   $apiKey
  * @param bool     $disableAssertions
  *
  * @throws \Exception If the json decode did not work
  *
  * @return string[]
  */
 protected function performRequest($method, $uri, array $parameters = [], $expectSuccess = true, array $headers = [], array $files = [], $expectedStatus = 200, $toJson = true, $apiKey = null, $disableAssertions = false)
 {
     if (null !== $apiKey || null !== AppContext::$apiKey) {
         $headers[ApiKeyAuthenticator::API_KEY_HEADER] = $apiKey ?: AppContext::$apiKey;
     }
     $headers = array_combine(array_map(function ($headerName) {
         return sprintf('HTTP_%s', $headerName);
     }, array_keys($headers)), array_values($headers));
     /** @var \Symfony\Bundle\FrameworkBundle\Client $client */
     $client = $this->getContainer()->get('test.client');
     $client->enableProfiler();
     $client->request($method, $uri, $parameters, $files, $headers);
     $response = $client->getResponse();
     if (!$disableAssertions) {
         $status = $response->getStatusCode();
         if ($expectSuccess) {
             Assertion::greaterOrEqualThan($status, 200);
             Assertion::lessOrEqualThan($status, 399);
         } else {
             Assertion::greaterOrEqualThan($status, 400);
             Assertion::lessOrEqualThan($status, 599);
         }
         Assertion::same($expectedStatus, $status);
     }
     $this->recentClient = $client;
     if ($toJson) {
         $content = $response->getContent();
         if (empty($content)) {
             $raw = null;
         } else {
             $raw = json_decode($content, true);
             Assertion::same(JSON_ERROR_NONE, json_last_error());
         }
         return $raw;
     }
     return $response;
 }
开发者ID:thomasmodeneis,项目名称:Sententiaregum,代码行数:55,代码来源:BaseContext.php

示例15: withPriority

 /**
  * @param float $priority
  *
  * @throws \InvalidArgumentException
  *
  * @return static
  */
 public function withPriority($priority)
 {
     Assertion::float($priority);
     Assertion::greaterOrEqualThan($priority, UrlInterface::PRIORITY_MIN);
     Assertion::lessOrEqualThan($priority, UrlInterface::PRIORITY_MAX);
     Assertion::same($priority, round($priority, 1));
     $instance = clone $this;
     $instance->priority = $priority;
     return $instance;
 }
开发者ID:refinery29,项目名称:sitemap,代码行数:17,代码来源:Url.php


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