mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6080f51a0b | |||
| e0f07be017 | |||
| 42e1b9f17f | |||
| 0171617c1d | |||
| 2e11e9e65d |
@ -15,8 +15,13 @@
|
|||||||
**Pest** is an elegant PHP testing Framework with a focus on simplicity, meticulously designed to bring back the joy of testing in PHP.
|
**Pest** is an elegant PHP testing Framework with a focus on simplicity, meticulously designed to bring back the joy of testing in PHP.
|
||||||
|
|
||||||
- Explore our docs at **[pestphp.com »](https://pestphp.com)**
|
- Explore our docs at **[pestphp.com »](https://pestphp.com)**
|
||||||
- Follow us on Twitter at **[@pestphp »](https://twitter.com/pestphp)**
|
- Follow the creator Nuno Maduro:
|
||||||
- Join us at **[discord.gg/kaHY6p54JH »](https://discord.gg/kaHY6p54JH)** or **[t.me/+kYH5G4d5MV83ODk0 »](https://t.me/+kYH5G4d5MV83ODk0)**
|
- YouTube: **[youtube.com/@nunomaduro](https://www.youtube.com/@nunomaduro)** — Videos every weekday
|
||||||
|
- Twitch: **[twitch.tv/enunomaduro](https://www.twitch.tv/enunomaduro)** — Streams (almost) every weekday
|
||||||
|
- Twitter / X: **[x.com/enunomaduro](https://x.com/enunomaduro)**
|
||||||
|
- LinkedIn: **[linkedin.com/in/nunomaduro](https://www.linkedin.com/in/nunomaduro)**
|
||||||
|
- Instagram: **[instagram.com/enunomaduro](https://www.instagram.com/enunomaduro)**
|
||||||
|
- Tiktok: **[tiktok.com/@enunomaduro](https://www.tiktok.com/@enunomaduro)**
|
||||||
|
|
||||||
## Sponsors
|
## Sponsors
|
||||||
|
|
||||||
|
|||||||
@ -19,10 +19,10 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": "^8.2.0",
|
"php": "^8.2.0",
|
||||||
"brianium/paratest": "^7.8.3",
|
"brianium/paratest": "^7.8.3",
|
||||||
"nunomaduro/collision": "^8.7.0",
|
"nunomaduro/collision": "^8.8.0",
|
||||||
"nunomaduro/termwind": "^2.3.0",
|
"nunomaduro/termwind": "^2.3.0",
|
||||||
"pestphp/pest-plugin": "^3.0.0",
|
"pestphp/pest-plugin": "^3.0.0",
|
||||||
"pestphp/pest-plugin-arch": "^3.0.0",
|
"pestphp/pest-plugin-arch": "^3.1.0",
|
||||||
"pestphp/pest-plugin-mutate": "^3.0.5",
|
"pestphp/pest-plugin-mutate": "^3.0.5",
|
||||||
"phpunit/phpunit": "^11.5.15"
|
"phpunit/phpunit": "^11.5.15"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -24,8 +24,12 @@ final readonly class Thanks
|
|||||||
*/
|
*/
|
||||||
private const FUNDING_MESSAGES = [
|
private const FUNDING_MESSAGES = [
|
||||||
'Star' => 'https://github.com/pestphp/pest',
|
'Star' => 'https://github.com/pestphp/pest',
|
||||||
'News' => 'https://twitter.com/pestphp',
|
'YouTube' => 'https://youtube.com/@nunomaduro',
|
||||||
'Videos' => 'https://youtube.com/@nunomaduro',
|
'TikTok' => 'https://tiktok.com/@nunomaduro',
|
||||||
|
'Twitch' => 'https://twitch.tv/enunomaduro',
|
||||||
|
'LinkedIn' => 'https://linkedin.com/in/nunomaduro',
|
||||||
|
'Instagram' => 'https://instagram.com/enunomaduro',
|
||||||
|
'X' => 'https://x.com/enunomaduro',
|
||||||
'Sponsor' => 'https://github.com/sponsors/nunomaduro',
|
'Sponsor' => 'https://github.com/sponsors/nunomaduro',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@ -74,7 +74,10 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
public function toUse(array|string $targets): ArchExpectation
|
public function toUse(array|string $targets): ArchExpectation
|
||||||
{
|
{
|
||||||
return GroupArchExpectation::fromExpectations($this->original, array_map(fn (string $target): SingleArchExpectation => ToUse::make($this->original, $target)->opposite(
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
|
return GroupArchExpectation::fromExpectations($original, array_map(fn (string $target): SingleArchExpectation => ToUse::make($original, $target)->opposite(
|
||||||
fn () => $this->throwExpectationFailedException('toUse', $target),
|
fn () => $this->throwExpectationFailedException('toUse', $target),
|
||||||
), is_string($targets) ? [$targets] : $targets));
|
), is_string($targets) ? [$targets] : $targets));
|
||||||
}
|
}
|
||||||
@ -84,8 +87,11 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
public function toHaveFileSystemPermissions(string $permissions): ArchExpectation
|
public function toHaveFileSystemPermissions(string $permissions): ArchExpectation
|
||||||
{
|
{
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
fn (ObjectDescription $object): bool => substr(sprintf('%o', fileperms($object->path)), -4) !== $permissions,
|
fn (ObjectDescription $object): bool => substr(sprintf('%o', fileperms($object->path)), -4) !== $permissions,
|
||||||
sprintf('permissions not to be [%s]', $permissions),
|
sprintf('permissions not to be [%s]', $permissions),
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, '<?php')),
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, '<?php')),
|
||||||
@ -105,8 +111,11 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
public function toHaveMethodsDocumented(): ArchExpectation
|
public function toHaveMethodsDocumented(): ArchExpectation
|
||||||
{
|
{
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
fn (ObjectDescription $object): bool => isset($object->reflectionClass) === false
|
fn (ObjectDescription $object): bool => isset($object->reflectionClass) === false
|
||||||
|| array_filter(
|
|| array_filter(
|
||||||
Reflection::getMethodsFromReflectionClass($object->reflectionClass),
|
Reflection::getMethodsFromReflectionClass($object->reflectionClass),
|
||||||
@ -124,8 +133,11 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
public function toHavePropertiesDocumented(): ArchExpectation
|
public function toHavePropertiesDocumented(): ArchExpectation
|
||||||
{
|
{
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
fn (ObjectDescription $object): bool => isset($object->reflectionClass) === false
|
fn (ObjectDescription $object): bool => isset($object->reflectionClass) === false
|
||||||
|| array_filter(
|
|| array_filter(
|
||||||
Reflection::getPropertiesFromReflectionClass($object->reflectionClass),
|
Reflection::getPropertiesFromReflectionClass($object->reflectionClass),
|
||||||
@ -144,8 +156,11 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
public function toUseStrictTypes(): ArchExpectation
|
public function toUseStrictTypes(): ArchExpectation
|
||||||
{
|
{
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
fn (ObjectDescription $object): bool => ! (bool) preg_match('/^<\?php\s+declare\(.*?strict_types\s?=\s?1.*?\);/', (string) file_get_contents($object->path)),
|
fn (ObjectDescription $object): bool => ! (bool) preg_match('/^<\?php\s+declare\(.*?strict_types\s?=\s?1.*?\);/', (string) file_get_contents($object->path)),
|
||||||
'not to use strict types',
|
'not to use strict types',
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, '<?php')),
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, '<?php')),
|
||||||
@ -157,8 +172,11 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
public function toUseStrictEquality(): ArchExpectation
|
public function toUseStrictEquality(): ArchExpectation
|
||||||
{
|
{
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
fn (ObjectDescription $object): bool => ! str_contains((string) file_get_contents($object->path), ' === ') && ! str_contains((string) file_get_contents($object->path), ' !== '),
|
fn (ObjectDescription $object): bool => ! str_contains((string) file_get_contents($object->path), ' === ') && ! str_contains((string) file_get_contents($object->path), ' !== '),
|
||||||
'to use strict equality',
|
'to use strict equality',
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, ' === ') || str_contains($line, ' !== ')),
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, ' === ') || str_contains($line, ' !== ')),
|
||||||
@ -170,8 +188,11 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
public function toBeFinal(): ArchExpectation
|
public function toBeFinal(): ArchExpectation
|
||||||
{
|
{
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
fn (ObjectDescription $object): bool => ! enum_exists($object->name) && ! $object->reflectionClass->isFinal(),
|
fn (ObjectDescription $object): bool => ! enum_exists($object->name) && ! $object->reflectionClass->isFinal(),
|
||||||
'not to be final',
|
'not to be final',
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
||||||
@ -183,8 +204,11 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
public function toBeReadonly(): ArchExpectation
|
public function toBeReadonly(): ArchExpectation
|
||||||
{
|
{
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
fn (ObjectDescription $object): bool => ! enum_exists($object->name) && ! $object->reflectionClass->isReadOnly() && assert(true), // @phpstan-ignore-line
|
fn (ObjectDescription $object): bool => ! enum_exists($object->name) && ! $object->reflectionClass->isReadOnly() && assert(true), // @phpstan-ignore-line
|
||||||
'not to be readonly',
|
'not to be readonly',
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
||||||
@ -196,8 +220,11 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
public function toBeTrait(): ArchExpectation
|
public function toBeTrait(): ArchExpectation
|
||||||
{
|
{
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
fn (ObjectDescription $object): bool => ! $object->reflectionClass->isTrait(),
|
fn (ObjectDescription $object): bool => ! $object->reflectionClass->isTrait(),
|
||||||
'not to be trait',
|
'not to be trait',
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
||||||
@ -217,8 +244,11 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
public function toBeAbstract(): ArchExpectation
|
public function toBeAbstract(): ArchExpectation
|
||||||
{
|
{
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
fn (ObjectDescription $object): bool => ! $object->reflectionClass->isAbstract(),
|
fn (ObjectDescription $object): bool => ! $object->reflectionClass->isAbstract(),
|
||||||
'not to be abstract',
|
'not to be abstract',
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
||||||
@ -234,8 +264,11 @@ final readonly class OppositeExpectation
|
|||||||
{
|
{
|
||||||
$methods = is_array($method) ? $method : [$method];
|
$methods = is_array($method) ? $method : [$method];
|
||||||
|
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
fn (ObjectDescription $object): bool => array_filter(
|
fn (ObjectDescription $object): bool => array_filter(
|
||||||
$methods,
|
$methods,
|
||||||
fn (string $method): bool => $object->reflectionClass->hasMethod($method),
|
fn (string $method): bool => $object->reflectionClass->hasMethod($method),
|
||||||
@ -266,8 +299,11 @@ final readonly class OppositeExpectation
|
|||||||
|
|
||||||
$state = new stdClass;
|
$state = new stdClass;
|
||||||
|
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
function (ObjectDescription $object) use ($methods, &$state): bool {
|
function (ObjectDescription $object) use ($methods, &$state): bool {
|
||||||
$reflectionMethods = isset($object->reflectionClass)
|
$reflectionMethods = isset($object->reflectionClass)
|
||||||
? Reflection::getMethodsFromReflectionClass($object->reflectionClass, ReflectionMethod::IS_PUBLIC)
|
? Reflection::getMethodsFromReflectionClass($object->reflectionClass, ReflectionMethod::IS_PUBLIC)
|
||||||
@ -309,8 +345,11 @@ final readonly class OppositeExpectation
|
|||||||
|
|
||||||
$state = new stdClass;
|
$state = new stdClass;
|
||||||
|
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
function (ObjectDescription $object) use ($methods, &$state): bool {
|
function (ObjectDescription $object) use ($methods, &$state): bool {
|
||||||
$reflectionMethods = isset($object->reflectionClass)
|
$reflectionMethods = isset($object->reflectionClass)
|
||||||
? Reflection::getMethodsFromReflectionClass($object->reflectionClass, ReflectionMethod::IS_PROTECTED)
|
? Reflection::getMethodsFromReflectionClass($object->reflectionClass, ReflectionMethod::IS_PROTECTED)
|
||||||
@ -352,8 +391,11 @@ final readonly class OppositeExpectation
|
|||||||
|
|
||||||
$state = new stdClass;
|
$state = new stdClass;
|
||||||
|
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
function (ObjectDescription $object) use ($methods, &$state): bool {
|
function (ObjectDescription $object) use ($methods, &$state): bool {
|
||||||
$reflectionMethods = isset($object->reflectionClass)
|
$reflectionMethods = isset($object->reflectionClass)
|
||||||
? Reflection::getMethodsFromReflectionClass($object->reflectionClass, ReflectionMethod::IS_PRIVATE)
|
? Reflection::getMethodsFromReflectionClass($object->reflectionClass, ReflectionMethod::IS_PRIVATE)
|
||||||
@ -389,8 +431,11 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
public function toBeEnum(): ArchExpectation
|
public function toBeEnum(): ArchExpectation
|
||||||
{
|
{
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
fn (ObjectDescription $object): bool => ! $object->reflectionClass->isEnum(),
|
fn (ObjectDescription $object): bool => ! $object->reflectionClass->isEnum(),
|
||||||
'not to be enum',
|
'not to be enum',
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
||||||
@ -410,8 +455,11 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
public function toBeClass(): ArchExpectation
|
public function toBeClass(): ArchExpectation
|
||||||
{
|
{
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
fn (ObjectDescription $object): bool => ! class_exists($object->name),
|
fn (ObjectDescription $object): bool => ! class_exists($object->name),
|
||||||
'not to be class',
|
'not to be class',
|
||||||
FileLineFinder::where(fn (string $line): bool => true),
|
FileLineFinder::where(fn (string $line): bool => true),
|
||||||
@ -431,8 +479,11 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
public function toBeInterface(): ArchExpectation
|
public function toBeInterface(): ArchExpectation
|
||||||
{
|
{
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
fn (ObjectDescription $object): bool => ! $object->reflectionClass->isInterface(),
|
fn (ObjectDescription $object): bool => ! $object->reflectionClass->isInterface(),
|
||||||
'not to be interface',
|
'not to be interface',
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
||||||
@ -452,8 +503,11 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
public function toExtend(string $class): ArchExpectation
|
public function toExtend(string $class): ArchExpectation
|
||||||
{
|
{
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
fn (ObjectDescription $object): bool => ! $object->reflectionClass->isSubclassOf($class),
|
fn (ObjectDescription $object): bool => ! $object->reflectionClass->isSubclassOf($class),
|
||||||
sprintf("not to extend '%s'", $class),
|
sprintf("not to extend '%s'", $class),
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
||||||
@ -465,8 +519,11 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
public function toExtendNothing(): ArchExpectation
|
public function toExtendNothing(): ArchExpectation
|
||||||
{
|
{
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
fn (ObjectDescription $object): bool => $object->reflectionClass->getParentClass() !== false,
|
fn (ObjectDescription $object): bool => $object->reflectionClass->getParentClass() !== false,
|
||||||
'to extend a class',
|
'to extend a class',
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
||||||
@ -490,8 +547,11 @@ final readonly class OppositeExpectation
|
|||||||
{
|
{
|
||||||
$traits = is_array($traits) ? $traits : [$traits];
|
$traits = is_array($traits) ? $traits : [$traits];
|
||||||
|
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
function (ObjectDescription $object) use ($traits): bool {
|
function (ObjectDescription $object) use ($traits): bool {
|
||||||
foreach ($traits as $trait) {
|
foreach ($traits as $trait) {
|
||||||
if (in_array($trait, $object->reflectionClass->getTraitNames(), true)) {
|
if (in_array($trait, $object->reflectionClass->getTraitNames(), true)) {
|
||||||
@ -515,8 +575,11 @@ final readonly class OppositeExpectation
|
|||||||
{
|
{
|
||||||
$interfaces = is_array($interfaces) ? $interfaces : [$interfaces];
|
$interfaces = is_array($interfaces) ? $interfaces : [$interfaces];
|
||||||
|
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
function (ObjectDescription $object) use ($interfaces): bool {
|
function (ObjectDescription $object) use ($interfaces): bool {
|
||||||
foreach ($interfaces as $interface) {
|
foreach ($interfaces as $interface) {
|
||||||
if ($object->reflectionClass->implementsInterface($interface)) {
|
if ($object->reflectionClass->implementsInterface($interface)) {
|
||||||
@ -536,8 +599,11 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
public function toImplementNothing(): ArchExpectation
|
public function toImplementNothing(): ArchExpectation
|
||||||
{
|
{
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
fn (ObjectDescription $object): bool => $object->reflectionClass->getInterfaceNames() !== [],
|
fn (ObjectDescription $object): bool => $object->reflectionClass->getInterfaceNames() !== [],
|
||||||
'to implement an interface',
|
'to implement an interface',
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
||||||
@ -557,8 +623,11 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
public function toHavePrefix(string $prefix): ArchExpectation
|
public function toHavePrefix(string $prefix): ArchExpectation
|
||||||
{
|
{
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
fn (ObjectDescription $object): bool => ! str_starts_with($object->reflectionClass->getShortName(), $prefix),
|
fn (ObjectDescription $object): bool => ! str_starts_with($object->reflectionClass->getShortName(), $prefix),
|
||||||
"not to have prefix '{$prefix}'",
|
"not to have prefix '{$prefix}'",
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
||||||
@ -570,8 +639,11 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
public function toHaveSuffix(string $suffix): ArchExpectation
|
public function toHaveSuffix(string $suffix): ArchExpectation
|
||||||
{
|
{
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
fn (ObjectDescription $object): bool => ! str_ends_with($object->reflectionClass->getName(), $suffix),
|
fn (ObjectDescription $object): bool => ! str_ends_with($object->reflectionClass->getName(), $suffix),
|
||||||
"not to have suffix '{$suffix}'",
|
"not to have suffix '{$suffix}'",
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
||||||
@ -599,7 +671,10 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
public function toBeUsed(): ArchExpectation
|
public function toBeUsed(): ArchExpectation
|
||||||
{
|
{
|
||||||
return ToBeUsedInNothing::make($this->original);
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
|
return ToBeUsedInNothing::make($original);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -609,7 +684,10 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
public function toBeUsedIn(array|string $targets): ArchExpectation
|
public function toBeUsedIn(array|string $targets): ArchExpectation
|
||||||
{
|
{
|
||||||
return GroupArchExpectation::fromExpectations($this->original, array_map(fn (string $target): GroupArchExpectation => ToBeUsedIn::make($this->original, $target)->opposite(
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
|
return GroupArchExpectation::fromExpectations($original, array_map(fn (string $target): GroupArchExpectation => ToBeUsedIn::make($original, $target)->opposite(
|
||||||
fn () => $this->throwExpectationFailedException('toBeUsedIn', $target),
|
fn () => $this->throwExpectationFailedException('toBeUsedIn', $target),
|
||||||
), is_string($targets) ? [$targets] : $targets));
|
), is_string($targets) ? [$targets] : $targets));
|
||||||
}
|
}
|
||||||
@ -632,8 +710,11 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
public function toBeInvokable(): ArchExpectation
|
public function toBeInvokable(): ArchExpectation
|
||||||
{
|
{
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
fn (ObjectDescription $object): bool => ! $object->reflectionClass->hasMethod('__invoke'),
|
fn (ObjectDescription $object): bool => ! $object->reflectionClass->hasMethod('__invoke'),
|
||||||
'to not be invokable',
|
'to not be invokable',
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class'))
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class'))
|
||||||
@ -645,8 +726,11 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
public function toHaveAttribute(string $attribute): ArchExpectation
|
public function toHaveAttribute(string $attribute): ArchExpectation
|
||||||
{
|
{
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
fn (ObjectDescription $object): bool => $object->reflectionClass->getAttributes($attribute) === [],
|
fn (ObjectDescription $object): bool => $object->reflectionClass->getAttributes($attribute) === [],
|
||||||
"to not have attribute '{$attribute}'",
|
"to not have attribute '{$attribute}'",
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class'))
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class'))
|
||||||
@ -737,8 +821,11 @@ final readonly class OppositeExpectation
|
|||||||
*/
|
*/
|
||||||
private function toBeBackedEnum(string $backingType): ArchExpectation
|
private function toBeBackedEnum(string $backingType): ArchExpectation
|
||||||
{
|
{
|
||||||
|
/** @var Expectation<array<int, string>|string> $original */
|
||||||
|
$original = $this->original;
|
||||||
|
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$original,
|
||||||
fn (ObjectDescription $object): bool => ! $object->reflectionClass->isEnum()
|
fn (ObjectDescription $object): bool => ! $object->reflectionClass->isEnum()
|
||||||
|| ! (new \ReflectionEnum($object->name))->isBacked() // @phpstan-ignore-line
|
|| ! (new \ReflectionEnum($object->name))->isBacked() // @phpstan-ignore-line
|
||||||
|| (string) (new \ReflectionEnum($object->name))->getBackingType() !== $backingType, // @phpstan-ignore-line
|
|| (string) (new \ReflectionEnum($object->name))->getBackingType() !== $backingType, // @phpstan-ignore-line
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace Pest;
|
|||||||
|
|
||||||
function version(): string
|
function version(): string
|
||||||
{
|
{
|
||||||
return '3.7.5';
|
return '3.8.1';
|
||||||
}
|
}
|
||||||
|
|
||||||
function testDirectory(string $file = ''): string
|
function testDirectory(string $file = ''): string
|
||||||
|
|||||||
@ -119,6 +119,6 @@ final readonly class Init implements HandlesArguments
|
|||||||
*/
|
*/
|
||||||
private function isLaravelInstalled(): bool
|
private function isLaravelInstalled(): bool
|
||||||
{
|
{
|
||||||
return InstalledVersions::isInstalled('laravel/laravel');
|
return InstalledVersions::isInstalled('laravel/framework');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
pest()->extend(Tests\TestCase::class)
|
pest()->extend(Tests\TestCase::class)
|
||||||
->use(Illuminate\Foundation\Testing\RefreshDatabase::class)
|
// ->use(Illuminate\Foundation\Testing\RefreshDatabase::class)
|
||||||
->in('Feature');
|
->in('Feature');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -1,31 +1,33 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
|
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||||
bootstrap="vendor/autoload.php"
|
bootstrap="vendor/autoload.php"
|
||||||
colors="true"
|
colors="true"
|
||||||
>
|
>
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="Unit">
|
<testsuite name="Unit">
|
||||||
<directory suffix="Test.php">./tests/Unit</directory>
|
<directory>tests/Unit</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
<testsuite name="Feature">
|
<testsuite name="Feature">
|
||||||
<directory suffix="Test.php">./tests/Feature</directory>
|
<directory>tests/Feature</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
<source>
|
||||||
|
<include>
|
||||||
|
<directory>app</directory>
|
||||||
|
</include>
|
||||||
|
</source>
|
||||||
<php>
|
<php>
|
||||||
<env name="APP_ENV" value="testing"/>
|
<env name="APP_ENV" value="testing"/>
|
||||||
|
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
|
||||||
<env name="BCRYPT_ROUNDS" value="4"/>
|
<env name="BCRYPT_ROUNDS" value="4"/>
|
||||||
<env name="CACHE_DRIVER" value="array"/>
|
<env name="CACHE_STORE" value="array"/>
|
||||||
<!-- <env name="DB_CONNECTION" value="sqlite"/> -->
|
<!-- <env name="DB_CONNECTION" value="sqlite"/> -->
|
||||||
<!-- <env name="DB_DATABASE" value=":memory:"/> -->
|
<!-- <env name="DB_DATABASE" value=":memory:"/> -->
|
||||||
<env name="MAIL_MAILER" value="array"/>
|
<env name="MAIL_MAILER" value="array"/>
|
||||||
|
<env name="PULSE_ENABLED" value="false"/>
|
||||||
<env name="QUEUE_CONNECTION" value="sync"/>
|
<env name="QUEUE_CONNECTION" value="sync"/>
|
||||||
<env name="SESSION_DRIVER" value="array"/>
|
<env name="SESSION_DRIVER" value="array"/>
|
||||||
<env name="TELESCOPE_ENABLED" value="false"/>
|
<env name="TELESCOPE_ENABLED" value="false"/>
|
||||||
</php>
|
</php>
|
||||||
<source>
|
|
||||||
<include>
|
|
||||||
<directory suffix=".php">./app</directory>
|
|
||||||
</include>
|
|
||||||
</source>
|
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// pest()->extend(Tests\TestCase::class)->in('Feature');
|
pest()->extend(Tests\TestCase::class)->in('Feature');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
|
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||||
bootstrap="vendor/autoload.php"
|
bootstrap="vendor/autoload.php"
|
||||||
colors="true"
|
colors="true"
|
||||||
>
|
>
|
||||||
@ -11,8 +11,8 @@
|
|||||||
</testsuites>
|
</testsuites>
|
||||||
<source>
|
<source>
|
||||||
<include>
|
<include>
|
||||||
<directory suffix=".php">./app</directory>
|
<directory>app</directory>
|
||||||
<directory suffix=".php">./src</directory>
|
<directory>src</directory>
|
||||||
</include>
|
</include>
|
||||||
</source>
|
</source>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
Pest Testing Framework 3.7.5.
|
Pest Testing Framework 3.8.1.
|
||||||
|
|
||||||
USAGE: pest <file> [options]
|
USAGE: pest <file> [options]
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
|
|
||||||
Pest Testing Framework 3.7.5.
|
Pest Testing Framework 3.8.1.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user