ILIAS  trunk Revision v11.0_alpha-2658-ge2404539063
ILIAS\GlobalScreen\Scope\Layout\MediaTest Class Reference

Class MediaTest. More...

+ Inheritance diagram for ILIAS\GlobalScreen\Scope\Layout\MediaTest:
+ Collaboration diagram for ILIAS\GlobalScreen\Scope\Layout\MediaTest:

Public Member Functions

 testAddCssFile ()
 
 testAddCssFileWithQuery ()
 
 testAddInlineCss ()
 
 testAddJsFile ()
 
 testAddJsFileWithQuery ()
 

Data Fields

string $version
 
MetaContent $meta_content
 

Protected Member Functions

 setUp ()
 

Detailed Description

Class MediaTest.

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

Definition at line 34 of file MediaTest.php.

Member Function Documentation

◆ setUp()

ILIAS\GlobalScreen\Scope\Layout\MediaTest::setUp ( )
protected

Definition at line 39 of file MediaTest.php.

39  : void
40  {
41  parent::setUp();
42  $this->version = '1.2.3.4.5.6.7.8.9';
43  $this->meta_content = new MetaContent(
44  $this->version,
45  true,
46  false,
47  true,
48  true
49  );
50  }

◆ testAddCssFile()

ILIAS\GlobalScreen\Scope\Layout\MediaTest::testAddCssFile ( )

Definition at line 52 of file MediaTest.php.

References $path, and ILIAS\GlobalScreen\Scope\Layout\MetaContent\MetaContent\MEDIA_SCREEN.

52  : void
53  {
54  $path = '/path/to/file.css';
55  $this->meta_content->addCss($path);
56  $collection = $this->meta_content->getCss();
57 
58  $iterator_to_array = iterator_to_array($collection->getItems());
59  $first_item = array_shift($iterator_to_array);
60  $this->assertInstanceOf(Css::class, $first_item);
61  $this->assertSame($path . '?version=' . $this->version, $first_item->getContent());
62  $this->assertSame(MetaContent::MEDIA_SCREEN, $first_item->getMedia());
63  }
$path
Definition: ltiservices.php:29

◆ testAddCssFileWithQuery()

ILIAS\GlobalScreen\Scope\Layout\MediaTest::testAddCssFileWithQuery ( )

Definition at line 65 of file MediaTest.php.

References $path, and ILIAS\GlobalScreen\Scope\Layout\MetaContent\MetaContent\MEDIA_SCREEN.

65  : void
66  {
67  $path = '/path/to/file.css?my=query';
68  $this->meta_content->addCss($path);
69  $collection = $this->meta_content->getCss();
70 
71  $iterator_to_array = iterator_to_array($collection->getItems());
72  $first_item = array_shift($iterator_to_array);
73  $this->assertInstanceOf(Css::class, $first_item);
74  $this->assertSame($path . '&version=' . $this->version, $first_item->getContent());
75  $this->assertSame(MetaContent::MEDIA_SCREEN, $first_item->getMedia());
76  }
$path
Definition: ltiservices.php:29

◆ testAddInlineCss()

ILIAS\GlobalScreen\Scope\Layout\MediaTest::testAddInlineCss ( )

Definition at line 78 of file MediaTest.php.

References ILIAS\GlobalScreen\Scope\Layout\MetaContent\MetaContent\MEDIA_SCREEN.

78  : void
79  {
80  $css = 'body {background-color:red;}';
81  $this->meta_content->addInlineCss($css);
82  $collection = $this->meta_content->getInlineCss();
83 
84  $first_item = iterator_to_array($collection->getItems())[0];
85  $this->assertInstanceOf(InlineCss::class, $first_item);
86  $this->assertSame($css, $first_item->getContent());
87  $this->assertSame(MetaContent::MEDIA_SCREEN, $first_item->getMedia());
88  }

◆ testAddJsFile()

ILIAS\GlobalScreen\Scope\Layout\MediaTest::testAddJsFile ( )

Definition at line 90 of file MediaTest.php.

References $path.

90  : void
91  {
92  $path = '/path/to/file.js';
93  $this->meta_content->addJs($path);
94  $collection = $this->meta_content->getJs();
95 
96  $iterator_to_array = iterator_to_array($collection->getItems());
97  $first_item = $iterator_to_array[$path];
98  $this->assertInstanceOf(Js::class, $first_item);
99  $this->assertSame($path . '?version=' . $this->version, $first_item->getContent());
100  $this->assertSame(2, $first_item->getBatch());
101  }
$path
Definition: ltiservices.php:29

◆ testAddJsFileWithQuery()

ILIAS\GlobalScreen\Scope\Layout\MediaTest::testAddJsFileWithQuery ( )

Definition at line 103 of file MediaTest.php.

References $path.

103  : void
104  {
105  $path = '/path/to/file.js';
106  $path_with_query = $path . '?my=query';
107  $this->meta_content->addJs($path_with_query);
108  $collection = $this->meta_content->getJs();
109 
110  $first_item = iterator_to_array($collection->getItems())[$path];
111  $this->assertInstanceOf(Js::class, $first_item);
112  $this->assertSame($path_with_query . '&version=' . $this->version, $first_item->getContent());
113  $this->assertSame(2, $first_item->getBatch());
114  }
$path
Definition: ltiservices.php:29

Field Documentation

◆ $meta_content

MetaContent ILIAS\GlobalScreen\Scope\Layout\MediaTest::$meta_content

Definition at line 37 of file MediaTest.php.

◆ $version

string ILIAS\GlobalScreen\Scope\Layout\MediaTest::$version

Definition at line 36 of file MediaTest.php.


The documentation for this class was generated from the following file: