setKeywordsDumperFunction() public method

Callable should accept 2 arguments (array $keywords and Boolean $isShort)
public setKeywordsDumperFunction ( callable $mapper )
$mapper callable Mapper function
示例#1
0
 /**
  * Initializes controller.
  *
  * @param KeywordsDumper      $dumper
  * @param TranslatorInterface $translator
  */
 public function __construct(KeywordsDumper $dumper, TranslatorInterface $translator)
 {
     $dumper->setKeywordsDumperFunction(array($this, 'dumpKeywords'));
     $this->keywordsDumper = $dumper;
     $this->translator = $translator;
 }
    public function testRuKeywordsCustomKeywordsDumper()
    {
        $dumper = new KeywordsDumper($this->keywords);
        $dumper->setKeywordsDumperFunction(function ($keywords, $short) {
            return '<keyword>' . implode(', ', $keywords) . '</keyword>';
        });
        $dumped = $dumper->dump('ru');
        $etalon = <<<GHERKIN
# language: ru
<keyword>Функционал, Фича</keyword>: Internal operations
  In order to stay secret
  As a secret organization
  We need to be able to erase past agents' memory

  <keyword>Предыстория, Бэкграунд</keyword>:
    <keyword>Допустим</keyword> there is agent A
    <keyword>И</keyword> there is agent B

  <keyword>Сценарий, История</keyword>: Erasing agent memory
    <keyword>Допустим</keyword> there is agent J
    <keyword>И</keyword> there is agent K
    <keyword>Если, @</keyword> I erase agent K's memory
    <keyword>То</keyword> there should be agent J
    <keyword>Но</keyword> there should not be agent K

  <keyword>Структура сценария, Аутлайн</keyword>: Erasing other agents' memory
    <keyword>Допустим</keyword> there is agent <agent1>
    <keyword>И</keyword> there is agent <agent2>
    <keyword>Если, @</keyword> I erase agent <agent2>'s memory
    <keyword>То</keyword> there should be agent <agent1>
    <keyword>Но</keyword> there should not be agent <agent2>

    <keyword>Значения</keyword>:
      | agent1 | agent2 |
      | D      | M      |
GHERKIN;
        $this->assertEquals($etalon, $dumped);
    }
示例#3
0
 /**
  * Initializes definition dispatcher.
  *
  * @param   Behat\Gherkin\Keywords\KeywordsDumper   $dumper
  */
 public function __construct(KeywordsDumper $dumper)
 {
     $dumper->setKeywordsDumperFunction(array($this, 'dumpKeywords'));
     $this->dumper = $dumper;
 }