ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilPhantomJSRendererTest.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 define("PATH_TO_PHANTOMJS", '');
11 {
12  protected $default_config = array('path' => '/usr/local/bin/phantomjs',
13  'page_size' => 'A4',
14  'margin' => '1cm',
15  'javascript_delay' => 200,
16  'viewport' => '',
17  'orientation' => 'Portrait',
18  'header_type' => 0,
19  'header_text' => '',
20  'header_height' => '0cm',
21  'header_show_pages' => 0,
22  'footer_type' => 0,
23  'footer_text' => '',
24  'footer_height' => '0cm',
25  'footer_show_pages' => 0,
26  'page_type' => 0);
27 
28 
29  protected $beckersche_config = array('path' => '/usr/local/bin/phantomjs',
30  'page_size' => 'A4',
31  'margin' => '1cm',
32  'javascript_delay' => 200,
33  'orientation' => 'Portrait',
34  'viewport' => '',
35  'header_type' => 0,
36  'header_text' => '',
37  'header_height' => '0cm',
38  'header_show_pages' => 0,
39  'footer_type' => 0,
40  'footer_text' => '',
41  'footer_height' => '0cm',
42  'footer_show_pages' => 0,
43  'page_type' => 0);
44 
45  protected static function getMethod($name)
46  {
47  $class = new ReflectionClass('ilPhantomJSRenderer');
48  $method = $class->getMethod($name);
49  $method->setAccessible(true);
50  return $method;
51  }
52 
53  public function testInstanceCanBeCreated()
54  {
55  $transformer = new ilPhantomJSRenderer(true);
56  $this->assertInstanceOf('ilPhantomJSRenderer', $transformer);
57  }
58 
59 
60  public function testGetSettings()
61  {
62  $obj = new ilPhantomJSRenderer(true);
63  $config = $obj->getDefaultConfig('Bla', 'Blubb');
64  $this->assertSame($this->default_config, $config);
65  }
66 
67  public function testBeckerscheSettingsText()
68  {
69  $transformer = self::getMethod('getCommandLineConfig');
70  $obj = new ilPhantomJSRenderer(true);
72  $this->assertSame('"{\"page_size\":\"A4\",\"orientation\":\"Portrait\",\"margin\":\"1cm\",\"delay\":200,\"viewport\":\"\",\"header\":null,\"footer\":null,\"page_type\":0}"', $transformer->invokeArgs($obj, array($config)));
73  }
74 
76  {
77  $transformer = self::getMethod('getCommandLineConfig');
78  $obj = new ilPhantomJSRenderer(true);
80  $config['pagesize'] = 'A4';
81  $config['header_text'] = 'Hello';
82  $config['header_height'] = '1cm';
83  $config['header_type'] = '1';
84  $config['header_show_pages'] = false;
85 
86  $this->assertSame('"{\"page_size\":\"A4\",\"orientation\":\"Portrait\",\"margin\":\"1cm\",\"delay\":200,\"viewport\":\"\",\"header\":{\"text\":\"Hello\",\"height\":\"1cm\",\"show_pages\":false},\"footer\":null,\"page_type\":0}"', $transformer->invokeArgs($obj, array($config)));
87  }
88 
89  public function testFooterSettingsText()
90  {
91  $transformer = self::getMethod('getCommandLineConfig');
92  $obj = new ilPhantomJSRenderer(true);
94  $config['pagesize'] = 'A4';
95  $config['footer_text'] = 'Hello';
96  $config['footer_height'] = '1cm';
97  $config['footer_type'] = '1';
98  $config['footer_show_pages'] = true;
99 
100  $this->assertSame('"{\"page_size\":\"A4\",\"orientation\":\"Portrait\",\"margin\":\"1cm\",\"delay\":200,\"viewport\":\"\",\"header\":null,\"footer\":{\"text\":\"Hello\",\"height\":\"1cm\",\"show_pages\":true},\"page_type\":0}"', $transformer->invokeArgs($obj, array($config)));
101  }
102 
104  {
105  $transformer = self::getMethod('getCommandLineConfig');
106  $obj = new ilPhantomJSRenderer(true);
108  $config['pagesize'] = 'A4';
109  $config['footer_text'] = 'Hello';
110  $config['footer_height'] = '1cm';
111  $config['footer_type'] = '1';
112  $config['footer_show_pages'] = false;
113 
114  $this->assertSame('"{\"page_size\":\"A4\",\"orientation\":\"Portrait\",\"margin\":\"1cm\",\"delay\":200,\"viewport\":\"\",\"header\":null,\"footer\":{\"text\":\"Hello\",\"height\":\"1cm\",\"show_pages\":false},\"page_type\":0}"', $transformer->invokeArgs($obj, array($config)));
115  }
116 }
if($format !==null) $name
Definition: metadata.php:146
Create styles array
The data for the language used.