/** * process a single cell * * Generic processing of a table cell. Well, this function * just ignores cells. * * This method may be overwritten by a subclass (ColumnFixture) * * @param PHPFIT_Parse $cell */ public function doCell($cell) { $adapter = null; if (isset($this->columnBindings[$cell->count])) { $adapter = $this->columnBindings[$cell->count]; } try { $text = $cell->text(); // skip the rest if there is no adapter if ($adapter == null) { $this->ignore($cell); return; } // a column can be a value if ($adapter->field != null) { $adapter->set($adapter->parse($text)); return; } // or a column can be method if ($adapter->method != null) { $this->checkCell($cell, $adapter); return; } } catch (Exception $e) { $this->exception($cell, $e); } }
/** * @param PHPFIT_Parse $cell * @param string/int $value */ public function check($cell, $value) { if ($cell->text() == strval($value)) { $this->right($cell); } else { $this->wrong($cell, $value); } }
/** * @param string $fixturesDirectory * @return string results */ public function process($fixturesDirectory) { $this->fixture = new PHPFIT_Fixture($fixturesDirectory); $this->tables = PHPFIT_Parse::create($this->input); $this->fixture->doTables($this->tables); return $this->fixture->counts->toString(); }
public function doRun($file, $right, $wrong, $ignores, $exceptions) { $input = 'examples/input/' . $file . '.html'; $tables = PHPFIT_Parse::create(file_get_contents($input, true)); $fixture = new PHPFIT_Fixture(); $fixture->doTables($tables); $this->assertEqual($right, $fixture->counts->right); $this->assertEqual($wrong, $fixture->counts->wrong); $this->assertEqual($ignores, $fixture->counts->ignores); $this->assertEqual($exceptions, $fixture->counts->exceptions); }
/** * @return string */ public function toString() { $out = $this->leader; $out .= $this->tag; if ($this->parts != null) { $out .= $this->parts->toString(); } else { $out .= $this->body; } $out .= $this->end; if ($this->more != null) { $out .= $this->more->toString(); } else { $out .= $this->trailer; } return $out; }
/** * @param Exception $e */ protected function exception(Exception $e, $fixture) { $message = "Exception occurred!"; $tables = PHPFIT_Parse::createSimple("span", $message, null, null); $fixture->exception($tables, $e); $fixture->listener->tableFinished($tables); $fixture->listener->tablesFinished($fixture->counts); return $tables; }
/** * @param string $body * @param PHPFIT_Parse $more * @return PHPFIT_Parse */ protected function td($body, $more) { return PHPFIT_Parse::createSimple("td", $this->infoInColor($body), null, $more); }
/** * @param string $body * @return PHPFIT_Parse */ public function td($body) { return PHPFIT_Parse::createSimple("td", $this->infoInColor($body), null, null); }
function doShow($cells) { try { $doCells = $this->doRestOfCells($cells->more, false); } catch (\Exception $e) { $this->exception($cells->more, $e); return; } $adapter = $doCells->getAdapter(); $newCell = \PHPFIT_Parse::createSimple('td', $adapter->valueToString($doCells->getResult())); $doCells->getLastCell()->more = $newCell; }
public static function findMatchingEndTag($lc, $matchFromHere, $tag, $offset) { return parent::findMatchingEndTag($lc, $matchFromHere, $tag, $offset); }
/** * @param PHPFIT_Parse $cell */ public function ignore($cell) { $cell->addToTag(self::getCssProperty('ignored')); $this->counts->ignores++; }
/** * @param array $row * @return PHPFIT_Parse */ protected function buildCells($row) { $root = PHPFIT_Parse::createSimple(null, null, null, null); $next = $root; foreach ($this->columnBindings as $adapter) { $next = $next->more = PHPFIT_Parse::createSimple('td', '', null, null); if (!$adapter) { $this->ignore($next); } else { try { $adapter->target = $row; $next->body = self::gray(self::escape($adapter->toString($adapter->get()))); } catch (Exception $e) { $this->exception($next, $e); } } } return $root->more; }