Skip to content

Commit ff40ffd

Browse files
authored
Merge pull request #612 from cosmocode/publish
Base for publish status via new structpublish plugin
2 parents bbfcbfb + 6c9d1a1 commit ff40ffd

26 files changed

+231
-26
lines changed

_test/AccessTableDataReplacement.test.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,10 @@ public function test_DataFiltersAsSubQuery($inputFilterLines, $expectedFilterWhe
185185
AND (ASSIGNED = 1 OR ASSIGNED IS NULL)
186186
)
187187
)
188-
AND data_bar.latest = 1";
188+
AND (
189+
(IS_PUBLISHER(data_bar.pid) AND data_bar.latest = 1)
190+
OR (IS_PUBLISHER(data_bar.pid) IS FALSE AND data_bar.published = 1)
191+
)";
189192

190193
$expected_where = $baseWhere . $expectedFilterWhere . " )";
191194
$this->assertEquals($this->cleanWS($expected_where), $this->cleanWS($where), $msg);

_test/SchemaBuilder.test.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ public function test_build_new()
6161
pid TEXT DEFAULT '',
6262
rid INTEGER,
6363
rev INTEGER,
64-
latest BOOLEAN NOT NULL DEFAULT 0, col1 DEFAULT '', col2 DEFAULT '',
64+
latest BOOLEAN NOT NULL DEFAULT 0,
65+
published BOOLEAN DEFAULT NULL, col1 DEFAULT '', col2 DEFAULT '',
6566
PRIMARY KEY(pid, rid, rev)
6667
)";
6768

_test/Search.test.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,22 @@ public function test_simple_title()
131131
$this->assertEquals(array('second data', 'more data', 'even more'), $result[0][2]->getValue());
132132
}
133133

134+
public function test_search_published()
135+
{
136+
$search = new mock\Search();
137+
$search->isNotPublisher();
138+
139+
$search->addSchema('schema1');
140+
$search->addColumn('%pageid%');
141+
$search->addColumn('first');
142+
$search->addColumn('second');
143+
144+
/** @var meta\Value[][] $result */
145+
$result = $search->execute();
146+
147+
$this->assertEquals(0, count($result), 'result rows');
148+
}
149+
134150
public function test_search_lasteditor()
135151
{
136152
$search = new mock\Search();

_test/json/bureaucracy.struct.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"allowed editors": "",
88
"label": {
99
"en": ""
10-
}
10+
},
11+
"internal": false
1112
},
1213
"columns": [
1314
{

_test/json/bureaucracy_lookup.struct.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"allowed editors": "",
88
"label": {
99
"en": ""
10-
}
10+
},
11+
"internal": false
1112
},
1213
"columns": [
1314
{

_test/json/schema1.struct.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"allowed editors": "",
88
"label": {
99
"en": ""
10-
}
10+
},
11+
"internal": false
1112
},
1213
"columns": [
1314
{

_test/json/schema_3.struct.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"allowed editors": "",
88
"label": {
99
"en": ""
10-
}
10+
},
11+
"internal": false
1112
},
1213
"columns": [
1314
{

_test/json/wikilookup.struct.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"allowed editors": "",
88
"label": {
99
"en": ""
10-
}
10+
},
11+
"internal": false
1112
},
1213
"columns": [
1314
{
@@ -81,4 +82,4 @@
8182
}
8283
}
8384
]
84-
}
85+
}

_test/mock/Search.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,13 @@ class Search extends meta\Search
1313
public $sortby = array();
1414

1515
public $filter = array();
16+
17+
/**
18+
* Register a dummy function that always returns false
19+
*/
20+
public function isNotPublisher()
21+
{
22+
$this->dbHelper = new helper_plugin_struct_db;
23+
$this->sqlite->create_function('IS_PUBLISHER', [$this->dbHelper, 'IS_PUBLISHER'], -1);
24+
}
1625
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace dokuwiki\plugin\struct\test\mock;
4+
5+
class helper_plugin_struct_db extends \helper_plugin_struct_db {
6+
7+
public function IS_PUBLISHER() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
8+
{
9+
return false;
10+
}
11+
}

0 commit comments

Comments
 (0)