Files
xExtension-BlueskyThreads/tests/stubs/freshrss_stubs.php
James Griffin 932d7a5f0e
All checks were successful
CI / test (push) Successful in 1m41s
Add PHPUnit test suite, Gitea CI, and fix broken URL pattern
- Add 22 unit tests covering feed parsing, thread rendering, facets,
  needsRefetch staleness windows, and handleConfigureAction
- Add FreshRSS class stubs so tests run without a full FreshRSS install
- Add RSS feed fixture (hockeyviz.com snapshot) and thread API fixture
  for post 3mhtk7awhrp26 (1 root + 2 replies)
- Add Gitea Actions workflow (.gitea/workflows/ci.yml) running on PHP 8.2
- Fix POST_URL_PATTERN: using '#' as PCRE delimiter with '#' inside a
  character class caused PHP to close the pattern early, so no Bluesky
  URL ever matched; switch delimiter to '~'

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 15:41:07 -03:00

81 lines
2.0 KiB
PHP

<?php
declare(strict_types=1);
/**
* Minimal stubs for FreshRSS classes so the extension can be loaded and
* tested outside of a full FreshRSS installation.
*/
abstract class Minz_Extension {
private array $userConfig = [];
public function init(): void {}
public function handleConfigureAction(): void {}
protected function registerHook(string $name, callable $callback): void {}
public function setUserConfigurationValue(string $key, mixed $value): void {
$this->userConfig[$key] = $value;
}
public function getUserConfigurationValue(string $key): mixed {
return $this->userConfig[$key] ?? null;
}
}
class FreshRSS_Entry {
private string $link = '';
private string $content = '';
private int $date = 0;
public function link(): string { return $this->link; }
/** @param string $link */
public function _link(string $link): void { $this->link = $link; }
/** @param string $content */
public function _content(string $content): void { $this->content = $content; }
public function content(): string { return $this->content; }
public function date(bool $asTimestamp = false): mixed {
return $asTimestamp ? $this->date : date('r', $this->date);
}
public function _date(int $timestamp): void { $this->date = $timestamp; }
}
class FreshRSS_EntryDao {
public function updateEntry(FreshRSS_Entry $entry): void {}
}
class FreshRSS_Factory {
public static function createEntryDao(): FreshRSS_EntryDao {
return new FreshRSS_EntryDao();
}
}
class Minz_Request {
private static bool $isPost = false;
private static array $params = [];
public static function isPost(): bool { return self::$isPost; }
public static function paramString(string $key): string {
return self::$params[$key] ?? '';
}
/** Test helper: configure the fake request state. */
public static function simulatePost(array $params): void {
self::$isPost = true;
self::$params = $params;
}
public static function reset(): void {
self::$isPost = false;
self::$params = [];
}
}