コード例 #1
0
 /**
  * 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);
     }
 }
コード例 #2
0
 /**
  * @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);
     }
 }
コード例 #3
0
 /**
  * @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();
 }
コード例 #4
0
 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);
 }
コード例 #5
0
ファイル: Parse.php プロジェクト: BackupTheBerlios/phpfit-svn
 /**
  * @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;
 }
コード例 #6
0
 /**
  * @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;
 }
コード例 #7
0
 /**
  * @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);
 }
コード例 #8
0
 /**
  * @param string $body
  * @return PHPFIT_Parse
  */
 public function td($body)
 {
     return PHPFIT_Parse::createSimple("td", $this->infoInColor($body), null, null);
 }
コード例 #9
0
ファイル: DoFixture.php プロジェクト: metaclass-nl/fit-shelf
 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;
 }
コード例 #10
0
 public static function findMatchingEndTag($lc, $matchFromHere, $tag, $offset)
 {
     return parent::findMatchingEndTag($lc, $matchFromHere, $tag, $offset);
 }
コード例 #11
0
 /**
  * @param PHPFIT_Parse $cell
  */
 public function ignore($cell)
 {
     $cell->addToTag(self::getCssProperty('ignored'));
     $this->counts->ignores++;
 }
コード例 #12
0
ファイル: Row.php プロジェクト: BackupTheBerlios/phpfit-svn
 /**
  * @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;
 }