ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilPhantomJSRendererUiTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once __DIR__ . '/../classes/renderer/phantomjs/class.ilPhantomJSRenderer.php';
5 require_once 'Services/Form/classes/class.ilTextInputGUI.php';
6 require_once 'Services/Form/classes/class.ilCheckboxInputGUI.php';
7 require_once 'Services/Form/classes/class.ilSelectInputGUI.php';
8 require_once 'Services/Form/classes/class.ilFormSectionHeaderGUI.php';
9 require_once 'Services/Language/classes/class.ilLanguage.php';
10 require_once 'libs/composer/vendor/pimple/pimple/src/Pimple/Container.php';
11 require_once 'src/DI/Container.php';
12 $GLOBALS["DIC"] = new \ILIAS\DI\Container();
18 {
19  protected $lng;
20 
21  protected $form;
22 
23  protected function setUp()
24  {
25  $this->form = new ilPhantomJSRenderer(true);
26  $this->callMethod($this->form, 'setLanguage', array($this->lng));
27  $this->setGlobalVariable('lng', $this->lng);
28  $this->setGlobalVariable('ilCtrl', null);
29  }
34  protected function setGlobalVariable($name, $value)
35  {
36  global $DIC;
37 
38  $GLOBALS[$name] = $value;
39 
40  unset($DIC[$name]);
41  $DIC[$name] = function ($c) use ($name) {
42  return $GLOBALS[$name];
43  };
44  }
48  public function __construct()
49  {
50  $this->lng = $this->getMockBuilder('ilLanguage')
51  ->disableOriginalConstructor()
52  ->getMock();
53  $this->lng->method('txt')
54  ->will($this->returnArgument(0));
55  }
56 
57  protected static function getMethod($name)
58  {
59  $class = new ReflectionClass('ilPhantomJSRenderer');
60  $method = $class->getMethod($name);
61  $method->setAccessible(true);
62  return $method;
63  }
64 
65  public static function callMethod($obj, $name, array $args)
66  {
67  $class = new ReflectionClass($obj);
68  $method = $class->getMethod($name);
69  $method->setAccessible(true);
70  return $method->invokeArgs($obj, $args);
71  }
72 
73  public function testBuildJavascriptDelayForm()
74  {
75  $transformer = self::getMethod('buildJavascriptDelayForm');
76  $this->assertInstanceOf('ilTextInputGUI', $transformer->invokeArgs($this->form, array()));
77  $this->assertSame('javascript_delay', $transformer->invokeArgs($this->form, array())->getTitle());
78  $this->assertSame('javascript_delay', $transformer->invokeArgs($this->form, array())->getPostVar());
79  }
80 
81  public function testBuildMarginForm()
82  {
83  $transformer = self::getMethod('buildMarginForm');
84  $this->assertInstanceOf('ilTextInputGUI', $transformer->invokeArgs($this->form, array()));
85  $this->assertSame('margin', $transformer->invokeArgs($this->form, array())->getTitle());
86  $this->assertSame('margin', $transformer->invokeArgs($this->form, array())->getPostVar());
87  }
88 
89  public function testBuildFooterHeightForm()
90  {
91  $transformer = self::getMethod('buildFooterHeightForm');
92  $this->assertInstanceOf('ilTextInputGUI', $transformer->invokeArgs($this->form, array()));
93  $this->assertSame('footer_height', $transformer->invokeArgs($this->form, array())->getTitle());
94  $this->assertSame('footer_height', $transformer->invokeArgs($this->form, array())->getPostVar());
95  }
96 
97  public function testBuildFooterTextForm()
98  {
99  $transformer = self::getMethod('buildFooterTextForm');
100  $this->assertInstanceOf('ilTextInputGUI', $transformer->invokeArgs($this->form, array()));
101  $this->assertSame('footer_text', $transformer->invokeArgs($this->form, array())->getTitle());
102  $this->assertSame('footer_text', $transformer->invokeArgs($this->form, array())->getPostVar());
103  }
104 
105  public function testBuildHeaderHeightForm()
106  {
107  $transformer = self::getMethod('buildHeaderHeightForm');
108  $this->assertInstanceOf('ilTextInputGUI', $transformer->invokeArgs($this->form, array()));
109  $this->assertSame('header_height', $transformer->invokeArgs($this->form, array())->getTitle());
110  $this->assertSame('header_height', $transformer->invokeArgs($this->form, array())->getPostVar());
111  }
112 
113  public function testBuildHeaderTextForm()
114  {
115  $transformer = self::getMethod('buildHeaderTextForm');
116  $this->assertInstanceOf('ilTextInputGUI', $transformer->invokeArgs($this->form, array()));
117  $this->assertSame('head_text', $transformer->invokeArgs($this->form, array())->getTitle());
118  $this->assertSame('header_text', $transformer->invokeArgs($this->form, array())->getPostVar());
119  }
120 
122  {
123  $transformer = self::getMethod('buildHeaderPageNumbersForm');
124  $this->assertInstanceOf('ilCheckboxInputGUI', $transformer->invokeArgs($this->form, array()));
125  $this->assertSame('header_show_pages', $transformer->invokeArgs($this->form, array())->getTitle());
126  $this->assertSame('header_show_pages', $transformer->invokeArgs($this->form, array())->getPostVar());
127  }
128 
130  {
131  $transformer = self::getMethod('buildFooterPageNumbersForm');
132  $this->assertInstanceOf('ilCheckboxInputGUI', $transformer->invokeArgs($this->form, array()));
133  $this->assertSame('footer_show_pages', $transformer->invokeArgs($this->form, array())->getTitle());
134  $this->assertSame('footer_show_pages', $transformer->invokeArgs($this->form, array())->getPostVar());
135  }
136 
137  public function testBuildViewPortForm()
138  {
139  $transformer = self::getMethod('buildViewPortForm');
140  $this->assertInstanceOf('ilTextInputGUI', $transformer->invokeArgs($this->form, array()));
141  $this->assertSame('viewport', $transformer->invokeArgs($this->form, array())->getTitle());
142  $this->assertSame('viewport', $transformer->invokeArgs($this->form, array())->getPostVar());
143  }
144 
145  public function testBuildPageSizesForm()
146  {
147  $transformer = self::getMethod('buildPageSizesForm');
148  $this->assertInstanceOf('ilSelectInputGUI', $transformer->invokeArgs($this->form, array()));
149  $this->assertSame('page_size', $transformer->invokeArgs($this->form, array())->getTitle());
150  $this->assertSame('page_size', $transformer->invokeArgs($this->form, array())->getPostVar());
151  }
152 
153  public function testBuildOrientationForm()
154  {
155  $transformer = self::getMethod('buildOrientationForm');
156  $this->assertInstanceOf('ilSelectInputGUI', $transformer->invokeArgs($this->form, array()));
157  $this->assertSame('orientation', $transformer->invokeArgs($this->form, array())->getTitle());
158  $this->assertSame('orientation', $transformer->invokeArgs($this->form, array())->getPostVar());
159  }
160 }
__construct()
ilPhantomJSRenderer constructor.
global $DIC
Definition: saml.php:7
$GLOBALS["DIC"]
static callMethod($obj, $name, array $args)