19 declare(strict_types=1);
29 require_once __DIR__ .
'/../ContainerMock.php';
37 $this->assertInstanceOf(Confirmation::class,
new Confirmation($this->mock(ilLanguage::class), $this->fail(...)));
43 $language = $this->mock(ilLanguage::class);
44 $language->expects(self::exactly(2))->method(
'txt')->willReturnCallback(
static fn(
string $key):
string =>
'translated ' . $key);
46 $instance =
new Confirmation($language,
static fn() => $confirmation);
47 $this->assertSame(
'rendered string', $instance->render(
'dummy link',
'submit',
'cancel',
'Hi', [
52 $this->assertSame(
'dummy link', $confirmation->link);
53 $this->assertSame(
'submit', $confirmation->submit_command);
54 $this->assertSame(
'cancel', $confirmation->cancel_command);
55 $this->assertSame(
'translated confirm', $confirmation->submit_label);
56 $this->assertSame(
'translated cancel', $confirmation->cancel_label);
57 $this->assertSame(
'Hi', $confirmation->header_text);
58 $this->assertSame([[
'ids[]',
'foo',
'bar'], [
'ids[]',
'7',
'baz']], $confirmation->items);
65 public string $confirm_command;
66 public string $cancel_command;
67 public string $header_text;
68 public array $items = [];
69 public string $cancel_label;
70 public string $submit_label;
71 public string $submit_command;
73 public function setFormAction(
string $link):
void 77 public function setConfirm(
string $label,
string $command):
void 79 $this->submit_label = $label;
80 $this->submit_command = $command;
82 public function setCancel(
string $label,
string $command):
void 84 $this->cancel_label = $label;
85 $this->cancel_command = $command;
87 public function setHeaderText(
string $text):
void 89 $this->header_text = $text;
91 public function addItem(
string $a,
string $b,
string $c):
void 93 $this->items[] = [
$a,
$b,
$c];
95 public function getHTML():
string 97 return 'rendered string';
confirmationGUIReplacement()
link(string $caption, string $href, bool $new_viewport=false)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples