Skip to content

Commit 19cd51a

Browse files
Merge branch 'master' into metadata-fix
2 parents a80f32a + 074c9a5 commit 19cd51a

File tree

117 files changed

+1779
-1481
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+1779
-1481
lines changed

.github/auto-comment.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/workflows/dokuwiki.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: DokuWiki Default Tasks
2+
on:
3+
push:
4+
pull_request:
5+
schedule:
6+
- cron: '19 8 25 * *'
7+
8+
9+
jobs:
10+
all:
11+
uses: dokuwiki/github-action/.github/workflows/all.yml@main

.github/workflows/phpCS.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/phpTestLinux.yml

Lines changed: 0 additions & 52 deletions
This file was deleted.

_test/AccessTableDataReplacementTest.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function test_simple()
9393

9494
$search = new meta\SearchConfig($actual_config);
9595
list(, $opts) = $search->getSQL();
96-
$result = $search->execute();
96+
$result = $search->getRows();
9797

9898
$this->assertEquals(['page1', 'page2'], $opts, '$STRUCT.table.col$ should not require table to be selected');
9999
$this->assertEquals('data of page1', $result[0][1]->getValue());
@@ -114,7 +114,7 @@ public function test_emptyfield()
114114
$actual_config = $configParser->getConfig();
115115

116116
$search = new meta\SearchConfig($actual_config);
117-
$result = $search->execute();
117+
$result = $search->getRows();
118118

119119
$this->assertEquals(0, count($result), 'if no pages a given, then none should be shown');
120120
}
@@ -126,30 +126,30 @@ public function dataProvider_DataFiltersAsSubQuery()
126126
[
127127
"filter : data = foo"
128128
],
129-
"AND ((data_bar.col1 != '' AND data_bar.col1 = ?))",
129+
"AND (data_bar.col1 = ?)",
130130
"The WHERE-clauses from page-syntax should be wrapped in parentheses"
131131
],
132132
[
133133
[
134134
"OR : data = foo"
135135
],
136-
"AND ((data_bar.col1 != '' AND data_bar.col1 = ?))",
136+
"AND (data_bar.col1 = ?)",
137137
"A single OR clause should be treated as AND clauses"
138138
],
139139
[
140140
[
141141
"filter : data = foo",
142142
"OR : data = bar"
143143
],
144-
"AND ((data_bar.col1 != '' AND data_bar.col1 = ?) OR (data_bar.col1 != '' AND data_bar.col1 = ?))",
144+
"AND (data_bar.col1 = ? OR data_bar.col1 = ?)",
145145
"The WHERE-clauses from page-syntax should be wrapped in parentheses"
146146
],
147147
[
148148
[
149149
"OR : data = bar",
150150
"filter : data = foo"
151151
],
152-
"AND ((data_bar.col1 != '' AND data_bar.col1 = ?) AND (data_bar.col1 != '' AND data_bar.col1 = ?))",
152+
"AND (data_bar.col1 = ? AND data_bar.col1 = ?)",
153153
"A single OR clause should be treated as AND clauses"
154154
]
155155
];
@@ -182,7 +182,10 @@ public function test_DataFiltersAsSubQuery($inputFilterLines, $expectedFilterWhe
182182
data_bar.pid = '' OR (
183183
GETACCESSLEVEL(data_bar.pid) > 0
184184
AND PAGEEXISTS(data_bar.pid) = 1
185-
AND (ASSIGNED = 1 OR ASSIGNED IS NULL)
185+
AND (
186+
data_bar.rid != 0
187+
OR (ASSIGNED = 1 OR ASSIGNED IS NULL)
188+
)
186189
)
187190
)
188191
AND (

_test/AggregationFilterTest.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
namespace dokuwiki\plugin\struct\test;
44

5-
5+
/**
6+
* Testing aggregation filter
7+
*
8+
* @group plugin_struct
9+
* @group plugins
10+
*/
611
class AggregationFilterTest extends StructTest
712
{
813
protected $items = [
@@ -38,7 +43,7 @@ public function testGetAllColumnValues()
3843
'red' => 'red',
3944
'yellow' => 'yellow'
4045
],
41-
$values[0]['values']
46+
$this->trimKeys($values[0]['values'])
4247
);
4348

4449
$this->assertEquals(
@@ -51,12 +56,23 @@ public function testGetAllColumnValues()
5156
'car' => 'car',
5257
'laptop' => 'laptop'
5358
],
54-
$values[1]['values']
59+
$this->trimKeys($values[1]['values'])
5560
);
5661

5762
$this->assertEquals(
5863
'Label 2',
5964
$values[1]['label']
6065
);
6166
}
67+
68+
/**
69+
* Reverses key padding workaround in AggregationFilter::getAllColumnValues()
70+
*
71+
* @param array $values
72+
* @return int[]|string[]
73+
*/
74+
protected function trimKeys($values)
75+
{
76+
return array_flip(array_map(static fn($val) => trim($val), array_flip($values)));
77+
}
6278
}

_test/AggregationResultsTest.php

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
use dokuwiki\plugin\struct\meta\ConfigParser;
77
use dokuwiki\plugin\struct\meta\PageMeta;
88
use dokuwiki\plugin\struct\test\mock\AccessTable as MockAccessTableAlias;
9-
use dokuwiki\plugin\struct\test\mock\AggregationEditorTable as MockAggregationEditorTableAlias;
10-
use dokuwiki\plugin\struct\test\mock\AggregationTable as MockAggregationTableAlias;
119
use dokuwiki\plugin\struct\test\mock\SearchConfig as MockSearchConfigAlias;
1210

1311
/**
@@ -53,8 +51,10 @@ public function setUp(): void
5351
'third' => "foobar$i",
5452
'fourth' => "barfoo$i",
5553
];
56-
$access = MockAccessTableAlias::getSerialAccess('schema1', "test$i");
57-
$access->saveData($data);
54+
$accessSerial = MockAccessTableAlias::getSerialAccess('schema1', "test$i");
55+
$accessSerial->saveData($data);
56+
$accessPage = MockAccessTableAlias::getPageAccess('schema1', "test$i");
57+
$accessPage->saveData($data);
5858
}
5959
}
6060

@@ -66,7 +66,7 @@ public function test_pid()
6666
// \syntax_plugin_struct_serial accesses the global $ID
6767
$id = 'test1';
6868
$schema = 'schema1';
69-
$result = $this->fetchResult($schema, $id);
69+
$result = $this->fetchNonPageResults($schema, $id);
7070

7171
$this->assertCount(1, $result);
7272
$this->assertEquals('test1', $result[0][0]->getValue());
@@ -83,30 +83,30 @@ public function test_pid()
8383
public function test_filter_text()
8484
{
8585
$schema = 'schema1';
86-
$result = $this->fetchResult($schema, 'test0');
86+
$result = $this->fetchNonPageResults($schema, 'test0');
8787
$this->assertCount(1, $result);
8888

89-
$result = $this->fetchResult($schema, 'test0', ['first', '=', 'foo0', 'AND']);
89+
$result = $this->fetchNonPageResults($schema, 'test0', ['first', '=', 'foo0', 'AND']);
9090
$this->assertCount(1, $result);
9191

92-
$result = $this->fetchResult($schema, 'test0', ['first', '!=', 'foo0', 'AND']);
92+
$result = $this->fetchNonPageResults($schema, 'test0', ['first', '!=', 'foo0', 'AND']);
9393
$this->assertCount(0, $result);
9494
}
9595

9696
/** @noinspection PhpUnreachableStatementInspection */
9797
public function test_filter_multi()
9898
{
9999
$schema = 'schema1';
100-
$result = $this->fetchPagesResult($schema, '');
101-
$this->assertCount(3, $result);
100+
$result = $this->fetchAllResults($schema, '');
101+
$this->assertCount(6, $result);
102102

103-
$result = $this->fetchPagesResult($schema, '', ['second', '=', 'green', 'AND']);
104-
$this->assertCount(2, $result);
103+
$result = $this->fetchAllResults($schema, '', ['second', '=', 'green', 'AND']);
104+
$this->assertCount(4, $result);
105105

106106
$this->markTestIncomplete('negative filters currently do not work on multi fields. See #512');
107107

108-
$result = $this->fetchPagesResult($schema, '', ['second', '!~', 'green', 'AND']);
109-
$this->assertCount(1, $result);
108+
$result = $this->fetchAllResults($schema, '', ['second', '!~', 'green', 'AND']);
109+
$this->assertCount(2, $result);
110110
}
111111

112112
/**
@@ -116,15 +116,15 @@ public function test_filter_page()
116116
{
117117
$this->prepareLookup();
118118
$schema = 'pageschema';
119-
$result = $this->fetchResult($schema);
119+
$result = $this->fetchNonPageResults($schema);
120120
$this->assertCount(3, $result);
121121

122122
// 'usetitles' = true
123-
$result = $this->fetchResult($schema, '', ['singletitle', '*~', 'another', 'AND']);
123+
$result = $this->fetchNonPageResults($schema, '', ['singletitle', '*~', 'another', 'AND']);
124124
$this->assertCount(1, $result);
125125

126126
// 'usetitles' = false
127-
$result = $this->fetchResult($schema, '', ['singlepage', '*~', 'this', 'AND']);
127+
$result = $this->fetchNonPageResults($schema, '', ['singlepage', '*~', 'this', 'AND']);
128128
$this->assertCount(0, $result);
129129
}
130130

@@ -135,13 +135,13 @@ public function test_filter_datetime()
135135
{
136136
$this->prepareDatetime();
137137
$schema = 'datetime';
138-
$result = $this->fetchResult($schema);
138+
$result = $this->fetchNonPageResults($schema);
139139
$this->assertCount(3, $result);
140140

141-
$result = $this->fetchResult($schema, '', ['field', '<', '2023-01-02', 'AND']);
141+
$result = $this->fetchNonPageResults($schema, '', ['field', '<', '2023-01-02', 'AND']);
142142
$this->assertCount(1, $result);
143143

144-
$result = $this->fetchResult($schema, '', ['field', '<', '2023-01-01 11:00', 'AND']);
144+
$result = $this->fetchNonPageResults($schema, '', ['field', '<', '2023-01-01 11:00', 'AND']);
145145
$this->assertCount(0, $result);
146146
}
147147

@@ -150,27 +150,27 @@ public function test_filter_datetime()
150150
*/
151151
public function test_assignments()
152152
{
153-
$result = $this->fetchPagesResult('schema1');
154-
$this->assertCount(3, $result);
153+
$result = $this->fetchAllResults('schema1');
154+
$this->assertCount(6, $result);
155155

156156
// revoke assignment
157157
$assignments = mock\Assignments::getInstance();
158158
$assignments->deassignPageSchema('test0', 'schema1');
159159

160-
$result = $this->fetchPagesResult('schema1');
161-
$this->assertCount(2, $result);
160+
$result = $this->fetchAllResults('schema1');
161+
$this->assertCount(5, $result);
162162
}
163163

164164

165165
/**
166-
* Initialize a lookup table from syntax and return the result from its internal search.
166+
* Initialize a table from syntax and return the result from its internal search.
167167
*
168168
* @param string $schema
169169
* @param string $id
170170
* @param array $filters
171171
* @return \dokuwiki\plugin\struct\meta\Value[][]
172172
*/
173-
protected function fetchPagesResult($schema, $id = '', $filters = [])
173+
protected function fetchAllResults($schema, $id = '', $filters = [])
174174
{
175175
$syntaxConfig = ['schema: ' . $schema, 'cols: %pageid%, %rowid%, *'];
176176
$configParser = new ConfigParser($syntaxConfig);
@@ -179,8 +179,7 @@ protected function fetchPagesResult($schema, $id = '', $filters = [])
179179
if ($filters) $config['filter'][] = $filters;
180180
$search = new MockSearchConfigAlias($config);
181181

182-
$table = new MockAggregationTableAlias($id, 'xhtml', new \Doku_Renderer_xhtml(), $search);
183-
return $table->getResult();
182+
return $search->getRows();
184183
}
185184

186185
/**
@@ -191,13 +190,13 @@ protected function fetchPagesResult($schema, $id = '', $filters = [])
191190
* @param array $filters
192191
* @return \dokuwiki\plugin\struct\meta\Value[][]
193192
*/
194-
protected function fetchResult($schema, $id = '', $filters = [])
193+
protected function fetchNonPageResults($schema, $id = '', $filters = [])
195194
{
196195
$syntaxConfig = ['schema: ' . $schema, 'cols: %pageid%, %rowid%, *'];
197196
$configParser = new ConfigParser($syntaxConfig);
198197
$config = $configParser->getConfig();
199198

200-
// FIXME simulate addYypeFilter() from \syntax_plugin_struct_serial or \syntax_plugin_struct_lookup
199+
// simulate addYypeFilter() from \syntax_plugin_struct_serial and \syntax_plugin_struct_lookup
201200
if ($id) {
202201
$config['filter'][] = ['%rowid%', '!=', (string)AccessTablePage::DEFAULT_PAGE_RID, 'AND'];
203202
$config['filter'][] = ['%pageid%', '=', $id, 'AND'];
@@ -209,8 +208,7 @@ protected function fetchResult($schema, $id = '', $filters = [])
209208
if ($filters) $config['filter'][] = $filters;
210209
$search = new MockSearchConfigAlias($config);
211210

212-
$table = new MockAggregationEditorTableAlias($id, 'xhtml', new \Doku_Renderer_xhtml(), $search);
213-
return $table->getResult();
211+
return $search->getRows();
214212
}
215213

216214
protected function prepareLookup()

0 commit comments

Comments
 (0)