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


PHP Assertion::count方法代码示例

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


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

示例1: iShouldSeeTheFollowingLocales

 /**
  * @Then I should see the following locales:
  */
 public function iShouldSeeTheFollowingLocales(TableNode $table)
 {
     foreach ($table->getHash() as $row) {
         Assertion::keyExists($this->result, $row['shortcut']);
         Assertion::eq($row['display_name'], $this->result[$row['shortcut']]);
     }
     Assertion::count(iterator_to_array($table), count($this->result));
 }
开发者ID:thomasmodeneis,项目名称:Sententiaregum,代码行数:11,代码来源:LocaleContext.php

示例2: __construct

 public function __construct(string $xmlFolder, array $additionalTypes = [], CacheItemPoolInterface $cache = null)
 {
     if (!empty($additionalTypes)) {
         Assertion::count(array_filter($additionalTypes, function ($type) : bool {
             return !$type instanceof TypeInterface;
         }), 0, sprintf('At least one element in array is not an instance of %s', TypeInterface::class));
     }
     $this->xmlFolder = $xmlFolder;
     $this->types = $additionalTypes + $this->createBuiltInTypes();
     $this->cache = $cache ?: new VoidCachePool();
 }
开发者ID:soliantconsulting,项目名称:simplefm,代码行数:11,代码来源:MetadataBuilder.php

示例3: 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

示例4: iShouldHaveAnActivationEmail

 /**
  * @Then I should have an activation email
  */
 public function iShouldHaveAnActivationEmail()
 {
     $client = $this->recentClient;
     /** @var \Symfony\Bundle\SwiftMailerBundle\DataCollector\MessageDataCollector $mailCollector */
     $mailCollector = $client->getProfile()->getCollector('swiftmailer');
     Assertion::eq(1, $mailCollector->getMessageCount());
     /** @var \Swift_Message $message */
     $message = $mailCollector->getMessages()[0];
     Assertion::eq($message->getSubject(), 'Sententiaregum Notifications');
     Assertion::eq(key($message->getTo()), 'sententiaregum@sententiaregum.dev');
     $crawler = new Crawler();
     $crawler->addContent($message->getChildren()[1]->getBody());
     Assertion::count($message->getChildren(), 2);
     Assertion::eq(1, $crawler->filter('#n-ac-l-p')->count());
     Assertion::notEq(0, preg_match('/!\\/activate\\/(.*)/', $message->getChildren()[0]->getBody()));
 }
开发者ID:thomasmodeneis,项目名称:Sententiaregum,代码行数:19,代码来源:RegistrationContext.php

示例5: checkEmail

 /**
  * @Then /^I should've gotten an email$/
  */
 public function checkEmail()
 {
     /** @var \Symfony\Bundle\SwiftmailerBundle\DataCollector\MessageDataCollector $profile */
     $profile = $this->apiContext->getProfile()->getCollector('swiftmailer');
     Assertion::eq(1, $profile->getMessageCount());
     /** @var \Swift_Message $message */
     $message = $profile->getMessages()[0];
     // user registers as "de", so email should be in german
     Assertion::eq($message->getSubject(), 'Benachrichtigungen von Sententiaregum');
     Assertion::eq(key($message->getTo()), 'sententiaregum@sententiaregum.dev');
     $crawler = new Crawler();
     $crawler->addContent($message->getChildren()[1]->getBody());
     Assertion::count($message->getChildren(), 2);
     Assertion::eq(1, $crawler->filter('#n-ac-l-p')->count());
     Assertion::notEq(0, preg_match('/\\/activate\\/(.*)/', $message->getChildren()[0]->getBody()));
 }
开发者ID:sententiaregum,项目名称:sententiaregum,代码行数:19,代码来源:CreateAccountContext.php

示例6: testInvalidCount

 /**
  * @dataProvider dataInvalidCount
  */
 public function testInvalidCount($countable, $count)
 {
     $this->setExpectedException('Assert\\AssertionFailedException', 'List does not contain exactly "' . $count . '" elements.', Assertion::INVALID_COUNT);
     Assertion::count($countable, $count);
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:8,代码来源:AssertTest.php

示例7: testInvalidCount

 /**
  * @dataProvider dataInvalidCount
  */
 public function testInvalidCount($countable, $count)
 {
     $this->setExpectedException('Assert\\AssertionFailedException', null, Assertion::INVALID_COUNT);
     Assertion::count($countable, $count);
 }
开发者ID:jeroendesloovere,项目名称:assert,代码行数:8,代码来源:AssertTest.php

示例8: validateArray

 private function validateArray(array $array, string $expectedClassName)
 {
     Assertion::count(array_filter($array, function ($metadata) use($expectedClassName) : bool {
         return !$metadata instanceof $expectedClassName;
     }), 0, sprintf('At least one element in array is not an instance of %s', $expectedClassName));
 }
开发者ID:soliantconsulting,项目名称:simplefm,代码行数:6,代码来源:Entity.php

示例9: iShouldGetTwoIds

 /**
  * @Then I should get two ids
  */
 public function iShouldGetTwoIds()
 {
     Assertion::count($this->followerIds, 2);
 }
开发者ID:thomasmodeneis,项目名称:Sententiaregum,代码行数:7,代码来源:UsersContext.php

示例10: reset

 /**
  * Resets the Temporal object to its initial value
  *
  * @return int Returns the initial value
  */
 public function reset()
 {
     Assertion::notNull(self::$redis, "Redis connection hasn't been set");
     // Remove each individual key
     $items = self::$redis->sMembers($this->identifier);
     foreach ($items as $i) {
         self::$redis->delete($i);
     }
     // Remove the set and check its emptiness
     self::$redis->delete($this->identifier);
     Assertion::count(self::$redis->sMembers($this->identifier), 0);
     return $this->initialNumber;
 }
开发者ID:3nr1c,项目名称:temporal,代码行数:18,代码来源:Temporal.php

示例11: iShouldSeeTheFollowingNameSuggestions

 /**
  * @Then I should see the following name suggestions:
  */
 public function iShouldSeeTheFollowingNameSuggestions(TableNode $table)
 {
     Assertion::inArray($table->getRow(1)[0], $this->suggestions);
     Assertion::count($this->suggestions, 2);
 }
开发者ID:thomasmodeneis,项目名称:Sententiaregum,代码行数:8,代码来源:UsernameSuggestionsContext.php

示例12: logItemsProcessingFailed

 /**
  * @param int $successfulItems
  * @param int $failedItems
  * @param array $failedMessages
  * @param WorkflowMessage $originMessage
  * @return LogMessage
  */
 public static function logItemsProcessingFailed($successfulItems, $failedItems, array $failedMessages, WorkflowMessage $originMessage)
 {
     Assertion::integer($successfulItems);
     Assertion::integer($failedItems);
     foreach ($failedMessages as $failedMsg) {
         Assertion::string($failedMsg);
     }
     Assertion::count($failedMessages, $failedItems, "Number of failed messages should be the same as number of failed items");
     return new self($originMessage->target(), $originMessage->processTaskListPosition(), sprintf('Processing for %d of %d items failed', $failedItems, $successfulItems + $failedItems), self::ERROR_ITEMS_PROCESSING_FAILED, [self::MSG_PARAM_SUCCESSFUL_ITEMS => $successfulItems, self::MSG_PARAM_FAILED_ITEMS => $failedItems, self::MSG_PARAM_FAILED_MESSAGES => $failedMessages]);
 }
开发者ID:prooph,项目名称:processing,代码行数:17,代码来源:LogMessage.php

示例13: validateNames

 /**
  * @Then I should see the following names:
  *
  * @param TableNode $table
  */
 public function validateNames(TableNode $table)
 {
     $list = array_column($table->getHash(), 'username');
     Assertion::allInArray($this->filterResult, $list);
     Assertion::count($this->filterResult, count($list));
 }
开发者ID:sententiaregum,项目名称:sententiaregum,代码行数:11,代码来源:UsersContext.php


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