ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Component\Progress\BarTest Class Reference
+ Inheritance diagram for Component\Progress\BarTest:
+ Collaboration diagram for Component\Progress\BarTest:

Public Member Functions

 testRender ()
 
 testRenderWithAsyncUrl ()
 
 getUIFactory ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

I SignalGeneratorInterface $signal_generator
 
I Symbol Glyph Factory $glyph_factory
 
I Symbol Glyph Glyph $glyph_mock
 
string $glyph_html
 
ILIAS Data URI $uri_mock
 
string $uri
 

Detailed Description

Author
Thibeau Fuhrer thibe.nosp@m.au@s.nosp@m.r.sol.nosp@m.utio.nosp@m.ns

Definition at line 31 of file BarTest.php.

Member Function Documentation

◆ getUIFactory()

Component\Progress\BarTest::getUIFactory ( )

Definition at line 105 of file BarTest.php.

106 {
107 $symbol_factory = new I\Symbol\Factory(
108 $this->createMock(I\Symbol\Icon\Factory::class),
109 $this->glyph_factory,
110 $this->createMock(I\Symbol\Avatar\Factory::class),
111 );
112
113 $progress_factory = new I\Progress\Factory(
114 $this->createMock(C\Progress\AsyncRefreshInterval::class),
115 $this->signal_generator,
116 $this->createMock(I\Progress\State\Factory::class),
117 );
118
119 return new class ($progress_factory, $symbol_factory) extends \NoUIFactory {
120 public function __construct(
121 protected I\Progress\Factory $progress_factory,
122 protected I\Symbol\Factory $symbol_factory,
123 ) {
124 }
125 public function progress(): I\Progress\Factory
126 {
127 return $this->progress_factory;
128 }
129 public function symbol(): I\Symbol\Factory
130 {
131 return $this->symbol_factory;
132 }
133 };
134 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\Repository\symbol().

Referenced by Component\Progress\BarTest\testRender(), and Component\Progress\BarTest\testRenderWithAsyncUrl().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setUp()

Component\Progress\BarTest::setUp ( )
protected

Definition at line 40 of file BarTest.php.

40 : void
41 {
42 $this->glyph_html = sha1(C\Symbol\Glyph\Glyph::class);
43
44 $this->glyph_mock = $this->createMock(I\Symbol\Glyph\Glyph::class);
45 $this->glyph_mock->method('getCanonicalName')->willReturn($this->glyph_html);
46
47 $this->glyph_factory = $this->createMock(I\Symbol\Glyph\Factory::class);
48 $this->glyph_factory->method('apply')->willReturn($this->glyph_mock);
49 $this->glyph_factory->method('close')->willReturn($this->glyph_mock);
50
51 $this->uri = sha1('https://example.com?foo=bar&bar=foobar');
52
53 $this->uri_mock = $this->createMock(\ILIAS\Data\URI::class);
54 $this->uri_mock->method('__toString')->willReturn($this->uri);
55
56 $this->signal_generator = new \IncrementalSignalGenerator();
57
58 parent::setUp();
59 }
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

◆ testRender()

Component\Progress\BarTest::testRender ( )

Definition at line 61 of file BarTest.php.

61 : void
62 {
63 $label = sha1('progress_bar_label');
64
65 $progress_bar = $this->getUIFactory()->progress()->bar($label);
66
67 $renderer = $this->getDefaultRenderer(null, [$this->glyph_mock]);
68
69 $actual_html = $renderer->render($progress_bar);
70
71 $expected_html = <<<EOT
72<div class="c-progress c-progress-bar">
73 <div class="c-progress-bar__label"><label for="id_1">$label</label>
74 <span data-status="success" class="c-progress-bar--success hidden">$this->glyph_html</span>
75 <span data-status="failure" class="c-progress-bar--failure hidden">$this->glyph_html</span>
76 </div>
77 <progress id="id_1" class="c-progress-bar__progress" value="0" max="100"></progress>
78 <div class="c-progress-bar__message text-left invisible" aria-live="polite"></div>
79</div>
80EOT;
81
82 $this->assertEquals(
83 $this->brutallyTrimHTML($expected_html),
84 $this->brutallyTrimHTML($actual_html),
85 );
86 }
$renderer

References $renderer, and Component\Progress\BarTest\getUIFactory().

+ Here is the call graph for this function:

◆ testRenderWithAsyncUrl()

Component\Progress\BarTest::testRenderWithAsyncUrl ( )

Definition at line 88 of file BarTest.php.

88 : void
89 {
90 $label = sha1('progress_bar_label');
91
92 $progress_bar = $this->getUIFactory()->progress()->bar($label, $this->uri_mock);
93
94 $renderer = $this->getDefaultRenderer(null, [$this->glyph_mock]);
95
96 $actual_html = $renderer->render($progress_bar);
97
98 $expected_html = "data-url=\"$this->uri\"";
99
100 $this->assertTrue(
101 str_contains($actual_html, $expected_html)
102 );
103 }

References $renderer, and Component\Progress\BarTest\getUIFactory().

+ Here is the call graph for this function:

Field Documentation

◆ $glyph_factory

I Symbol Glyph Factory Component\Progress\BarTest::$glyph_factory
protected

Definition at line 34 of file BarTest.php.

◆ $glyph_html

string Component\Progress\BarTest::$glyph_html
protected

Definition at line 36 of file BarTest.php.

◆ $glyph_mock

I Symbol Glyph Glyph Component\Progress\BarTest::$glyph_mock
protected

Definition at line 35 of file BarTest.php.

◆ $signal_generator

I SignalGeneratorInterface Component\Progress\BarTest::$signal_generator
protected

Definition at line 33 of file BarTest.php.

◆ $uri

string Component\Progress\BarTest::$uri
protected

Definition at line 38 of file BarTest.php.

◆ $uri_mock

ILIAS Data URI Component\Progress\BarTest::$uri_mock
protected

Definition at line 37 of file BarTest.php.


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