mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Add Initial teamcity support
This commit is contained in:
46
src/Subscribers/EnsureTeamCityEnabled.php
Normal file
46
src/Subscribers/EnsureTeamCityEnabled.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pest\Subscribers;
|
||||
|
||||
use Pest\Logging\TeamCity\Converter;
|
||||
use Pest\Logging\TeamCity\TeamCityLogger;
|
||||
use Pest\TestSuite;
|
||||
use PHPUnit\Event\TestRunner\Configured;
|
||||
use PHPUnit\Event\TestRunner\ConfiguredSubscriber;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class EnsureTeamCityEnabled implements ConfiguredSubscriber
|
||||
{
|
||||
public function __construct(
|
||||
private readonly OutputInterface $output,
|
||||
private readonly InputInterface $input,
|
||||
private readonly TestSuite $testSuite,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the subscriber.
|
||||
*/
|
||||
public function notify(Configured $event): void
|
||||
{
|
||||
if (! $this->input->hasParameterOption('--teamcity')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$flowId = getenv('FLOW_ID');
|
||||
$flowId = is_string($flowId) ? (int) $flowId : getmypid();
|
||||
|
||||
new TeamCityLogger(
|
||||
$this->output,
|
||||
new Converter($this->testSuite->rootPath),
|
||||
$flowId === false ? null : $flowId,
|
||||
getenv('COLLISION_IGNORE_DURATION') !== false
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user