@@ -53,8 +53,10 @@ public function setUp(): void
53
53
'third ' => "foobar $ i " ,
54
54
'fourth ' => "barfoo $ i " ,
55
55
];
56
- $ access = MockAccessTableAlias::getSerialAccess ('schema1 ' , "test $ i " );
57
- $ access ->saveData ($ data );
56
+ $ accessSerial = MockAccessTableAlias::getSerialAccess ('schema1 ' , "test $ i " );
57
+ $ accessSerial ->saveData ($ data );
58
+ $ accessPage = MockAccessTableAlias::getPageAccess ('schema1 ' , "test $ i " );
59
+ $ accessPage ->saveData ($ data );
58
60
}
59
61
}
60
62
@@ -66,7 +68,7 @@ public function test_pid()
66
68
// \syntax_plugin_struct_serial accesses the global $ID
67
69
$ id = 'test1 ' ;
68
70
$ schema = 'schema1 ' ;
69
- $ result = $ this ->fetchResult ($ schema , $ id );
71
+ $ result = $ this ->fetchNonPageResults ($ schema , $ id );
70
72
71
73
$ this ->assertCount (1 , $ result );
72
74
$ this ->assertEquals ('test1 ' , $ result [0 ][0 ]->getValue ());
@@ -83,30 +85,30 @@ public function test_pid()
83
85
public function test_filter_text ()
84
86
{
85
87
$ schema = 'schema1 ' ;
86
- $ result = $ this ->fetchResult ($ schema , 'test0 ' );
88
+ $ result = $ this ->fetchNonPageResults ($ schema , 'test0 ' );
87
89
$ this ->assertCount (1 , $ result );
88
90
89
- $ result = $ this ->fetchResult ($ schema , 'test0 ' , ['first ' , '= ' , 'foo0 ' , 'AND ' ]);
91
+ $ result = $ this ->fetchNonPageResults ($ schema , 'test0 ' , ['first ' , '= ' , 'foo0 ' , 'AND ' ]);
90
92
$ this ->assertCount (1 , $ result );
91
93
92
- $ result = $ this ->fetchResult ($ schema , 'test0 ' , ['first ' , '!= ' , 'foo0 ' , 'AND ' ]);
94
+ $ result = $ this ->fetchNonPageResults ($ schema , 'test0 ' , ['first ' , '!= ' , 'foo0 ' , 'AND ' ]);
93
95
$ this ->assertCount (0 , $ result );
94
96
}
95
97
96
98
/** @noinspection PhpUnreachableStatementInspection */
97
99
public function test_filter_multi ()
98
100
{
99
101
$ schema = 'schema1 ' ;
100
- $ result = $ this ->fetchPagesResult ($ schema , '' );
101
- $ this ->assertCount (3 , $ result );
102
+ $ result = $ this ->fetchAllResults ($ schema , '' );
103
+ $ this ->assertCount (6 , $ result );
102
104
103
- $ result = $ this ->fetchPagesResult ($ schema , '' , ['second ' , '= ' , 'green ' , 'AND ' ]);
104
- $ this ->assertCount (2 , $ result );
105
+ $ result = $ this ->fetchAllResults ($ schema , '' , ['second ' , '= ' , 'green ' , 'AND ' ]);
106
+ $ this ->assertCount (4 , $ result );
105
107
106
108
$ this ->markTestIncomplete ('negative filters currently do not work on multi fields. See #512 ' );
107
109
108
- $ result = $ this ->fetchPagesResult ($ schema , '' , ['second ' , '!~ ' , 'green ' , 'AND ' ]);
109
- $ this ->assertCount (1 , $ result );
110
+ $ result = $ this ->fetchAllResults ($ schema , '' , ['second ' , '!~ ' , 'green ' , 'AND ' ]);
111
+ $ this ->assertCount (2 , $ result );
110
112
}
111
113
112
114
/**
@@ -116,15 +118,15 @@ public function test_filter_page()
116
118
{
117
119
$ this ->prepareLookup ();
118
120
$ schema = 'pageschema ' ;
119
- $ result = $ this ->fetchResult ($ schema );
121
+ $ result = $ this ->fetchNonPageResults ($ schema );
120
122
$ this ->assertCount (3 , $ result );
121
123
122
124
// 'usetitles' = true
123
- $ result = $ this ->fetchResult ($ schema , '' , ['singletitle ' , '*~ ' , 'another ' , 'AND ' ]);
125
+ $ result = $ this ->fetchNonPageResults ($ schema , '' , ['singletitle ' , '*~ ' , 'another ' , 'AND ' ]);
124
126
$ this ->assertCount (1 , $ result );
125
127
126
128
// 'usetitles' = false
127
- $ result = $ this ->fetchResult ($ schema , '' , ['singlepage ' , '*~ ' , 'this ' , 'AND ' ]);
129
+ $ result = $ this ->fetchNonPageResults ($ schema , '' , ['singlepage ' , '*~ ' , 'this ' , 'AND ' ]);
128
130
$ this ->assertCount (0 , $ result );
129
131
}
130
132
@@ -135,13 +137,13 @@ public function test_filter_datetime()
135
137
{
136
138
$ this ->prepareDatetime ();
137
139
$ schema = 'datetime ' ;
138
- $ result = $ this ->fetchResult ($ schema );
140
+ $ result = $ this ->fetchNonPageResults ($ schema );
139
141
$ this ->assertCount (3 , $ result );
140
142
141
- $ result = $ this ->fetchResult ($ schema , '' , ['field ' , '< ' , '2023-01-02 ' , 'AND ' ]);
143
+ $ result = $ this ->fetchNonPageResults ($ schema , '' , ['field ' , '< ' , '2023-01-02 ' , 'AND ' ]);
142
144
$ this ->assertCount (1 , $ result );
143
145
144
- $ result = $ this ->fetchResult ($ schema , '' , ['field ' , '< ' , '2023-01-01 11:00 ' , 'AND ' ]);
146
+ $ result = $ this ->fetchNonPageResults ($ schema , '' , ['field ' , '< ' , '2023-01-01 11:00 ' , 'AND ' ]);
145
147
$ this ->assertCount (0 , $ result );
146
148
}
147
149
@@ -150,27 +152,27 @@ public function test_filter_datetime()
150
152
*/
151
153
public function test_assignments ()
152
154
{
153
- $ result = $ this ->fetchPagesResult ('schema1 ' );
154
- $ this ->assertCount (3 , $ result );
155
+ $ result = $ this ->fetchAllResults ('schema1 ' );
156
+ $ this ->assertCount (6 , $ result );
155
157
156
158
// revoke assignment
157
159
$ assignments = mock \Assignments::getInstance ();
158
160
$ assignments ->deassignPageSchema ('test0 ' , 'schema1 ' );
159
161
160
- $ result = $ this ->fetchPagesResult ('schema1 ' );
161
- $ this ->assertCount (2 , $ result );
162
+ $ result = $ this ->fetchAllResults ('schema1 ' );
163
+ $ this ->assertCount (5 , $ result );
162
164
}
163
165
164
166
165
167
/**
166
- * Initialize a lookup table from syntax and return the result from its internal search.
168
+ * Initialize a table from syntax and return the result from its internal search.
167
169
*
168
170
* @param string $schema
169
171
* @param string $id
170
172
* @param array $filters
171
173
* @return \dokuwiki\plugin\struct\meta\Value[][]
172
174
*/
173
- protected function fetchPagesResult ($ schema , $ id = '' , $ filters = [])
175
+ protected function fetchAllResults ($ schema , $ id = '' , $ filters = [])
174
176
{
175
177
$ syntaxConfig = ['schema: ' . $ schema , 'cols: %pageid%, %rowid%, * ' ];
176
178
$ configParser = new ConfigParser ($ syntaxConfig );
@@ -191,13 +193,13 @@ protected function fetchPagesResult($schema, $id = '', $filters = [])
191
193
* @param array $filters
192
194
* @return \dokuwiki\plugin\struct\meta\Value[][]
193
195
*/
194
- protected function fetchResult ($ schema , $ id = '' , $ filters = [])
196
+ protected function fetchNonPageResults ($ schema , $ id = '' , $ filters = [])
195
197
{
196
198
$ syntaxConfig = ['schema: ' . $ schema , 'cols: %pageid%, %rowid%, * ' ];
197
199
$ configParser = new ConfigParser ($ syntaxConfig );
198
200
$ config = $ configParser ->getConfig ();
199
201
200
- // FIXME simulate addYypeFilter() from \syntax_plugin_struct_serial or \syntax_plugin_struct_lookup
202
+ // simulate addYypeFilter() from \syntax_plugin_struct_serial and \syntax_plugin_struct_lookup
201
203
if ($ id ) {
202
204
$ config ['filter ' ][] = ['%rowid% ' , '!= ' , (string )AccessTablePage::DEFAULT_PAGE_RID , 'AND ' ];
203
205
$ config ['filter ' ][] = ['%pageid% ' , '= ' , $ id , 'AND ' ];
0 commit comments