-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#[RequiresPhpunitExtension] attribute
- Loading branch information
1 parent
93961d3
commit bf3d4a4
Showing
13 changed files
with
437 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\Framework\Attributes; | ||
|
||
use Attribute; | ||
use PHPUnit\Runner\Extension\Extension; | ||
|
||
/** | ||
* @immutable | ||
* | ||
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit | ||
*/ | ||
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)] | ||
final readonly class RequiresPhpunitExtension | ||
{ | ||
/** | ||
* @var class-string<Extension> | ||
*/ | ||
private string $extensionClasses; | ||
|
||
/** | ||
* @param class-string<Extension> $extensionClas | ||
*/ | ||
public function __construct(string $extensionClas) | ||
{ | ||
$this->extensionClasses = $extensionClas; | ||
} | ||
|
||
/** | ||
* @return class-string<Extension> | ||
*/ | ||
public function extensionClass(): string | ||
{ | ||
return $this->extensionClasses; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\Metadata; | ||
|
||
use PHPUnit\Runner\Extension\Extension; | ||
|
||
/** | ||
* @immutable | ||
* | ||
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit | ||
*/ | ||
final readonly class RequiresPhpunitExtension extends Metadata | ||
{ | ||
/** | ||
* @var class-string<Extension> | ||
*/ | ||
private string $extensionClass; | ||
|
||
/** | ||
* @param class-string<Extension> $extensionClass | ||
*/ | ||
public function __construct(int $level, string $extensionClass) | ||
{ | ||
parent::__construct($level); | ||
|
||
$this->extensionClass = $extensionClass; | ||
} | ||
|
||
public function isRequiresPhpunitExtension(): true | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* @return class-string<Extension> | ||
*/ | ||
public function extensionClass(): string | ||
{ | ||
return $this->extensionClass; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
tests/_files/Metadata/Attribute/tests/RequiresPhpunitExtensionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\TestFixture\Metadata\Attribute; | ||
|
||
use PHPUnit\Framework\Attributes\RequiresPhpunitExtension; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
#[RequiresPhpunitExtension(SomeExtension::class)] | ||
final class RequiresPhpunitExtensionTest extends TestCase | ||
{ | ||
#[RequiresPhpunitExtension(SomeExtension::class)] | ||
#[RequiresPhpunitExtension(SomeOtherExtension::class)] | ||
public function testOne(): void | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.