Beispiel #1
0
    public function testGetTableAsString()
    {
        $table = new TableNode(array(5 => array('id', 'username', 'password'), 10 => array('42', 'everzet', 'qwerty'), 13 => array('2', 'antono', "pa\$sword")));
        $expected = <<<TABLE
| id | username | password |
| 42 | everzet  | qwerty   |
| 2  | antono   | pa\$sword |
TABLE;
        $this->assertEquals($expected, $table->getTableAsString());
    }
 /**
  * @Then I should see the following in the repeated :element element
  */
 public function iShouldSeeTheFollowingInTheRepeatedElementWithinTheContextOfTheElement2($element, TableNode $table)
 {
     $elements = $this->getSession()->getPage()->findAll('css', $element);
     $hash = $table->getHash();
     /*foreach ( $elements as $index => $element ) {
     			try {
     				if ( ! $element->isVisible() ) {
     					unset( $elements[$index] );
     				}
     			} catch ( \Exception $e ) {
     				//do nothing.
     			}
     		}*/
     $actual = array(array('text' => 'text'));
     foreach ($elements as $n => $element) {
         $actual[] = array('text' => $elements[$n]->getText());
     }
     $actual_table = new TableNode($actual);
     if ($actual_table->getTableAsString() != $table->getTableAsString()) {
         var_dump($table->table);
         var_dump($actual_table->table);
         throw new \Exception(sprintf("Found elements:\n %s", $actual_table->getTableAsString()));
     }
 }