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


PHP Assertion::eq方法代码示例

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


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

示例1: populatePayload

 /**
  * @param \Jose\Object\JWSInterface $jws
  * @param array                     $data
  */
 private static function populatePayload(JWSInterface &$jws, array $data)
 {
     $is_encoded = null;
     foreach ($jws->getSignatures() as $signature) {
         if (null === $is_encoded) {
             $is_encoded = self::isPayloadEncoded($signature);
         }
         Assertion::eq($is_encoded, self::isPayloadEncoded($signature), 'Foreign payload encoding detected. The JWS cannot be loaded.');
     }
     if (array_key_exists('payload', $data)) {
         $payload = $data['payload'];
         $jws = $jws->withAttachedPayload();
         $jws = $jws->withEncodedPayload($payload);
         if (false !== $is_encoded) {
             $payload = Base64Url::decode($payload);
         }
         $json = json_decode($payload, true);
         if (null !== $json && !empty($payload)) {
             $payload = $json;
         }
         $jws = $jws->withPayload($payload);
     } else {
         $jws = $jws->withDetachedPayload();
     }
 }
开发者ID:spomky-labs,项目名称:jose,代码行数:29,代码来源:JWSLoader.php

示例2: it_should_create_configured_connection

 public function it_should_create_configured_connection(ConnectionRegistry $registry)
 {
     /** @var Connection $connection */
     $connection = $this->createNamed('default')->shouldReturnAnInstanceOf(Connection::class);
     $registry->addConnection($connection)->shouldHaveBeenCalled();
     Assertion::eq($connection->getWrappedConnection()->getVhost(), 'foo');
 }
开发者ID:Evaneos,项目名称:Hector,代码行数:7,代码来源:ConnectionFactorySpec.php

示例3: unserialize

 /**
  * @param  \stdClass $obj
  * @param  array     $context
  * @return \Twitter\Object\Tweet
  */
 public function unserialize($obj, array $context = [])
 {
     Assertion::true($this->canUnserialize($obj), 'object is not unserializable');
     $createdAt = new \DateTimeImmutable($obj->created_at);
     Assertion::eq(new \DateTimeZone('UTC'), $createdAt->getTimezone());
     return Tweet::create(TwitterMessageId::create($obj->id), $this->userSerializer->unserialize($obj->user), $obj->text, $obj->lang, $createdAt, $obj->entities ? $this->twitterEntitiesSerializer->unserialize($obj->entities) : TwitterEntities::create(), $obj->coordinates ? $this->coordinatesSerializer->unserialize($obj->coordinates) : null, $obj->place ? $this->placeSerializer->unserialize($obj->place) : null, $obj->in_reply_to_status_id, $obj->in_reply_to_user_id, $obj->in_reply_to_screen_name, $obj->retweeted, $obj->retweet_count, $obj->favorited, $obj->favorite_count, $obj->truncated, $obj->source, isset($obj->retweeted_status) ? $this->unserialize($obj->retweeted_status) : null);
 }
开发者ID:remi-san,项目名称:twitter,代码行数:12,代码来源:TweetSerializer.php

示例4: checkKey

 /**
  * @param JWKInterface $key
  */
 private function checkKey(JWKInterface $key)
 {
     Assertion::eq($key->get('kty'), 'OKP', 'Wrong key type.');
     Assertion::true($key->has('x'), 'The key parameter "x" is missing.');
     Assertion::true($key->has('crv'), 'The key parameter "crv" is missing.');
     Assertion::inArray($key->get('crv'), ['Ed25519'], 'Unsupported curve');
 }
开发者ID:spomky-labs,项目名称:jose,代码行数:10,代码来源:EdDSA.php

示例5: unserialize

 /**
  * @param  \stdClass $obj
  * @param  array     $context
  * @return TwitterEvent
  */
 public function unserialize($obj, array $context = [])
 {
     Assertion::true($this->canUnserialize($obj), 'object is not unserializable');
     $createdAt = new \DateTimeImmutable($obj->created_at);
     Assertion::eq(new \DateTimeZone('UTC'), $createdAt->getTimezone());
     return TwitterEvent::create($obj->event, $this->userSerializer->unserialize($obj->source), isset($obj->target) ? $this->userSerializer->unserialize($obj->target) : null, isset($obj->target_object) ? $this->targetSerializer->unserialize($obj->target_object) : null, $createdAt);
 }
开发者ID:remi-san,项目名称:twitter,代码行数:12,代码来源:TwitterEventSerializer.php

示例6: validate

 /**
  * @return $this
  */
 public function validate()
 {
     $this->rewind();
     $firstBytes = fread($this->resource, 1);
     $this->rewind();
     Assertion::eq($firstBytes, "<", "Stream is no valid xml file. Does not start with '<'.");
     return $this;
 }
开发者ID:metasyntactical,项目名称:xml-tools,代码行数:11,代码来源:AbstractXmlStream.php

示例7: unserialize

 /**
  * @param  \stdClass $directMessage
  * @param  array     $context
  * @return TwitterDirectMessage
  */
 public function unserialize($directMessage, array $context = [])
 {
     Assertion::true($this->canUnserialize($directMessage), 'object is not unserializable');
     $dm = $directMessage->direct_message;
     $createdAt = new \DateTimeImmutable($dm->created_at);
     Assertion::eq(new \DateTimeZone('UTC'), $createdAt->getTimezone());
     return TwitterDirectMessage::create(TwitterMessageId::create($dm->id), $this->userSerializer->unserialize($dm->sender), $this->userSerializer->unserialize($dm->recipient), $dm->text, $createdAt, $this->twitterEntitiesSerializer->canUnserialize($dm->entities) ? $this->twitterEntitiesSerializer->unserialize($dm->entities) : TwitterEntities::create());
 }
开发者ID:remi-san,项目名称:twitter,代码行数:13,代码来源:TwitterDirectMessageSerializer.php

示例8: allUsersWithAPendingAndOutdatedActivationShouldBeRemoved

 /**
  * @Then All users with a pending and outdated activation should be removed
  */
 public function allUsersWithAPendingAndOutdatedActivationShouldBeRemoved()
 {
     $em = $this->getEntityManager();
     for ($i = 0; $i < 2; ++$i) {
         Assertion::eq(null, $em->getRepository('Account:User')->findOneBy(['username' => (string) $i]));
     }
     Assertion::notEq(null, $em->getRepository('Account:User')->findOneBy(['username' => 'foo']));
 }
开发者ID:thomasmodeneis,项目名称:Sententiaregum,代码行数:11,代码来源:UserPurgerContext.php

示例9: checkUserActivity

 /**
  * @Then /^the following users should be active:$/
  *
  * @param TableNode $node
  */
 public function checkUserActivity(TableNode $node)
 {
     /** @var \AppBundle\Service\Doctrine\Repository\UserRepository $repository */
     $repository = $this->getContainer()->get('app.repository.user');
     Assertion::eq($response = $this->apiContext->getResponse(), array_combine(array_map(function (array $data) use($repository) : string {
         return $repository->findOneBy(['username' => $data['username']])->getId();
     }, $node->getHash()), array_fill(0, count($response), 1)));
 }
开发者ID:sententiaregum,项目名称:sententiaregum,代码行数:13,代码来源:OnlineUsersContext.php

示例10: checkClaim

 /**
  * {@inheritdoc}
  */
 public function checkClaim(JWTInterface $jwt)
 {
     if (!$jwt->hasClaim('iss')) {
         return [];
     }
     $issuer = $jwt->getClaim('iss');
     Assertion::eq($this->issuer, $issuer, sprintf('The issuer "%s" is not allowed.', $issuer));
     return ['iss'];
 }
开发者ID:spomky-labs,项目名称:lexik-jose-bridge,代码行数:12,代码来源:IssuerChecker.php

示例11: offsetSet

 /**
  * @param string $offset
  * @param TechnicalData $value
  */
 public function offsetSet($offset, $value)
 {
     Assertion::isInstanceOf($value, TechnicalData::class);
     $name = $value->getName();
     if (null !== $offset) {
         Assertion::eq($name, $offset);
     }
     $this->data[$name] = $value;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:13,代码来源:ArrayTechnicalDataSet.php

示例12: checkData

 /**
  * @param array $data
  */
 private static function checkData(array &$data)
 {
     foreach (['scheme', 'host', 'path', 'query'] as $key) {
         Assertion::keyExists($data, $key, 'Not a valid OTP provisioning URI');
     }
     Assertion::eq('otpauth', $data['scheme'], 'Not a valid OTP provisioning URI');
     parse_str($data['query'], $data['query']);
     Assertion::keyExists($data['query'], 'secret', 'Not a valid OTP provisioning URI');
 }
开发者ID:spomky-labs,项目名称:otphp,代码行数:12,代码来源:Factory.php

示例13: init

 /**
  * Init.
  *
  * @param TwitterMessageId   $id
  * @param TwitterUser        $sender
  * @param string             $text
  * @param TwitterEntities    $entities
  * @param \DateTimeInterface $date
  */
 public function init(TwitterMessageId $id, TwitterUser $sender, $text, TwitterEntities $entities, \DateTimeInterface $date)
 {
     Assertion::eq(new \DateTimeZone('UTC'), $date->getTimezone());
     $this->entities = $entities;
     $this->id = $id;
     $this->sender = $sender;
     $this->text = $text;
     $this->date = $date;
 }
开发者ID:remi-san,项目名称:twitter,代码行数:18,代码来源:AbstractMessage.php

示例14: iShouldSeeTheFollowingResult

 /**
  * @Then I should see the following result:
  */
 public function iShouldSeeTheFollowingResult(TableNode $table)
 {
     foreach ($table->getHash() as $row) {
         $userId = (int) $row['user_id'];
         $state = $row['state'] === 'true';
         Assertion::keyExists($this->result, $userId);
         Assertion::eq($state, $this->result[$userId]);
     }
     Assertion::eq(count(iterator_to_array($table)), count($this->result));
 }
开发者ID:thomasmodeneis,项目名称:Sententiaregum,代码行数:13,代码来源:OnlineUsersRedisClusterContext.php

示例15: lights

 /**
  * Because your neighbors keep defeating you in the holiday house decorating contest year after year,
  * you've decided to deploy one million lights in a 1000x1000 grid.
  *
  * Furthermore, because you've been especially nice this year, Santa has mailed you instructions
  * on how to display the ideal lighting configuration.
  *
  * Lights in your grid are numbered from 0 to 999 in each direction;
  * the lights at each corner are at 0,0, 0,999, 999,999, and 999,0.
  * The instructions include whether to turn on, turn off, or toggle various
  * inclusive ranges given as coordinate pairs. Each coordinate pair represents
  * opposite corners of a rectangle, inclusive; a coordinate pair like 0,0 through 2,2
  * therefore refers to 9 lights in a 3x3 square.
  * The lights all start turned off.
  *
  * To defeat your neighbors this year, all you have to do is set up your lights
  * by doing the instructions Santa sent you in order.
  *
  * For example:
  *
  * - turn on 0,0 through 999,999 would turn on (or leave on) every light.
  * - toggle 0,0 through 999,0 would toggle the first line of 1000 lights,
  *   turning off the ones that were on, and turning on the ones that were off.
  * - turn off 499,499 through 500,500 would turn off (or leave off) the middle four lights.
  *
  * After following the instructions, how many lights are lit?
  */
 public function lights(string $input, array &$grid = null) : int
 {
     $pattern = '/^(?<command>\\w+)(?: (?<value>[\\w-]+))? (?<x1>\\d+),(?<y1>\\d+) through (?<x2>\\d+),(?<y2>\\d+)\\n?$/i';
     if ($grid === null) {
         $grid = $this->createGrid(1000, 1000);
     }
     foreach (explode("\n", trim($input)) as $line) {
         $valid = preg_match($pattern, $line, $matches);
         Assertion::eq($valid, true, sprintf('Invalid input line: %s', $line));
         $instruction = $this->marshallInstruction($matches);
         $this->execute($grid, ...$instruction);
     }
     return $this->count($grid);
 }
开发者ID:stefanotorresi,项目名称:thorr-advent,代码行数:41,代码来源:Day6.php


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