66use dokuwiki \plugin \struct \meta \ConfigParser ;
77use dokuwiki \plugin \struct \meta \PageMeta ;
88use 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 ;
119use 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