當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。