Esempio n. 1
0
 public function run($test)
 {
     testFSWrapper::loadFilesystem($test);
     $view = new Opt_View('test.tpl');
     if (file_exists('test://data.php')) {
         eval(file_get_contents('test://data.php'));
     }
     $out = new Opt_Output_Return();
     $expected = file_get_contents('test://expected.txt');
     if (strpos($expected, 'OUTPUT') === 0) {
         // This test shoud give correct results
         try {
             $result = $out->render($view);
             if ($this->stripWs(trim(file_get_contents('test://result.txt'))) === ($o = $this->stripWs(trim($result)))) {
                 return true;
             }
             echo $result;
             die('Invalid output: ' . $o . "\n");
         } catch (Opt_Exception $e) {
             die('Exception returned: #' . get_class($e) . ': ' . $e->getMessage() . "\n");
         }
     } else {
         // This test should generate an exception
         $expected = trim($expected);
         try {
             $out->render($view);
         } catch (Opt_Exception $e) {
             if ($expected != get_class($e)) {
                 die('Invalid exception returned: #' . get_class($e) . ', ' . $expected . " expected.\n");
             }
             return true;
         }
         die("Exception NOT returned, but should be: " . $expected . "\n");
     }
 }
Esempio n. 2
0
 /**
  * @dataProvider correctProvider
  */
 public function testCorrect($test)
 {
     testFSWrapper::loadFilesystem(FEAT_DIR . $test);
     $view = new Opt_View('test.tpl');
     if (file_exists('test://data.php')) {
         eval(file_get_contents('test://data.php'));
     }
     $out = new Opt_Output_Return();
     $expected = file_get_contents('test://expected.txt');
     if (strpos($expected, 'OUTPUT') === 0) {
         // This test shoud give correct results
         try {
             $result = $out->render($view);
             $this->assertEquals($this->stripWs(trim(file_get_contents('test://result.txt'))), $this->stripWs(trim($result)));
         } catch (Opt_Exception $e) {
             $this->fail('Exception returned: #' . get_class($e) . ': ' . $e->getMessage());
         }
     } else {
         // This test should generate an exception
         $expected = trim($expected);
         try {
             $out->render($view);
         } catch (Opt_Exception $e) {
             if ($expected != get_class($e)) {
                 $this->fail('Invalid exception returned: #' . get_class($e) . ', ' . $expected . ' expected.');
             }
             return true;
         }
         $this->fail('Exception NOT returned, but should be: ' . $expected);
     }
 }
Esempio n. 3
0
 /**
  * Tests if the relative path switch works.
  * @expectedException Opt_TemplateNotFound_Exception
  */
 public function testRelativePathsEnabled()
 {
     $this->tpl->allowRelativePaths = true;
     $view = new Opt_View('../template.tpl');
     $output = new Opt_Output_Return();
     $output->render($view);
 }