/**
  * @dataProvider getAutomatons
  */
 public function testVisitAutomaton(array $sequences, array $labels, $name)
 {
     $visitor = new slAutomatonDotVisitor();
     $automaton = new slSingleOccurenceAutomaton();
     foreach ($sequences as $sequence) {
         $automaton->learn($sequence);
     }
     $result = $visitor->visit($automaton, $labels);
     // Read expectation from file, if available
     if (!is_file($file = __DIR__ . '/data/' . $name . '.dot')) {
         $this->MarkTestSkipped("No comparision file available; Generated result:\n" . $result);
     }
     $this->assertEquals(file_get_contents($file), $result);
 }
Esempio n. 2
0
 /**
  * Store a dot file representing the current automaton for debugging
  * 
  * @param slSingleOccurenceAutomaton $automaton 
  * @param array $regularExpressions 
  * @param int $counter 
  * @param string $label 
  * @return void
  */
 protected function debugAutomaton(slSingleOccurenceAutomaton $automaton, array $regularExpressions, $counter, $label)
 {
     // @codeCoverageIgnoreStart
     // This is pure debugging code, which is not required to be covered by
     // unit tests.
     return;
     $fileName = sprintf('debug/%04d_%s.dot', $counter, $label);
     $regExpVisitor = new slRegularExpressionStringVisitor();
     $labels = array_map(array($regExpVisitor, 'visit'), $regularExpressions);
     $automatonVisitor = new slAutomatonDotVisitor();
     file_put_contents($fileName, $automatonVisitor->visit($automaton, $labels));
     // @codeCoverageIgnoreEnd
 }