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


PHP TableNode::addRow方法代码示例

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


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

示例1: testTokens

    public function testTokens()
    {
        $table = new TableNode();
        $table->addRow(array('username', 'password'));
        $table->addRow(array('<username>', '<password>'));
        $tableCompare = new TableNode(<<<TABLE
| username | password |
| everzet  | qwerty   |
TABLE
);
        $exampleTable = $table->createExampleRowStepArgument(array('username' => 'everzet', 'password' => 'qwerty'));
        $this->assertNotSame($table, $exampleTable);
        $this->assertSame($tableCompare->getRows(), $exampleTable->getRows());
    }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:14,代码来源:TableNodeTest.php

示例2: testTableFromArrayCreation

    public function testTableFromArrayCreation()
    {
        $table1 = new TableNode();
        $table1->addRow(array('username', 'password'));
        $table1->addRow(array('everzet', 'qwerty'));
        $table1->addRow(array('antono', 'pa$sword'));
        $table2 = new TableNode(<<<TABLE
| username | password |
| everzet  | qwerty   |
| antono   | pa\$sword|
TABLE
);
        $this->assertEquals($table2->getRows(), $table1->getRows());
        $this->assertEquals(array(array('username' => 'everzet', 'password' => 'qwerty'), array('username' => 'antono', 'password' => 'pa$sword')), $table1->getHash());
        $this->assertEquals(array('username' => 'password', 'everzet' => 'qwerty', 'antono' => 'pa$sword'), $table2->getRowsHash());
    }
开发者ID:kingsj,项目名称:core,代码行数:16,代码来源:TableNodeTest.php

示例3: it_can_verify_that_expected_entities_have_expected_values

 /**
  * The assert_entities step should verify that entities have expected values
  *
  * @param \Ingenerator\BeEntity\Factory        $factory the entity factory mock
  * @param \Ingenerator\BeEntity\FactoryManager $manager the factory manager mock
  * @param \Doctrine\ORM\EntityManager $entity_manager the entity manager
  *
  * @return void
  * @see \Ingenerator\BeEntity\Context\BeEntityContext::assert_entities
  */
 public function it_can_verify_that_expected_entities_have_expected_values($factory, $manager, $entity_manager)
 {
     $manager->create_factory('Dummy')->willReturn($factory);
     $this->set_factory_manager($manager);
     // The entity exists but has invalid values
     $factory->matches('not existing dummy', array('active' => 'y', 'foo' => 'bar'))->willReturn(array('foo' => array('exp' => 'bar', 'got' => 'foo')));
     // Stub some entity data that would be specified in the table
     $data_1 = array('title' => 'not existing dummy', 'active' => 'y', 'foo' => 'bar');
     $table = new TableNode();
     $table->addRow(array_keys($data_1));
     $table->addRow($data_1);
     // The entity manager should be cleared to ensure values are reloaded from DB
     $entity_manager->clear()->shouldBeCalled();
     $this->shouldThrow('\\Ingenerator\\BeEntity\\Exception\\ExpectationException')->during('assert_entities', array('Dummy', $table));
 }
开发者ID:ingenerator,项目名称:be_entity,代码行数:25,代码来源:BeEntityContextSpec.php

示例4: translationTestDataProvider

 public function translationTestDataProvider()
 {
     $data = array();
     $translator = $this->getTranslator();
     $parser = $this->getParser();
     $finder = new Finder();
     $i18ns = $finder->files()->name('*.xliff')->in(__DIR__ . '/../Fixtures/i18n');
     foreach ($i18ns as $i18n) {
         $language = basename($i18n, '.xliff');
         $translator->addResource('xliff', $i18n, $language, 'gherkin');
         $etalon = array();
         $features = array();
         foreach ($this->getTranslatedKeywords('Feature', $language) as $featureNum => $featureKeyword) {
             $gherkin = "# language: {$language}";
             $lineNum = 1;
             $feature = new Node\FeatureNode(null, null, null, ++$lineNum);
             $feature->setLanguage($language);
             $feature->setKeyword($featureKeyword);
             $feature->setTitle($title = "title of the feature N{$featureNum}");
             $feature->setDescription($description = "some\nfeature\ndescription");
             $gherkin .= "\n{$featureKeyword}: {$title}";
             $gherkin .= "\n{$description}";
             $lineNum += 3;
             $stepKeywords = $this->getTranslatedKeywords('Given|When|Then|And|But', $language);
             $backgroundKeywords = $this->getTranslatedKeywords('Background', $language);
             $examplesKeywords = $this->getTranslatedKeywords('Examples', $language);
             // Background
             $backgroundKeyword = $backgroundKeywords[0];
             $background = new Node\BackgroundNode(null, ++$lineNum);
             $background->setKeyword($backgroundKeyword);
             $feature->setBackground($background);
             $gherkin .= "\n{$backgroundKeyword}:";
             foreach ($stepKeywords as $stepNum => $stepKeyword) {
                 $step = new Node\StepNode($stepKeyword, $text = "text of the step N{$stepNum}", ++$lineNum);
                 $background->addStep($step);
                 $gherkin .= "\n{$stepKeyword} {$text}";
             }
             // Scenarios
             foreach ($this->getTranslatedKeywords('Scenario', $language) as $scenarioNum => $scenarioKeyword) {
                 $scenario = new Node\ScenarioNode($title = "title of the scenario N{$scenarioNum}", ++$lineNum);
                 $scenario->setKeyword($scenarioKeyword);
                 $feature->addScenario($scenario);
                 $gherkin .= "\n{$scenarioKeyword}: {$title}";
                 foreach ($stepKeywords as $stepNum => $stepKeyword) {
                     $step = new Node\StepNode($stepKeyword, $text = "text of the step N{$stepNum}", ++$lineNum);
                     $scenario->addStep($step);
                     $gherkin .= "\n{$stepKeyword} {$text}";
                 }
             }
             // Scenario Outlines
             foreach ($this->getTranslatedKeywords('Scenario Outline', $language) as $outlineNum => $outlineKeyword) {
                 $outline = new Node\OutlineNode($title = "title of the outline N{$outlineNum}", ++$lineNum);
                 $outline->setKeyword($outlineKeyword);
                 $feature->addScenario($outline);
                 $gherkin .= "\n{$outlineKeyword}: {$title}";
                 $stepKeyword = $stepKeywords[0];
                 $step = new Node\StepNode($stepKeyword, $text = "text of the step <num>", ++$lineNum);
                 $outline->addStep($step);
                 $gherkin .= "\n{$stepKeyword} {$text}";
                 $examplesKeyword = $examplesKeywords[0];
                 $examples = new Node\TableNode();
                 $examples->setKeyword($examplesKeyword);
                 $examples->addRow(array('num'));
                 $examples->addRow(array(2));
                 $outline->setExamples($examples);
                 $gherkin .= "\n{$examplesKeyword}:";
                 $gherkin .= "\n  | num |";
                 $gherkin .= "\n  | 2   |";
                 $lineNum += 3;
             }
             $etalon[] = $feature;
             $features[] = $this->getParser()->parse($gherkin);
         }
         $data[] = array($language, $etalon, $features);
     }
     return $data;
 }
开发者ID:kingsj,项目名称:core,代码行数:77,代码来源:SymfonyTranslationKeywordsTest.php

示例5: fix_data_counter

 /**
  * Helper function to modify #count#, #refcount# and #repeatcount# in table.
  *
  * @param TableNode $data Data to be passed to the resource.
  * @throws
  */
 protected function fix_data_counter(TableNode $data)
 {
     $datanodes = array();
     $rows = $data->getRows();
     // Get table keys and remove instances and reference
     $firstrow = array_shift($rows);
     if (($instancekey = array_search('instances', $firstrow)) !== false) {
         unset($firstrow[$instancekey]);
     }
     if (($refkey = array_search('referencecount', $firstrow)) !== false) {
         unset($firstrow[$refkey]);
     }
     if (($repeatkey = array_search('repeat', $firstrow)) !== false) {
         unset($firstrow[$repeatkey]);
     }
     // Create all instances.
     foreach ($rows as $row) {
         // Get count and unset instances key.
         $instances = $row[$instancekey];
         unset($row[$instancekey]);
         // Check if there is an refrence which needs to be met.
         // Reference is like how many categories to use to create given instances of sub-category.
         $reference = 0;
         if ($refkey) {
             $reference = $row[$refkey];
             unset($row[$refkey]);
             // We want sequential filling of data so keep track of counter.
             $referencecounter = 1;
             $maxperreference = ceil($instances / $reference);
         }
         // Check if repeat is given to repeat process.
         $repeat = 1;
         if ($repeatkey) {
             $repeat = $row[$repeatkey];
             unset($row[$repeatkey]);
         }
         for ($repeatcounter = 1; $repeatcounter <= $repeat; $repeatcounter++) {
             for ($i = 1; $i <= $instances; $i++) {
                 $rowtoadd = $row;
                 $datanode = new TableNode();
                 $datanode->addRow($firstrow);
                 foreach ($rowtoadd as $key => $value) {
                     if ($reference) {
                         $rowtoadd[$key] = str_replace("#count#", $referencecounter, $value);
                     } else {
                         $rowtoadd[$key] = str_replace("#count#", $i, $value);
                     }
                     $rowtoadd[$key] = str_replace("#refcount#", $i, $rowtoadd[$key]);
                     $rowtoadd[$key] = str_replace("#repeatcount#", $repeatcounter, $rowtoadd[$key]);
                 }
                 $datanode->addRow($rowtoadd);
                 // Call generator function.
                 //$contexttouse->$function($elementname, $datanode);
                 $datanodes[] = $datanode;
                 // We want sequential filling of data so increment reference counter.
                 if ($reference && $i % $maxperreference == 0) {
                     $referencecounter++;
                 }
             }
         }
     }
     return $datanodes;
 }
开发者ID:rajeshtaneja,项目名称:moodle-performance-toolkit,代码行数:69,代码来源:behat_tool_generator.php

示例6: loadTableHash

 /**
  * Loads table from provided hash.
  *
  * @param array $hash Table hash
  *
  * @return TableNode
  */
 protected function loadTableHash(array $hash)
 {
     $table = new Node\TableNode();
     foreach ($hash as $line => $row) {
         $table->addRow($row, $line);
     }
     return $table;
 }
开发者ID:unkerror,项目名称:Budabot,代码行数:15,代码来源:ArrayLoader.php

示例7: translationTestDataProvider

    public function translationTestDataProvider()
    {
        $keywords = $this->getKeywords();
        $lexer = new Lexer($keywords);
        $parser = new Parser($lexer);
        $dumper = new KeywordsDumper($keywords);
        $data = array();
        foreach ($this->getKeywordsArray() as $lang => $i18nKeywords) {
            $features = array();
            foreach (explode('|', $i18nKeywords['feature']) as $transNum => $featureKeyword) {
                $line = 1;
                if ('en' !== $lang) {
                    $line = 2;
                }
                $feature = new Node\FeatureNode('Internal operations', <<<DESC
In order to stay secret
As a secret organization
We need to be able to erase past agents' memory
DESC
, $lang . '_' . ($transNum + 1) . '.feature', $line);
                $feature->setLanguage($lang);
                $feature->setKeyword($featureKeyword);
                $line += 5;
                $background = new Node\BackgroundNode(null, $line);
                $keywords = explode('|', $i18nKeywords['background']);
                $background->setKeyword($keywords[0]);
                $line += 1;
                $line = $this->addSteps($background, $i18nKeywords['given'], 'there is agent A', $line);
                $line = $this->addSteps($background, $i18nKeywords['and'], 'there is agent B', $line);
                $feature->setBackground($background);
                $line += 1;
                foreach (explode('|', $i18nKeywords['scenario']) as $scenarioKeyword) {
                    $scenario = new Node\ScenarioNode('Erasing agent memory', $line);
                    $scenario->setKeyword($scenarioKeyword);
                    $line += 1;
                    $line = $this->addSteps($scenario, $i18nKeywords['given'], 'there is agent J', $line);
                    $line = $this->addSteps($scenario, $i18nKeywords['and'], 'there is agent K', $line);
                    $line = $this->addSteps($scenario, $i18nKeywords['when'], 'I erase agent K\'s memory', $line);
                    $line = $this->addSteps($scenario, $i18nKeywords['then'], 'there should be agent J', $line);
                    $line = $this->addSteps($scenario, $i18nKeywords['but'], 'there should not be agent K', $line);
                    $feature->addScenario($scenario);
                    $line += 1;
                }
                foreach (explode('|', $i18nKeywords['scenario_outline']) as $outlineKeyword) {
                    $outline = new Node\OutlineNode('Erasing other agents\' memory', $line);
                    $outline->setKeyword($outlineKeyword);
                    $line += 1;
                    $line = $this->addSteps($outline, $i18nKeywords['given'], 'there is agent <agent1>', $line);
                    $line = $this->addSteps($outline, $i18nKeywords['and'], 'there is agent <agent2>', $line);
                    $line = $this->addSteps($outline, $i18nKeywords['when'], 'I erase agent <agent2>\'s memory', $line);
                    $line = $this->addSteps($outline, $i18nKeywords['then'], 'there should be agent <agent1>', $line);
                    $line = $this->addSteps($outline, $i18nKeywords['but'], 'there should not be agent <agent2>', $line);
                    $line += 1;
                    $examples = new Node\TableNode();
                    $examples->addRow('                      | agent1 | agent2 |', ++$line);
                    $examples->addRow('                      | D      | M      |', ++$line);
                    $outline->setExamples($examples);
                    $keywords = explode('|', $i18nKeywords['examples']);
                    $examples->setKeyword($keywords[0]);
                    $line += 1;
                    $feature->addScenario($outline);
                    $line += 1;
                }
                $features[] = $feature;
            }
            $dumped = $dumper->dump($lang, false);
            $parsed = array();
            try {
                foreach ($dumped as $num => $dumpedFeature) {
                    $parsed[] = $parser->parse($dumpedFeature, $lang . '_' . ($num + 1) . '.feature');
                }
            } catch (\Exception $e) {
                throw new \Exception($e->getMessage() . ":\n" . $dumped, 0, $e);
            }
            $data[] = array($lang, $features, $parsed);
        }
        return $data;
    }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:78,代码来源:KeywordsTest.php

示例8: parseTable

 /**
  * Parses table token & returns it's node.
  *
  * @return  Behat\Gherkin\Node\TableNode
  */
 protected function parseTable()
 {
     $token = $this->expectTokenType('TableRow');
     $node = new Node\TableNode();
     $node->addRow($token->columns);
     $this->skipExtraChars();
     while ('TableRow' === $this->predictTokenType()) {
         $token = $this->expectTokenType('TableRow');
         $node->addRow($token->columns);
         $this->skipExtraChars();
     }
     return $node;
 }
开发者ID:kingsj,项目名称:core,代码行数:18,代码来源:Parser.php

示例9: providerTableNode

    public function providerTableNode()
    {
        // complete table
        $node1 = new TableNode();
        $node1->addRow(array('lib1', 'lib2', 'lib3'));
        $node1->addRow(array(1, 2, 3));
        $node1->addRow(array(4, 5, 6));
        $expected1 = '
| lib1 | lib2 | lib3 |
| 1    | 2    | 3    |
| 4    | 5    | 6    |';
        // empty table
        $node2 = new TableNode();
        $expected2 = '';
        return array(array($node1, $expected1), array($node2, $expected2));
    }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:16,代码来源:GherkinDumperTest.php


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