19 declare(strict_types=1);
40 require_once __DIR__ .
'/../ContainerMock.php';
48 $this->assertInstanceOf(HistoryTable::class,
new HistoryTable(
49 $this->mock(HistoryRepository::class),
50 $this->mock(ProvideDocument::class),
53 $this->mock(UI::class),
54 $this->mock(DocumentModal::class),
61 $ui = $this->mock(UI::class);
62 $ui->expects(self::exactly(6))->method(
'txt')->willReturnCallback(fn(
$key) =>
'txt: ' .
$key);
65 $this->mock(HistoryRepository::class),
66 $this->mock(ProvideDocument::class),
70 $this->mock(DocumentModal::class),
75 'created' => [
'txt: tbl_hist_head_acceptance_date',
'created'],
76 'login' => [
'txt: tbl_hist_head_login',
'login'],
77 'firstname' => [
'txt: tbl_hist_head_firstname',
'firstname'],
78 'lastname' => [
'txt: tbl_hist_head_lastname',
'lastname'],
79 'document' => [
'txt: tbl_hist_head_document',
'document'],
80 'criteria' => [
'txt: tbl_hist_head_criteria'],
81 ], $instance->columns());
86 class_exists(ilDateTime::class,
true);
87 $filter = $this->mock(TableFilter::class);
88 $filter->expects(self::exactly(2))->method(
'addFilterItem');
90 $config = $this->mock(TableConfig::class);
91 $config->expects(self::once())->method(
'setTitle')->with(
'txt: acceptance_history');
92 $config->expects(self::once())->method(
'setDefaultOrderField')->with(
'created');
93 $config->expects(self::once())->method(
'setDefaultOrderDirection')->with(
'DESC');
94 $config->expects(self::once())->method(
'setSelectableColumns')->with(
'firstname',
'lastname',
'criteria');
95 $config->expects(self::once())->method(
'asFilter')->with(
'reset command')->willReturn($filter);
97 $ui = $this->mock(UI::class);
98 $ui->method(
'txt')->willReturnCallback(fn(
$key) =>
'txt: ' .
$key);
101 $this->mock(HistoryRepository::class),
102 $this->mock(ProvideDocument::class),
104 'auto-complete-link',
106 $this->mock(DocumentModal::class),
110 $instance->config($config);
115 $expected_filter = [
'a' =>
'b',
'start' =>
'x',
'end' =>
'y',
'c' =>
'd'];
116 $repository = $this->mock(HistoryRepository::class);
117 $repository->expects(self::once())->method(
'countAll')->with($expected_filter)->willReturn(2);
118 $repository->expects(self::once())->method(
'all')->with(
124 $this->mock(History::class),
125 $this->mock(History::class),
128 $selection = $this->mockTree(TableSelection::class, [
129 'filter' => [
'a' =>
'b',
'period' => [
'start' =>
'x',
'end' =>
'y'] ,
'c' =>
'd'],
130 'getOrderField' =>
'foo',
131 'getOrderDirection' =>
'bar',
135 $selection->expects(self::once())->method(
'setMaxCount')->with(2);
139 $this->mock(ProvideDocument::class),
141 'auto-complete-link',
142 $this->mock(UI::class),
143 $this->mock(DocumentModal::class),
149 'created' =>
'formated',
156 'created' =>
'formated',
162 ]], $instance->rows($selection));
168 $this->mock(HistoryRepository::class),
169 $this->mock(ProvideDocument::class),
171 'auto-complete-link',
172 $this->mock(UI::class),
173 $this->mock(DocumentModal::class),
177 $this->assertSame(HistoryTable::class, $instance->name());