18 declare(strict_types=1);
22 require_once(__DIR__ .
"/../../Base.php");
38 protected function setUp(): void
40 $this->indeterminate_status_value = I\Progress\State\Bar\Status::INDETERMINATE->value;
41 $this->determinate_status_value = I\Progress\State\Bar\Status::DETERMINATE->value;
42 $this->success_status_value = I\Progress\State\Bar\Status::SUCCESS->value;
44 $this->message = sha1(
'progress_bar_state_message');
49 public function testIndeterminateConstruction():
void 52 $indeterminate = $this->
getUIFactory()->progress()->state()->bar()->indeterminate($this->message);
55 $this->assertNull($indeterminate->getVisualProgressValue());
59 public function testDeterminateConstruction():
void 63 $determinate = $this->
getUIFactory()->progress()->state()->bar()->determinate($progress, $this->message);
66 $this->assertEquals($determinate->getVisualProgressValue(), $progress);
72 $invalid_progress = -1;
73 $this->expectException(\InvalidArgumentException::class);
74 $determinate = $this->
getUIFactory()->progress()->state()->bar()->determinate($invalid_progress);
79 $invalid_progress = 100;
80 $this->expectException(\InvalidArgumentException::class);
81 $determinate = $this->
getUIFactory()->progress()->state()->bar()->determinate($invalid_progress);
84 public function testSuccessConstruction():
void 87 $success = $this->
getUIFactory()->progress()->state()->bar()->success($this->message);
90 $this->assertEquals($success->getVisualProgressValue(), I\Progress\Bar::MAX_VALUE);
94 public function testFailureConstruction():
void 97 $failure = $this->
getUIFactory()->progress()->state()->bar()->failure($this->message);
100 $this->assertEquals($failure->getVisualProgressValue(), I\Progress\Bar::MAX_VALUE);
106 $state = $this->
getUIFactory()->progress()->state()->bar()->indeterminate($this->message);
110 $actual_html =
$renderer->render($state);
112 $expected_html = <<<EOT
113 <div
class=
"c-progress c-progress-bar--state">
114 <section data-section=
"progress"><progress max=
"100"></progress></section>
115 <section data-section=
"status" data-status=
"$this->indeterminate_status_value"></section>
116 <section data-section=
"message">$this->message</section>
121 $this->brutallyTrimHTML($expected_html),
122 $this->brutallyTrimHTML($actual_html),
129 $state = $this->
getUIFactory()->progress()->state()->bar()->determinate($progress, $this->message);
133 $actual_html =
$renderer->render($state);
135 $expected_html = <<<EOT
136 <div
class=
"c-progress c-progress-bar--state">
137 <section data-section=
"progress"><progress value=
"$progress" max=
"100"></progress></section>
138 <section data-section=
"status" data-status=
"$this->determinate_status_value"></section>
139 <section data-section=
"message">$this->message</section>
144 $this->brutallyTrimHTML($expected_html),
145 $this->brutallyTrimHTML($actual_html),
151 $state = $this->
getUIFactory()->progress()->state()->bar()->success($this->message);
155 $actual_html =
$renderer->render($state);
157 $expected_html = <<<EOT
158 <div
class=
"c-progress c-progress-bar--state">
159 <section data-section=
"progress"><progress value=
"100" max=
"100"></progress></section>
160 <section data-section=
"status" data-status=
"$this->success_status_value"></section>
161 <section data-section=
"message">$this->message</section>
166 $this->brutallyTrimHTML($expected_html),
167 $this->brutallyTrimHTML($actual_html),
173 $state = $this->
getUIFactory()->progress()->state()->bar()->failure($this->message);
177 $actual_html =
$renderer->render($state);
179 $expected_html = <<<EOT
180 <div
class=
"c-progress c-progress-bar--state">
181 <section data-section=
"progress"><progress value=
"100" max=
"100"></progress></section>
182 <section data-section=
"status" data-status=
"$this->failure_status_value"></section>
183 <section data-section=
"message">$this->message</section>
188 $this->brutallyTrimHTML($expected_html),
189 $this->brutallyTrimHTML($actual_html),
195 $bar_state_factory =
new I\Progress\State\Bar\Factory();
197 $state_factory = $this->createMock(
C\Progress\State\Factory::class);
198 $state_factory->method(
'bar')->willReturn($bar_state_factory);
200 $progress_factory = $this->createMock(
C\Progress\Factory::class);
201 $progress_factory->method(
'state')->willReturn($state_factory);
203 return new class ($progress_factory) extends \
NoUIFactory {
205 protected C\Progress\Factory $progress_factory,
208 public function progress(): C\Progress\Factory
210 return $this->progress_factory;
testRenderIndeterminate()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testDeterminateConstructionWithNegativeNumber()
string $indeterminate_status_value
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
string $failure_status_value
string $determinate_status_value
The progress of the process/task cannot be calculated (yet), but it has started processing.
Provides common functionality for UI tests.
string $success_status_value
testDeterminateConstructionWithMaximumValue()
__construct(Container $dic, ilPlugin $plugin)