@@ -53,8 +53,10 @@ public function setUp(): void
5353 'third ' => "foobar $ i " ,
5454 'fourth ' => "barfoo $ i " ,
5555 ];
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 );
5860 }
5961 }
6062
@@ -66,7 +68,7 @@ public function test_pid()
6668 // \syntax_plugin_struct_serial accesses the global $ID
6769 $ id = 'test1 ' ;
6870 $ schema = 'schema1 ' ;
69- $ result = $ this ->fetchResult ($ schema , $ id );
71+ $ result = $ this ->fetchNonPageResults ($ schema , $ id );
7072
7173 $ this ->assertCount (1 , $ result );
7274 $ this ->assertEquals ('test1 ' , $ result [0 ][0 ]->getValue ());
@@ -83,30 +85,30 @@ public function test_pid()
8385 public function test_filter_text ()
8486 {
8587 $ schema = 'schema1 ' ;
86- $ result = $ this ->fetchResult ($ schema , 'test0 ' );
88+ $ result = $ this ->fetchNonPageResults ($ schema , 'test0 ' );
8789 $ this ->assertCount (1 , $ result );
8890
89- $ result = $ this ->fetchResult ($ schema , 'test0 ' , ['first ' , '= ' , 'foo0 ' , 'AND ' ]);
91+ $ result = $ this ->fetchNonPageResults ($ schema , 'test0 ' , ['first ' , '= ' , 'foo0 ' , 'AND ' ]);
9092 $ this ->assertCount (1 , $ result );
9193
92- $ result = $ this ->fetchResult ($ schema , 'test0 ' , ['first ' , '!= ' , 'foo0 ' , 'AND ' ]);
94+ $ result = $ this ->fetchNonPageResults ($ schema , 'test0 ' , ['first ' , '!= ' , 'foo0 ' , 'AND ' ]);
9395 $ this ->assertCount (0 , $ result );
9496 }
9597
9698 /** @noinspection PhpUnreachableStatementInspection */
9799 public function test_filter_multi ()
98100 {
99101 $ schema = 'schema1 ' ;
100- $ result = $ this ->fetchPagesResult ($ schema , '' );
101- $ this ->assertCount (3 , $ result );
102+ $ result = $ this ->fetchAllResults ($ schema , '' );
103+ $ this ->assertCount (6 , $ result );
102104
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 );
105107
106108 $ this ->markTestIncomplete ('negative filters currently do not work on multi fields. See #512 ' );
107109
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 );
110112 }
111113
112114 /**
@@ -116,15 +118,15 @@ public function test_filter_page()
116118 {
117119 $ this ->prepareLookup ();
118120 $ schema = 'pageschema ' ;
119- $ result = $ this ->fetchResult ($ schema );
121+ $ result = $ this ->fetchNonPageResults ($ schema );
120122 $ this ->assertCount (3 , $ result );
121123
122124 // 'usetitles' = true
123- $ result = $ this ->fetchResult ($ schema , '' , ['singletitle ' , '*~ ' , 'another ' , 'AND ' ]);
125+ $ result = $ this ->fetchNonPageResults ($ schema , '' , ['singletitle ' , '*~ ' , 'another ' , 'AND ' ]);
124126 $ this ->assertCount (1 , $ result );
125127
126128 // 'usetitles' = false
127- $ result = $ this ->fetchResult ($ schema , '' , ['singlepage ' , '*~ ' , 'this ' , 'AND ' ]);
129+ $ result = $ this ->fetchNonPageResults ($ schema , '' , ['singlepage ' , '*~ ' , 'this ' , 'AND ' ]);
128130 $ this ->assertCount (0 , $ result );
129131 }
130132
@@ -135,13 +137,13 @@ public function test_filter_datetime()
135137 {
136138 $ this ->prepareDatetime ();
137139 $ schema = 'datetime ' ;
138- $ result = $ this ->fetchResult ($ schema );
140+ $ result = $ this ->fetchNonPageResults ($ schema );
139141 $ this ->assertCount (3 , $ result );
140142
141- $ result = $ this ->fetchResult ($ schema , '' , ['field ' , '< ' , '2023-01-02 ' , 'AND ' ]);
143+ $ result = $ this ->fetchNonPageResults ($ schema , '' , ['field ' , '< ' , '2023-01-02 ' , 'AND ' ]);
142144 $ this ->assertCount (1 , $ result );
143145
144- $ result = $ this ->fetchResult ($ schema , '' , ['field ' , '< ' , '2023-01-01 11:00 ' , 'AND ' ]);
146+ $ result = $ this ->fetchNonPageResults ($ schema , '' , ['field ' , '< ' , '2023-01-01 11:00 ' , 'AND ' ]);
145147 $ this ->assertCount (0 , $ result );
146148 }
147149
@@ -150,27 +152,27 @@ public function test_filter_datetime()
150152 */
151153 public function test_assignments ()
152154 {
153- $ result = $ this ->fetchPagesResult ('schema1 ' );
154- $ this ->assertCount (3 , $ result );
155+ $ result = $ this ->fetchAllResults ('schema1 ' );
156+ $ this ->assertCount (6 , $ result );
155157
156158 // revoke assignment
157159 $ assignments = mock \Assignments::getInstance ();
158160 $ assignments ->deassignPageSchema ('test0 ' , 'schema1 ' );
159161
160- $ result = $ this ->fetchPagesResult ('schema1 ' );
161- $ this ->assertCount (2 , $ result );
162+ $ result = $ this ->fetchAllResults ('schema1 ' );
163+ $ this ->assertCount (5 , $ result );
162164 }
163165
164166
165167 /**
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.
167169 *
168170 * @param string $schema
169171 * @param string $id
170172 * @param array $filters
171173 * @return \dokuwiki\plugin\struct\meta\Value[][]
172174 */
173- protected function fetchPagesResult ($ schema , $ id = '' , $ filters = [])
175+ protected function fetchAllResults ($ schema , $ id = '' , $ filters = [])
174176 {
175177 $ syntaxConfig = ['schema: ' . $ schema , 'cols: %pageid%, %rowid%, * ' ];
176178 $ configParser = new ConfigParser ($ syntaxConfig );
@@ -191,13 +193,13 @@ protected function fetchPagesResult($schema, $id = '', $filters = [])
191193 * @param array $filters
192194 * @return \dokuwiki\plugin\struct\meta\Value[][]
193195 */
194- protected function fetchResult ($ schema , $ id = '' , $ filters = [])
196+ protected function fetchNonPageResults ($ schema , $ id = '' , $ filters = [])
195197 {
196198 $ syntaxConfig = ['schema: ' . $ schema , 'cols: %pageid%, %rowid%, * ' ];
197199 $ configParser = new ConfigParser ($ syntaxConfig );
198200 $ config = $ configParser ->getConfig ();
199201
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
201203 if ($ id ) {
202204 $ config ['filter ' ][] = ['%rowid% ' , '!= ' , (string )AccessTablePage::DEFAULT_PAGE_RID , 'AND ' ];
203205 $ config ['filter ' ][] = ['%pageid% ' , '= ' , $ id , 'AND ' ];
0 commit comments