Adjusts for Collision 8.4

This commit is contained in:
Nuno Maduro
2024-08-03 16:36:01 +01:00
parent 63ba117b33
commit 6fb1133d52
6 changed files with 139 additions and 33 deletions

View File

@ -4,20 +4,45 @@ declare(strict_types=1);
namespace Pest\Configuration;
use NunoMaduro\Collision\Adapters\Phpunit\Printers\DefaultPrinter;
/**
* @internal
*/
final readonly class Context
final class Context
{
/**
* The issues link.
*
* @internal
*/
public string $issues = '';
/**
* The PRs link.
*
* @internal
*/
public string $prs = '';
/**
* The singleton instance.
*/
private static ?self $instance = null;
/**
* Creates a new instance of the context.
*/
public static function getInstance(): self
{
return self::$instance ??= new self;
}
/**
* Sets the test context to GitHub.
*/
public function github(string $project): self
{
DefaultPrinter::linkIssuesWith("https://github.com/{$project}/issues/%s");
DefaultPrinter::linkPrsWith("https://github.com/{$project}/pull/%s");
$this->issues = "https://github.com/{$project}/issues/%s";
$this->prs = "https://github.com/{$project}/pull/%s";
return $this;
}
@ -27,8 +52,8 @@ final readonly class Context
*/
public function gitlab(string $project): self
{
DefaultPrinter::linkIssuesWith("https://gitlab.com/{$project}/issues/%s");
DefaultPrinter::linkPrsWith("https://gitlab.com/{$project}/merge_requests/%s");
$this->issues = "https://gitlab.com/{$project}/issues/%s";
$this->prs = "https://gitlab.com/{$project}/merge_requests/%s";
return $this;
}
@ -38,8 +63,8 @@ final readonly class Context
*/
public function bitbucket(string $project): self
{
DefaultPrinter::linkIssuesWith('https://bitbucket.org/{$project}/issues/%s');
DefaultPrinter::linkPrsWith("https://bitbucket.org/{$project}/pull-requests/%s");
$this->issues = 'https://bitbucket.org/{$project}/issues/%s';
$this->prs = "https://bitbucket.org/{$project}/pull-requests/%s";
return $this;
}
@ -49,7 +74,7 @@ final readonly class Context
*/
public function jira(string $namespace, string $project): self
{
DefaultPrinter::linkIssuesWith("https://{$namespace}.atlassian.net/browse/{$project}-%s");
$this->issues = "https://{$namespace}.atlassian.net/browse/{$project}-%s";
return $this;
}
@ -59,8 +84,8 @@ final readonly class Context
*/
public function using(string $issues, string $prs): self
{
DefaultPrinter::linkIssuesWith($issues);
DefaultPrinter::linkPrsWith($prs);
$this->issues = $issues;
$this->prs = $prs;
return $this;
}