예제 #1
0
 /**
  * @dataProvider provideCodeRenderer
  * @param  ICodeRenderer $renderer The code renderer to use
  * @param  WidgetInfo $widget     Widget to render for
  * @param  array  $args           Arguments to pass to the widget
  * @param  string $expectedOutput Expected HTML output
  */
 public function testCodeRenderer(ICodeRenderer $renderer, $widgetInfo, array $args, $expectedOutput)
 {
     $code = $renderer->render($widgetInfo, $args);
     // Unstrip
     $code = $this->getParser()->mStripState->unstripBoth($code);
     $this->assertEquals($code, $expectedOutput);
 }
예제 #2
0
 /**
  * Renders an OOUI widget demo
  * @param  WidgetInfo    $info     A WidgetInfo class for the widget being demonstrated.
  * should exist in the 'classMap' config section
  * @param  array         $args     Processed arguments to pass directly to the OOUI widget.
  * @param  ICodeRenderer $codeRenderer A code renderer for showing source code
  * @return string                  HTML output.
  */
 public static function getDemo(WidgetInfo $class, array $args, ICodeRenderer $codeRenderer)
 {
     self::setupOOUI();
     $factory = self::getContainer('widgetFactory');
     try {
         $obj = $factory->getWidget($class, $args);
     } catch (MWException $excep) {
         return self::renderError($excep);
     }
     $output = $obj->toString();
     $code = $codeRenderer->render($class, $args);
     return $code . Html::rawElement('div', array('class' => 'ooui-playground-widget'), $output);
 }