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


PHP TableNode::getColumnsHash方法代码示例

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


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

示例1: assertNoSelectOptions

 /**
  * Checks that the given select field doesn't have the listed options.
  *
  * @Then I should not have the following options for :select:
  */
 public function assertNoSelectOptions($select, TableNode $options)
 {
     // Retrieve the specified field.
     if (!($field = $this->getSession()->getPage()->findField($select))) {
         throw new ExpectationException("Field '{$select}' not found.", $this->getSession());
     }
     // Check that the specified field is a <select> field.
     $this->assertElementType($field, 'select');
     // Retrieve the options table from the test scenario and flatten it.
     $expected_options = $options->getColumnsHash();
     array_walk($expected_options, function (&$value) {
         $value = reset($value);
     });
     // Retrieve the actual options that are shown in the page.
     $actual_options = $field->findAll('css', 'option');
     // Convert into a flat list of option text strings.
     array_walk($actual_options, function (&$value) {
         $value = $value->getText();
     });
     // Check that none of the expected options are present.
     foreach ($expected_options as $expected_option) {
         if (in_array($expected_option, $actual_options)) {
             throw new ExpectationException("Option '{$expected_option}' is unexpectedly found in select list '{$select}'.", $this->getSession());
         }
     }
 }
开发者ID:janoka,项目名称:platform-dev,代码行数:31,代码来源:FeatureContext.php

示例2: iShouldSeeTheRow

 /**
  * @Given /^I should see the row in the table "(?P<element>[^"]*)":$/
  *
  * @param string    $element
  * @param TableNode $table
  *
  * @throws \Exception
  */
 public function iShouldSeeTheRow($element, TableNode $table)
 {
     // Check that the (html) table exists
     $this->assertNumElements(1, $element);
     // Get the (html) table rows
     $headerNodeElements = $this->getSession()->getPage()->findAll('css', sprintf('%s thead > tr > th', $element));
     $rowNodeElements = $this->getSession()->getPage()->findAll('css', sprintf('%s > tbody > tr', $element));
     foreach ($table->getColumnsHash() as $rowIndex => $row) {
         // At this point, we want to check that $rowNodeElements contains a rows matching $row
         $rowMatches = false;
         foreach ($rowNodeElements as $rowNodeElement) {
             /* @var NodeElement $rowNodeElement */
             try {
                 // Get the row cells
                 $cellNodeElements = $rowNodeElement->findAll('css', 'td');
                 // Check that for each cells of $row, we got a matching value
                 foreach ($row as $columnText => $cellValue) {
                     $this->assertNodeElementContainsText($cellNodeElements[$this->findTableIndex($headerNodeElements, $columnText)], $cellValue);
                 }
                 // At this point the row match otherwise an exception would have been thrown
                 $rowMatches = true;
                 continue;
             } catch (\Exception $exception) {
                 // Exception thrown because the row was not matching
                 // Do nothing and pass to the next row
             }
         }
         PHPUnit::assertTrue($rowMatches, sprintf('Expected to find at least one row matching row #%d', $rowIndex));
     }
 }
开发者ID:EllynB,项目名称:Incipio,代码行数:38,代码来源:FrontContext.php

示例3: orderEventsExists

 /**
  * @Given order events exists:
  */
 public function orderEventsExists(TableNode $table)
 {
     foreach ($table->getColumnsHash() as $eventData) {
         $event = $this->getContainer()->get('crm.customer_event.factory')->createOrder(['value' => (double) $eventData['Value'], 'valueCurrency' => $eventData['Currency'], 'customerId' => $eventData['Customer ID'], 'time' => new \DateTime($eventData['Time'])]);
         $this->getContainer()->get('crm.customer_event.repository')->add($event);
     }
 }
开发者ID:ThreeDotsLabs,项目名称:crm,代码行数:10,代码来源:CustomerContext.php

示例4: theFollowingPeopleExist

 /**
  * @Given the following people exist:
  */
 public function theFollowingPeopleExist(TableNode $table)
 {
     $data = new Sample();
     $values = $table->getColumnsHash();
     foreach ($values as $val) {
         $data->set($val['name'], $val['id']);
     }
 }
开发者ID:sabsen-kol-alone,项目名称:vz-hackathon,代码行数:11,代码来源:MyContext.php

示例5: theFollowingRolesExist

 /**
  * @Given the following roles exist:
  */
 public function theFollowingRolesExist(TableNode $roles)
 {
     $roleData = $roles->getColumnsHash();
     foreach ($roleData as $roleDatum) {
         $this->getOrCreateRole($roleDatum['name'], $roleDatum['system']);
     }
     $this->getEntityManager()->flush();
 }
开发者ID:sulu,项目名称:sulu,代码行数:11,代码来源:SecurityContext.php

示例6: usersAndPermissions

 /**
  * @Given users and permissions:
  */
 public function usersAndPermissions(TableNode $table)
 {
     $permission = array();
     foreach ($table->getColumnsHash() as $userInfo) {
         $permission[$userInfo['user']] = explode(',', $userInfo['resource']);
     }
     $this->userPermission = new \Dgafka\Fixtures\IBAC\SimpleACL($permission);
 }
开发者ID:dgafka,项目名称:authorization-security,代码行数:11,代码来源:FeatureContext.php

示例7: thereAreTheFollowingResponses

 /**
  * @Given There are the following responses:
  */
 public function thereAreTheFollowingResponses(TableNode $table)
 {
     $em = $this->getManager();
     $applicationRepository = $em->getRepository('JSONMockBundle:Application');
     foreach ($table->getColumnsHash() as $row) {
         $response = new \JSONMockBundle\Entity\Response();
         $response->setName($row['Name']);
         $response->setUrl($row['Url']);
         $response->setValue(json_decode($row['Value']));
         $response->setMethod($row['Method']);
         $response->setStatusCode($row['Status_code']);
         $application = $applicationRepository->find($row['APP_ID']);
         $response->setApplication($application);
         $this->getManager()->persist($response);
     }
     $this->getManager()->flush();
     $this->getManager()->clear();
 }
开发者ID:tarnawski,项目名称:JSONMock-backend,代码行数:21,代码来源:ApiContext.php

示例8: userExistsWith

 /**
  * @Given /^User "([^"]*)" exists with:$/
  */
 public function userExistsWith($username, TableNode $table)
 {
     $entity = new User($username, 'password');
     foreach ($table->getColumnsHash() as $row) {
         $value = $row['Value'];
         if ('Roles' === $row['Property']) {
             $roles = $entity->getRoles();
             if (!in_array($value, $roles)) {
                 $roles[] = $value;
             }
             $entity->setRoles($roles);
             continue;
         }
         $setter = 'set' . $row['Property'];
         $entity->{$setter}($value);
     }
     $this->getParameterBag()->set('user', $entity);
     $em = $this->getEntityManager();
     $em->persist($entity);
     $em->flush();
 }
开发者ID:drymek,项目名称:fcs-backend,代码行数:24,代码来源:DatabaseContext.php

示例9: itShouldContainTheFollowingSetOfLabelsAndInputFieldsTypes

 /**
  * @Given /^it should contain the following set of labels, and input fields of the following types:$/
  */
 public function itShouldContainTheFollowingSetOfLabelsAndInputFieldsTypes(TableNode $table)
 {
     $fieldsExpectations = $table->getColumnsHash();
     $inputNodeElements = $this->getSession()->getPage()->findAll('css', sprintf('div.ezfield-identifier-%s fieldset input', self::$fieldIdentifier));
     /** @var NodeElement $nodeElement */
     foreach ($inputNodeElements as $nodeElement) {
         foreach ($fieldsExpectations as $expectationId => $fieldExpectation) {
             if ($fieldExpectation['type'] === $nodeElement->getAttribute('type')) {
                 $inputId = $nodeElement->getAttribute('id');
                 $this->assertSession()->elementExists('css', "label[for={$inputId}]");
                 $this->assertSession()->elementTextContains('css', "label[for={$inputId}]", $fieldExpectation['label']);
                 unset($fieldsExpectations[$expectationId]);
                 reset($fieldsExpectations);
                 break;
             }
         }
     }
     Assertion::assertEmpty($fieldsExpectations, 'The following input fields were not found:' . implode(', ', array_map(function ($v) {
         return $v['label'];
     }, $fieldsExpectations)));
 }
开发者ID:ezsystems,项目名称:repository-forms,代码行数:24,代码来源:FieldTypeFormContext.php

示例10: theJSONResponseIsComposedOf

 /**
  * @Then the JSON response should have the following nodes:
  *
  * @param TableNode $table
  */
 public function theJSONResponseIsComposedOf(TableNode $table)
 {
     $count = 0;
     foreach ($table->getColumnsHash() as $row) {
         ++$count;
         $expectedValue = $row['value'];
         // Check for null value
         // The `~` is used to specify null value (like in YAML) unless the type is explicitly set to string
         // in which case will be processed as the string '~'.
         if ('~' === $expectedValue && (false === array_key_exists('type', $row) || 'string' !== $row['type'])) {
             $this->theJsonNodeShouldBeNull($row['node']);
             continue;
         }
         // Default type is set to string
         $expectedValueType = 'string';
         if (array_key_exists('type', $row)) {
             // Trim the expected value type of all spaces before using its value
             $_expectedValueType = str_replace(' ', '', $row['type']);
             if (false === empty($_expectedValueType)) {
                 $expectedValueType = $_expectedValueType;
             }
             unset($_expectedValueType);
         }
         $expectedValue = $this->normalizeValue($row['value'], $expectedValueType);
         if (true === is_bool($expectedValue) || true === is_int($expectedValue)) {
             PHPUnit::assertEquals($expectedValue, $this->inspector->evaluate($this->getJson(), $row['node']));
             continue;
         }
         if ('array' === $expectedValueType) {
             $this->theJsonNodeShouldBeAnArray($row['node']);
             continue;
         }
         if ('object' === $expectedValueType) {
             $this->theJsonNodeShouldBeAnObject($row['node']);
             continue;
         }
         // If want to compare to an empty string, the value must be `""` in the table
         // Otherwise an empty string means no check on the value
         if ('""' === $expectedValue) {
             $this->theJsonNodeShouldBeEqualTo($row['node'], '');
             continue;
         }
         if ('' === $expectedValue) {
             $this->theJsonNodeShouldExist($row['node']);
             continue;
         }
         $this->theJsonNodeShouldBeEqualTo($row['node'], $expectedValue);
     }
     $nbrOfNodes = $this->getNumberOfNodes($this->getJson()->getContent());
     PHPUnit::assertEquals($nbrOfNodes, $count, sprintf('Expected to find %d nodes. Found %d instead', $nbrOfNodes, $count));
 }
开发者ID:EllynB,项目名称:Incipio,代码行数:56,代码来源:JsonContext.php

示例11: theFollowingPagesExist

 /**
  * @Given the following pages exist:
  */
 public function theFollowingPagesExist(TableNode $table)
 {
     $data = $table->getColumnsHash();
     $this->createStructures('page', $data);
 }
开发者ID:Silwereth,项目名称:sulu,代码行数:8,代码来源:ContentContext.php

示例12: castArticleIds

 /**
  * @Transform table:article_id
  *
  * @param TableNode $articleIds
  *
  * @return array
  */
 public function castArticleIds(TableNode $articleIds)
 {
     return array_column($articleIds->getColumnsHash(), 'article_id');
 }
开发者ID:schibsted-tech-polska,项目名称:capi_php_sdk,代码行数:11,代码来源:ArticleRepositoryContext.php

示例13: iShouldGet

 /**
  * @Then I should get:
  */
 public function iShouldGet(TableNode $table)
 {
     if (isset($this->response["error"])) {
         throw new \Exception($this->response["error"]);
     }
     $result = array_map(function ($item) {
         return ['Name' => $item["name"]];
     }, $this->response["completion"]);
     expect($table->getColumnsHash())->to->be->equal($result);
 }
开发者ID:nevernet,项目名称:padawan.php,代码行数:13,代码来源:FeatureContext.php


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