/**
  * Initializes table.
  *
  * @param TableNode $cleanTable
  * @param array     $tokens
  *
  * @internal param string $table Initial table string
  */
 public function __construct(TableNode $cleanTable, array $tokens)
 {
     $this->cleanRows = $rows = $cleanTable->getRows();
     foreach ($tokens as $key => $value) {
         foreach (array_keys($rows) as $row) {
             foreach (array_keys($rows[$row]) as $col) {
                 $rows[$row][$col] = str_replace('<' . $key . '>', $value, $rows[$row][$col]);
             }
         }
     }
     $this->setKeyword($cleanTable->getKeyword());
     $this->setRows($rows);
 }
Ejemplo n.º 2
0
 /**
  * Replaces tokens in table with row values.
  *
  * @param TableNode $argument
  *
  * @return TableNode
  */
 protected function replaceTableArgumentTokens(TableNode $argument)
 {
     $table = $argument->getTable();
     foreach ($table as $line => $row) {
         foreach (array_keys($row) as $col) {
             $table[$line][$col] = $this->replaceTextTokens($table[$line][$col]);
         }
     }
     return new TableNode($table);
 }
Ejemplo n.º 3
0
 /**
  * Fills in form fields with provided table.
  *
  * @When /^(?:|I )fill in the following:$/
  */
 public function fillFields(TableNode $fields)
 {
     foreach ($fields->getRowsHash() as $field => $value) {
         $this->fillField($field, $value);
     }
 }
Ejemplo n.º 4
0
 /**
  * Initializes example table.
  *
  * @param array  $table   Table in form of [$rowLineNumber => [$val1, $val2, $val3]]
  * @param string $keyword
  */
 public function __construct(array $table, $keyword)
 {
     $this->keyword = $keyword;
     parent::__construct($table);
 }
Ejemplo n.º 5
0
 /**
  * Retrieves the header of the table.
  *
  * @param TableNode $table The table node.
  * @return Array The names of the header cells.
  */
 private function getHeader($table)
 {
     $rows = $table->getChildren();
     if (empty($rows)) {
         return array();
     }
     if (count($rows[0]->getChildren()) > 1) {
         $headerRow = $rows[0];
     } else {
         if (count($rows) > 1 && count($rows[1]->getChildren()) > 1) {
             $headerRow = $rows[1];
         } else {
             return array();
         }
     }
     $header = array();
     foreach ($headerRow->getChildren() as $headerCell) {
         $headerStr = $this->nodeToString($headerCell);
         if (empty($headerStr)) {
             continue;
         }
         $header[] = $headerStr;
     }
     return $header;
 }