mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
feat: adds toHaveLineCountLessThan
This commit is contained in:
@ -447,6 +447,19 @@ final class Expectation
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the given expectation target to have line count less than the given number.
|
||||
*/
|
||||
public function toHaveLineCountLessThan(int $lines): ArchExpectation
|
||||
{
|
||||
return Targeted::make(
|
||||
$this,
|
||||
fn (ObjectDescription $object): bool => count(file($object->path)) < $lines,
|
||||
sprintf('to have less than %d lines of code', $lines),
|
||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, '<?php')),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the given expectation target use the "declare(strict_types=1)" declaration.
|
||||
*/
|
||||
|
||||
@ -88,6 +88,14 @@ final class OppositeExpectation
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Not supported.
|
||||
*/
|
||||
public function toHaveLineCountLessThan(): ArchExpectation
|
||||
{
|
||||
throw InvalidExpectation::fromMethods(['not', 'toHaveLineCountLessThan']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the given expectation target does not use the "declare(strict_types=1)" declaration.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user