Skip to content

Commit

Permalink
moove tests loader into onLoad
Browse files Browse the repository at this point in the history
  • Loading branch information
ShockedPlot7560 committed Sep 23, 2023
1 parent eee826f commit ea54151
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/PmmpUnit.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,29 @@ public function __construct(PluginLoader $loader, Server $server, PluginDescript
}

include_once dirname(__DIR__) . "/vendor/autoload.php";
parent::__construct($loader, $server, $description, $dataFolder, $file, $resourceProvider);
}

$unitFolder = $dataFolder . "/tests";
protected function onLoad() : void {
$unitFolder = $this->getDataFolder() . "tests";
if (!is_dir($unitFolder)) {
$server->getLogger()->warning("Unit test folder ($unitFolder) not found, creating one...");
$this->getLogger()->warning("Unit test folder ($unitFolder) not found, creating one...");
mkdir($unitFolder);
}

$testSuite = getenv("TEST_SUITE");
if ($testSuite !== false) {
$unitFolder .= "/" . $testSuite;
if (!is_dir($unitFolder)) {
$server->getLogger()->warning("Unit test folder ($unitFolder) not found, creating one...");
$this->getLogger()->warning("Unit test folder ($unitFolder) not found, creating one...");
mkdir($unitFolder);
}
}

$server->getLogger()->debug("Loading tests from $unitFolder");
$this->getLogger()->debug("Loading tests from $unitFolder");

$this->test = TestSuite::fromDirectory($unitFolder);
parent::__construct($loader, $server, $description, $dataFolder, $file, $resourceProvider);
}

protected function onLoad() : void {
// prevent server waiting, so we can run tests faster for CI
$reflectionServer = new ReflectionClass(Server::getInstance());
$startTimeProperty = $reflectionServer->getProperty("startTime");
Expand Down

0 comments on commit ea54151

Please sign in to comment.