Files
XC_VM/tests/Support/FakeTmdbClient.php
T
Divarion_D 8f6e3ab267 feat(vod): move the per-file VOD importer into core
Movies/Series -> Import (M3U or folder) spawned `console.php watch_item`,
a command that moved into the optional watch module during the module
split. Without the module the import reported success and imported
nothing.

The worker now lives in core as Domain\Vod\VodItemImporter behind the
`vod_import_item` command, and both import paths call it. It no longer
writes the module-owned watch_logs table: each file's outcome is
dispatched as a VodImportResultEvent for the module to log.

It also dispatches StreamsChangedEvent after inserting or upgrading a
stream, so Watch Folder imports now reach load balancers (R2 version
stamp), which the module copy never did.

The watch module's tests for the worker move here, plus an end-to-end
run() test for an M3U episode import. lb_settings_keys is regenerated
for the two settings the importer reads.
2026-10-03 22:12:14 +03:00

72 lines
2.4 KiB
PHP

<?php
/**
* FakeTmdbClient — test double for the global \TMDB client.
*
* The real \TMDB::__construct() makes a live curl_exec() to
* api.themoviedb.org and exit()s if that call fails, so it cannot be
* constructed at all in a test process without network access and a real
* API key. This double duck-types only the methods VodItemImporter actually calls
* (searchMovie/searchTVShow/getMovieTitles/getSeriesTitles/getMovie/
* getTVShow/getSeason) and is driven by plain closures, so each test wires
* up exactly the canned response it needs. Movie/TVShow/Season are the real
* TMDB entity classes (see TmdbClient.php's trailing include_once list) —
* they are plain array wrappers with no network dependency of their own.
*/
final class FakeTmdbClient {
private $rSearchMovie;
private $rSearchTVShow;
private $rGetMovieTitles;
private $rGetSeriesTitles;
private $rGetMovie;
private $rGetTVShow;
private $rGetSeason;
public function __construct(array $rHandlers = array()) {
$rNoResults = function () {
return array();
};
$rNoTitles = function () {
return array('titles' => array());
};
$rNull = function () {
return null;
};
$this->rSearchMovie = $rHandlers['searchMovie'] ?? $rNoResults;
$this->rSearchTVShow = $rHandlers['searchTVShow'] ?? $rNoResults;
$this->rGetMovieTitles = $rHandlers['getMovieTitles'] ?? $rNoTitles;
$this->rGetSeriesTitles = $rHandlers['getSeriesTitles'] ?? $rNoTitles;
$this->rGetMovie = $rHandlers['getMovie'] ?? $rNull;
$this->rGetTVShow = $rHandlers['getTVShow'] ?? $rNull;
$this->rGetSeason = $rHandlers['getSeason'] ?? $rNull;
}
public function searchMovie($rTitle, $rYear = null) {
return ($this->rSearchMovie)($rTitle, $rYear);
}
public function searchTVShow($rTitle, $rYear = null) {
return ($this->rSearchTVShow)($rTitle, $rYear);
}
public function getMovieTitles($rID) {
return ($this->rGetMovieTitles)($rID);
}
public function getSeriesTitles($rID) {
return ($this->rGetSeriesTitles)($rID);
}
public function getMovie($rID) {
return ($this->rGetMovie)($rID);
}
public function getTVShow($rID) {
return ($this->rGetTVShow)($rID);
}
public function getSeason($rShowID, $rSeason) {
return ($this->rGetSeason)($rShowID, $rSeason);
}
}