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


PHP TableNode::getRows方法代码示例

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


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

示例1: iShouldSeeAPaginatedTableWithTheColumns

 /**
  * @Given /^I should see a paginated table "(?P<element>[^"]*)" with the columns:$/
  *
  * @param string    $element
  * @param TableNode $table
  *
  * @throws \Exception
  */
 public function iShouldSeeAPaginatedTableWithTheColumns($element, TableNode $table)
 {
     // Check that the (html) table exists
     $this->assertNumElements(1, $element);
     // Check that the (html) table has a pagination
     // Disabled for now, require JavaScript support to work
     //$this->assertNumElements(1, sprintf('%s_paginate', $element));
     // Get the (html) table rows
     $elements = $this->getSession()->getPage()->findAll('css', sprintf('%s thead > tr > th', $element));
     // Check the rows names
     foreach ($table->getRows() as $row) {
         $this->assertANodeElementContainsText($elements, $row[0]);
     }
     PHPUnit::assertEquals(count($table->getRows()), count($elements), 'Expected to find the same number of columns.');
 }
开发者ID:EllynB,项目名称:Incipio,代码行数:23,代码来源:FrontContext.php

示例2: quiz_contains_the_following_questions

 /**
  * Put the specified questions on the specified pages of a given quiz.
  *
  * Give the question name in the first column, and that page number in the
  * second column. You may optionally give the desired maximum mark for each
  * question in a third column.
  *
  * @param string $quizname the name of the quiz to add questions to.
  * @param TableNode $data information about the questions to add.
  *
  * @Given /^quiz "([^"]*)" contains the following questions:$/
  */
 public function quiz_contains_the_following_questions($quizname, TableNode $data)
 {
     global $DB;
     $quiz = $DB->get_record('quiz', array('name' => $quizname), '*', MUST_EXIST);
     // The action depends on the field type.
     foreach ($data->getRows() as $questiondata) {
         if (count($questiondata) < 2 || count($questiondata) > 3) {
             throw new ExpectationException('When adding questions to a quiz, you should give 2 or three 3 things: ' . ' the question name, the page number, and optionally a the maxiumum mark. ' . count($questiondata) . ' values passed.', $this->getSession());
         }
         list($questionname, $rawpage) = $questiondata;
         if (!isset($questiondata[2]) || $questiondata[2] === '') {
             $maxmark = null;
         } else {
             $maxmark = clean_param($questiondata[2], PARAM_FLOAT);
             if (!is_numeric($questiondata[2]) || $maxmark < 0) {
                 throw new ExpectationException('When adding questions to a quiz, the max mark must be a positive number.', $this->getSession());
             }
         }
         $page = clean_param($rawpage, PARAM_INT);
         if ($page <= 0 || (string) $page !== $rawpage) {
             throw new ExpectationException('When adding questions to a quiz, the page number must be a positive integer.', $this->getSession());
         }
         $questionid = $DB->get_field('question', 'id', array('name' => $questionname), MUST_EXIST);
         quiz_add_quiz_question($questionid, $quiz, $page, $maxmark);
     }
     quiz_update_sumgrades($quiz);
 }
开发者ID:adonm,项目名称:learning,代码行数:39,代码来源:behat_mod_quiz.php

示例3: i_add_a_question_and_i_fill_the_form_with

 /**
  * Adds a question to the questionnaire with the provided data.
  *
  * @Given /^I add a "([^"]*)" question and I fill the form with:$/
  *
  * @param string $questiontype The question type by text name to enter.
  * @param TableNode $fielddata
  */
 public function i_add_a_question_and_i_fill_the_form_with($questiontype, TableNode $fielddata)
 {
     $validtypes = array('----- Page Break -----', 'Check Boxes', 'Date', 'Dropdown Box', 'Essay Box', 'Label', 'Numeric', 'Radio Buttons', 'Rate (scale 1..5)', 'Text Box', 'Yes/No');
     if (!in_array($questiontype, $validtypes)) {
         throw new ExpectationException('Invalid question type specified.', $this->getSession());
     }
     // We get option choices as CSV strings. If we have this, modify it for use in
     // multiline data.
     $rows = $fielddata->getRows();
     $hashrows = $fielddata->getRowsHash();
     $options = array();
     if (isset($hashrows['Possible answers'])) {
         $options = explode(',', $hashrows['Possible answers']);
         $rownum = -1;
         // Find the row that contained multiline data and add line breaks. Rows are two item arrays where the
         // first is an identifier and the second is the value.
         foreach ($rows as $key => $row) {
             if ($row[0] == 'Possible answers') {
                 $row[1] = str_replace(',', "\n", $row[1]);
                 $rows[$key] = $row;
                 break;
             }
         }
         $fielddata = new TableNode($rows);
     }
     $this->execute('behat_forms::i_set_the_field_to', array('id_type_id', $questiontype));
     $this->execute('behat_forms::press_button', 'Add selected question type');
     $this->execute('behat_forms::i_set_the_following_fields_to_these_values', $fielddata);
     $this->execute('behat_forms::press_button', 'Save changes');
 }
开发者ID:SysBind,项目名称:moodle-mod_questionnaire,代码行数:38,代码来源:behat_mod_questionnaire.php

示例4: taxonomyHasFollowingTaxons

 /**
  * @Given /^taxonomy "([^""]*)" has following taxons:$/
  */
 public function taxonomyHasFollowingTaxons($taxonomyName, TableNode $taxonsTable)
 {
     $taxonomy = $this->findOneByName('taxonomy', $taxonomyName);
     $manager = $this->getEntityManager();
     $taxons = array();
     foreach ($taxonsTable->getRows() as $node) {
         $taxonList = explode('>', $node[0]);
         $parent = null;
         foreach ($taxonList as $taxonName) {
             $taxonName = trim($taxonName);
             if (!isset($taxons[$taxonName])) {
                 /* @var $taxon TaxonInterface */
                 $taxon = $this->getRepository('taxon')->createNew();
                 $taxon->setName($taxonName);
                 $taxons[$taxonName] = $taxon;
             }
             $taxon = $taxons[$taxonName];
             if (null !== $parent) {
                 $parent->addChild($taxon);
             } else {
                 $taxonomy->addTaxon($taxon);
             }
             $parent = $taxon;
         }
     }
     $manager->persist($taxonomy);
     $manager->flush();
 }
开发者ID:Strontium-90,项目名称:Sylius,代码行数:31,代码来源:TaxonomyContext.php

示例5: taxonHasFollowingChildren

 /**
  * @Given /^taxon "([^""]*)" has following children:$/
  */
 public function taxonHasFollowingChildren($taxonName, TableNode $childrenTable)
 {
     /* @var $taxon TaxonInterface */
     $taxon = $this->findOneByName('taxon', $taxonName);
     $manager = $this->getEntityManager();
     $children = [];
     foreach ($childrenTable->getRows() as $node) {
         $taxonList = explode('>', $node[0]);
         /* @var $parent TaxonInterface */
         $parent = null;
         foreach ($taxonList as $item) {
             $item = trim($item);
             $childData = preg_split('[\\[|\\]]', $item, -1, PREG_SPLIT_NO_EMPTY);
             if (!isset($children[$childData[0]])) {
                 /* @var $child TaxonInterface */
                 $child = $this->getFactory('taxon')->createNew();
                 $child->setName($childData[0]);
                 $child->setCode($childData[1]);
                 $children[$childData[0]] = $child;
             }
             $child = $children[$childData[0]];
             if (null !== $parent) {
                 $parent->addChild($child);
             } else {
                 $taxon->addChild($child);
             }
             $parent = $child;
         }
     }
     $manager->persist($taxon);
     $manager->flush();
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:35,代码来源:TaxonomyContext.php

示例6: taxonomyHasFollowingTaxons

 /**
  * @Given /^taxonomy "([^""]*)" has following taxons:$/
  */
 public function taxonomyHasFollowingTaxons($taxonomyName, TableNode $taxonsTable)
 {
     $taxonomy = $this->findOneByName('taxonomy', $taxonomyName);
     $manager = $this->getEntityManager();
     $taxons = array();
     foreach ($taxonsTable->getRows() as $node) {
         $taxonList = explode('>', $node[0]);
         $parent = null;
         foreach ($taxonList as $taxon) {
             $taxon = trim($taxon);
             $taxonData = preg_split("[\\[|\\]]", $taxon, -1, PREG_SPLIT_NO_EMPTY);
             if (!isset($taxons[$taxonData[0]])) {
                 /* @var $taxon TaxonInterface */
                 $taxon = $this->getFactory('taxon')->createNew();
                 $taxon->setName($taxonData[0]);
                 $taxon->setCode($taxonData[1]);
                 $taxons[$taxonData[0]] = $taxon;
             }
             $taxon = $taxons[$taxonData[0]];
             if (null !== $parent) {
                 $parent->addChild($taxon);
             } else {
                 $taxonomy->addTaxon($taxon);
             }
             $parent = $taxon;
         }
     }
     $manager->persist($taxonomy);
     $manager->flush();
 }
开发者ID:malukenho,项目名称:Sylius,代码行数:33,代码来源:TaxonomyContext.php

示例7: i_fill_the_capabilities_form_with_the_following_permissions

 /**
  * Fills the advanced permissions form with the provided data. Expects a table with capability name and permission (Inherit/Allow/Prevent/Prohibit) columns.
  * @Given /^I fill the capabilities form with the following permissions:$/
  * @param TableNode $table
  * @return void
  */
 public function i_fill_the_capabilities_form_with_the_following_permissions($table)
 {
     // Ensure we are using the advanced view.
     // Wrapped in a try/catch to capture the exception and continue execution, we don't know if advanced mode was already enabled.
     try {
         $advancedtoggle = $this->find_button(get_string('showadvanced', 'form'));
         if ($advancedtoggle) {
             $this->getSession()->getPage()->pressButton(get_string('showadvanced', 'form'));
         }
     } catch (Exception $e) {
         // We already are in advanced mode.
     }
     // Using getRows() as we are not sure if tests writers will add the header.
     foreach ($table->getRows() as $key => $row) {
         if (count($row) !== 2) {
             throw new ExpectationException('You should specify a table with capability/permission columns', $this->getSession());
         }
         list($capability, $permission) = $row;
         // Skip the headers row if it was provided
         if (strtolower($capability) == 'capability' || strtolower($capability) == 'capabilities') {
             continue;
         }
         // Checking the permission value.
         $permissionconstant = 'CAP_' . strtoupper($permission);
         if (!defined($permissionconstant)) {
             throw new ExpectationException('The provided permission value "' . $permission . '" is not valid. Use Inherit, Allow, Prevent or Prohibited', $this->getSession());
         }
         // Converting from permission to constant value.
         $permissionvalue = constant($permissionconstant);
         // Here we wait for the element to appear and exception if it does not exists.
         $radio = $this->find('xpath', '//input[@name="' . $capability . '" and @value="' . $permissionvalue . '"]');
         $radio->click();
     }
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:40,代码来源:behat_permissions.php

示例8: thereAreValues

 /**
  * @Then there are keywords in :smth
  */
 public function thereAreValues($file, \Behat\Gherkin\Node\TableNode $node)
 {
     $this->seeFileFound($file);
     foreach ($node->getRows() as $row) {
         $this->seeThisFileMatches('~' . implode('.*?', $row) . '~');
     }
 }
开发者ID:solutionDrive,项目名称:Codeception,代码行数:10,代码来源:ScenarioGuy.php

示例9: i_allocate_submissions_in_workshop_as

 /**
  * Manually allocates multiple reviewers in workshop.
  *
  * @When /^I allocate submissions in workshop "(?P<workshop_name_string>(?:[^"]|\\")*)" as:"$/
  * @param string $workshopname
  * @param TableNode $table should have one column with title 'Reviewer' and another with title 'Participant' (or 'Reviewee')
  */
 public function i_allocate_submissions_in_workshop_as($workshopname, TableNode $table)
 {
     $this->find_link($workshopname)->click();
     $this->find_link(get_string('allocate', 'workshop'))->click();
     $rows = $table->getRows();
     $reviewer = $participant = null;
     for ($i = 0; $i < count($rows[0]); $i++) {
         if (strtolower($rows[0][$i]) === 'reviewer') {
             $reviewer = $i;
         } else {
             if (strtolower($rows[0][$i]) === 'reviewee' || strtolower($rows[0][$i]) === 'participant') {
                 $participant = $i;
             } else {
                 throw new ElementTextException('Unrecognised column "' . $rows[0][$i] . '"', $this->getSession());
             }
         }
     }
     if ($reviewer === null) {
         throw new ElementTextException('Column "Reviewer" could not be located', $this->getSession());
     }
     if ($participant === null) {
         throw new ElementTextException('Neither "Participant" nor "Reviewee" column could be located', $this->getSession());
     }
     for ($i = 1; $i < count($rows); $i++) {
         $this->i_add_a_reviewer_for_workshop_participant($rows[$i][$reviewer], $rows[$i][$participant]);
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:34,代码来源:behat_workshopallocation_manual.php

示例10: iHaveParams

 /**
  * @When /I have parameters/
  */
 public function iHaveParams(TableNode $table)
 {
     foreach ($table->getRows() as $idx => $row) {
         if ($idx == 0) {
             continue;
         }
         Fixtures::add($row[0], $row[1]);
     }
 }
开发者ID:edno,项目名称:codeception-gherkin-param,代码行数:12,代码来源:Acceptance.php

示例11: array

 function it_should_throw_an_exception_if_no_existence(EntityResolver $resolver, TableNode $tableNode, $repository, $manager, ClassMetadata $metadata)
 {
     $resolver->resolve(Argument::cetera())->willReturn([$metadata]);
     $metadata->getName()->willReturn("EntityStub");
     $tableNode->getRows()->willReturn(array(array('firstName', 'lastName', 'number', 'nullValue'), array('John', 'DOE', 0, '')));
     $manager->getRepository(Argument::any())->willReturn($repository);
     $repository->findOneBy(['firstName' => 'John', 'lastName' => 'DOE', 'number' => 0, 'nullValue' => null])->willReturn(null);
     $this->shouldThrow(new \Exception("There is no object for the following criteria: {\"firstName\":\"John\",\"lastName\":\"DOE\",\"number\":0,\"nullValue\":null}"))->duringExistLikeFollowing(1, "Class", $tableNode);
 }
开发者ID:lafourchette,项目名称:FriendlyContexts,代码行数:9,代码来源:EntityContextSpec.php

示例12: iSeeTableEqual

 /**
  * @Then I should see following:
  */
 public function iSeeTableEqual(TableNode $table)
 {
     foreach ($table->getRows() as $idx => $row) {
         if ($idx == 0) {
             continue;
         }
         $this->assertEquals($row[0], $row[1]);
     }
 }
开发者ID:edno,项目名称:codeception-gherkin-param,代码行数:12,代码来源:AcceptanceTester.php

示例13: exportedXlsxFileOfShouldContainsTheFollowingHeaders

 /**
  * @param string    $code
  * @param TableNode $expectedLines
  *
  * @Then /^exported xlsx file of "([^"]*)" should contains the following headers:$/
  */
 public function exportedXlsxFileOfShouldContainsTheFollowingHeaders($code, TableNode $expectedLines)
 {
     $path = $this->getMainContext()->getSubcontext('job')->getJobInstancePath($code);
     $reader = ReaderFactory::create(Type::XLSX);
     $reader->open($path);
     $sheet = current(iterator_to_array($reader->getSheetIterator()));
     $actualLines = iterator_to_array($sheet->getRowIterator());
     $reader->close();
     $this->compareXlsxFileHeadersOrder(array_values($expectedLines->getRows()), array_values($actualLines));
 }
开发者ID:pierallard,项目名称:pim-community-dev,代码行数:16,代码来源:XlsxFileContext.php

示例14: iHavePlayers

 /**
  * @Given /^I have players:$/
  */
 public function iHavePlayers(TableNode $table)
 {
     $playerManager = $this->kernel->getContainer()->get('cytron_babitch.player.manager');
     foreach ($table->getRows() as $row) {
         $player = new Player();
         $player->setName($row[0]);
         $player->setEmail($row[1]);
         $playerManager->persist($player, true);
     }
 }
开发者ID:bricebuffa,项目名称:Babitch,代码行数:13,代码来源:FeatureContext.php

示例15: quiz_contains_the_following_questions

 /**
  * Put the specified questions on the specified pages of a given quiz.
  *
  * The first row should be column names:
  * | question | page | maxmark |
  * The first two of those are required. The others are optional.
  *
  * question        needs to uniquely match a question name.
  * page            is a page number. Must start at 1, and on each following
  *                 row should be the same as the previous, or one more.
  * maxmark         What the question is marked out of. Defaults to question.defaultmark.
  *
  * Then there should be a number of rows of data, one for each question you want to add.
  *
  * For backwards-compatibility reasons, specifying the column names is optional
  * (but strongly encouraged). If not specified, the columns are asseumed to be
  * | question | page | maxmark |.
  *
  * @param string $quizname the name of the quiz to add questions to.
  * @param TableNode $data information about the questions to add.
  *
  * @Given /^quiz "([^"]*)" contains the following questions:$/
  */
 public function quiz_contains_the_following_questions($quizname, TableNode $data)
 {
     global $CFG, $DB;
     require_once __DIR__ . '/../../editlib.php';
     $quiz = $DB->get_record('quiz', array('name' => $quizname), '*', MUST_EXIST);
     // Deal with backwards-compatibility, optional first row.
     $firstrow = $data->getRow(0);
     if (!in_array('question', $firstrow) && !in_array('page', $firstrow)) {
         if (count($firstrow) == 2) {
             $headings = array('question', 'page');
         } else {
             if (count($firstrow) == 3) {
                 $headings = array('question', 'page', 'maxmark');
             } else {
                 throw new ExpectationException('When adding questions to a quiz, you should give 2 or three 3 things: ' . ' the question name, the page number, and optionally the maxiumum mark. ' . count($firstrow) . ' values passed.', $this->getSession());
             }
         }
         $rows = $data->getRows();
         array_unshift($rows, $headings);
         $data->setRows($rows);
     }
     // Add the questions.
     $lastpage = 0;
     foreach ($data->getHash() as $questiondata) {
         if (!array_key_exists('question', $questiondata)) {
             throw new ExpectationException('When adding questions to a quiz, ' . 'the question name column is required.', $this->getSession());
         }
         if (!array_key_exists('page', $questiondata)) {
             throw new ExpectationException('When adding questions to a quiz, ' . 'the page number column is required.', $this->getSession());
         }
         // Question id.
         $questionid = $DB->get_field('question', 'id', array('name' => $questiondata['question']), MUST_EXIST);
         // Page number.
         $page = clean_param($questiondata['page'], PARAM_INT);
         if ($page <= 0 || (string) $page !== $questiondata['page']) {
             throw new ExpectationException('The page number for question "' . $questiondata['question'] . '" must be a positive integer.', $this->getSession());
         }
         if ($page < $lastpage || $page > $lastpage + 1) {
             throw new ExpectationException('When adding questions to a quiz, ' . 'the page number for each question must either be the same, ' . 'or one more, then the page number for the previous question.', $this->getSession());
         }
         $lastpage = $page;
         // Max mark.
         if (!array_key_exists('maxmark', $questiondata) || $questiondata['maxmark'] === '') {
             $maxmark = null;
         } else {
             $maxmark = clean_param($questiondata['maxmark'], PARAM_FLOAT);
             if (!is_numeric($questiondata['maxmark']) || $maxmark < 0) {
                 throw new ExpectationException('The max mark for question "' . $questiondata['question'] . '" must be a positive number.', $this->getSession());
             }
         }
         // Add the question.
         quiz_add_quiz_question($questionid, $quiz, $page, $maxmark);
     }
     quiz_update_sumgrades($quiz);
 }
开发者ID:educacionbe,项目名称:cursos,代码行数:78,代码来源:behat_mod_quiz.php


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