19 declare(strict_types=1);
37 require_once __DIR__ .
'/../ContainerMock.php';
45 $this->assertInstanceOf(HistoryTable::class,
new HistoryTable(
46 $this->mock(HistoryRepository::class),
47 $this->mock(ProvideDocument::class),
50 $this->mock(UI::class),
51 $this->mock(DocumentModal::class),
58 $ui = $this->mock(UI::class);
59 $ui->expects(self::exactly(6))->method(
'txt')->willReturnCallback(fn($key) =>
'txt: ' . $key);
62 $this->mock(HistoryRepository::class),
63 $this->mock(ProvideDocument::class),
67 $this->mock(DocumentModal::class),
72 'created' => [
'txt: tbl_hist_head_acceptance_date',
'created'],
73 'login' => [
'txt: tbl_hist_head_login',
'login'],
74 'firstname' => [
'txt: tbl_hist_head_firstname',
'firstname'],
75 'lastname' => [
'txt: tbl_hist_head_lastname',
'lastname'],
76 'document' => [
'txt: tbl_hist_head_document',
'document'],
77 'criteria' => [
'txt: tbl_hist_head_criteria'],
78 ], $instance->columns());
83 class_exists(ilDateTime::class,
true);
84 $filter = $this->mock(TableFilter::class);
85 $filter->expects(self::exactly(2))->method(
'addFilterItem');
87 $config = $this->mock(TableConfig::class);
88 $config->expects(self::once())->method(
'setTitle')->with(
'txt: acceptance_history');
89 $config->expects(self::once())->method(
'setDefaultOrderField')->with(
'created');
90 $config->expects(self::once())->method(
'setDefaultOrderDirection')->with(
'DESC');
91 $config->expects(self::once())->method(
'setSelectableColumns')->with(
'firstname',
'lastname',
'criteria');
92 $config->expects(self::once())->method(
'asFilter')->with(
'reset command')->willReturn($filter);
94 $ui = $this->mock(UI::class);
95 $ui->method(
'txt')->willReturnCallback(fn($key) =>
'txt: ' . $key);
98 $this->mock(HistoryRepository::class),
99 $this->mock(ProvideDocument::class),
101 'auto-complete-link',
103 $this->mock(DocumentModal::class),
107 $instance->config($config);
112 $expected_filter = [
'a' =>
'b',
'start' =>
'x',
'end' =>
'y',
'c' =>
'd'];
113 $repository = $this->mock(HistoryRepository::class);
114 $repository->expects(self::once())->method(
'countAll')->with($expected_filter)->willReturn(2);
115 $repository->expects(self::once())->method(
'all')->with(
121 $this->mock(History::class),
122 $this->mock(History::class),
125 $selection = $this->mockTree(TableSelection::class, [
126 'filter' => [
'a' =>
'b',
'period' => [
'start' =>
'x',
'end' =>
'y'] ,
'c' =>
'd'],
127 'getOrderField' =>
'foo',
128 'getOrderDirection' =>
'bar',
132 $selection->expects(self::once())->method(
'setMaxCount')->with(2);
136 $this->mock(ProvideDocument::class),
138 'auto-complete-link',
139 $this->mock(UI::class),
140 $this->mock(DocumentModal::class),
146 'created' =>
'formated',
153 'created' =>
'formated',
159 ]], $instance->rows($selection));
165 $this->mock(HistoryRepository::class),
166 $this->mock(ProvideDocument::class),
168 'auto-complete-link',
169 $this->mock(UI::class),
170 $this->mock(DocumentModal::class),
174 $this->assertSame(HistoryTable::class, $instance->name());