mirror of
https://github.com/pestphp/pest.git
synced 2026-03-11 02:07:23 +01:00
Add Initial teamcity support
This commit is contained in:
21
src/Factories/Annotations/AddsAnnotation.php
Normal file
21
src/Factories/Annotations/AddsAnnotation.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pest\Factories\Annotations;
|
||||
|
||||
use Pest\Factories\TestCaseMethodFactory;
|
||||
|
||||
/**
|
||||
* @interal
|
||||
*/
|
||||
interface AddsAnnotation
|
||||
{
|
||||
/**
|
||||
* Adds annotations to method
|
||||
*
|
||||
* @param array<int, string> $annotations
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function __invoke(TestCaseMethodFactory $method, array $annotations): array;
|
||||
}
|
||||
@ -10,7 +10,7 @@ use Pest\Factories\TestCaseMethodFactory;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class CoversNothing
|
||||
final class CoversNothing implements AddsAnnotation
|
||||
{
|
||||
/**
|
||||
* Adds annotations regarding the "depends" feature.
|
||||
|
||||
@ -10,7 +10,7 @@ use Pest\Support\Str;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class Depends
|
||||
final class Depends implements AddsAnnotation
|
||||
{
|
||||
/**
|
||||
* Adds annotations regarding the "depends" feature.
|
||||
|
||||
@ -9,7 +9,7 @@ use Pest\Factories\TestCaseMethodFactory;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class Groups
|
||||
final class Groups implements AddsAnnotation
|
||||
{
|
||||
/**
|
||||
* Adds annotations regarding the "groups" feature.
|
||||
|
||||
24
src/Factories/Annotations/TestDox.php
Normal file
24
src/Factories/Annotations/TestDox.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pest\Factories\Annotations;
|
||||
|
||||
use Pest\Factories\TestCaseMethodFactory;
|
||||
|
||||
final class TestDox implements AddsAnnotation
|
||||
{
|
||||
/**
|
||||
* Add metadata via test dox for TeamCity
|
||||
*
|
||||
* @param array<int, string> $annotations
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function __invoke(TestCaseMethodFactory $method, array $annotations): array
|
||||
{
|
||||
// First test dox on class overrides the method name.
|
||||
$annotations[] = "@testdox $method->description";
|
||||
|
||||
return $annotations;
|
||||
}
|
||||
}
|
||||
@ -11,6 +11,7 @@ use Pest\Exceptions\DatasetMissing;
|
||||
use Pest\Exceptions\ShouldNotHappen;
|
||||
use Pest\Exceptions\TestAlreadyExist;
|
||||
use Pest\Exceptions\TestDescriptionMissing;
|
||||
use Pest\Factories\Annotations\AddsAnnotation;
|
||||
use Pest\Factories\Concerns\HigherOrderable;
|
||||
use Pest\Plugins\Environment;
|
||||
use Pest\Support\Reflection;
|
||||
@ -29,12 +30,13 @@ final class TestCaseFactory
|
||||
/**
|
||||
* The list of annotations.
|
||||
*
|
||||
* @var array<int, class-string>
|
||||
* @var array<int, class-string<AddsAnnotation>>
|
||||
*/
|
||||
private const ANNOTATIONS = [
|
||||
Annotations\Depends::class,
|
||||
Annotations\Groups::class,
|
||||
Annotations\CoversNothing::class,
|
||||
Annotations\TestDox::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@ -198,6 +200,10 @@ final class TestCaseFactory
|
||||
|
||||
use Pest\Repositories\DatasetsRepository as __PestDatasets;
|
||||
use Pest\TestSuite as __PestTestSuite;
|
||||
|
||||
/**
|
||||
* @testdox $filename
|
||||
*/
|
||||
$classAttributesCode
|
||||
#[\AllowDynamicProperties]
|
||||
final class $className extends $baseClass implements $hasPrintableTestCaseClassFQN {
|
||||
|
||||
@ -6,6 +6,7 @@ namespace Pest\Factories;
|
||||
|
||||
use Closure;
|
||||
use Pest\Exceptions\ShouldNotHappen;
|
||||
use Pest\Factories\Annotations\AddsAnnotation;
|
||||
use Pest\Factories\Concerns\HigherOrderable;
|
||||
use Pest\Plugins\Retry;
|
||||
use Pest\Repositories\DatasetsRepository;
|
||||
@ -112,7 +113,7 @@ final class TestCaseMethodFactory
|
||||
/**
|
||||
* Creates a PHPUnit method as a string ready for evaluation.
|
||||
*
|
||||
* @param array<int, class-string> $annotationsToUse
|
||||
* @param array<int, class-string<AddsAnnotation>> $annotationsToUse
|
||||
* @param array<int, class-string<\Pest\Factories\Attributes\Attribute>> $attributesToUse
|
||||
*/
|
||||
public function buildForEvaluation(string $classFQN, array $annotationsToUse, array $attributesToUse): string
|
||||
@ -134,7 +135,6 @@ final class TestCaseMethodFactory
|
||||
$attributes = [];
|
||||
|
||||
foreach ($annotationsToUse as $annotation) {
|
||||
/** @phpstan-ignore-next-line */
|
||||
$annotations = (new $annotation())->__invoke($this, $annotations);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user