@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3/**
4 * Configurable test query for implementing Policy unit tests.
5 */
6final class PhabricatorPolicyAwareTestQuery
7 extends PhabricatorPolicyAwareQuery {
8
9 private $results;
10 private $offset = 0;
11
12 public function setResults(array $results) {
13 $this->results = $results;
14 return $this;
15 }
16
17 protected function willExecute() {
18 $this->offset = 0;
19 }
20
21 protected function loadPage() {
22 if ($this->getRawResultLimit()) {
23 return array_slice(
24 $this->results,
25 $this->offset,
26 $this->getRawResultLimit());
27 } else {
28 return array_slice($this->results, $this->offset);
29 }
30 }
31
32 protected function nextPage(array $page) {
33 $this->offset += count($page);
34 }
35
36 public function getQueryApplicationClass() {
37 return null;
38 }
39
40}