diff --git a/src/Expectation.php b/src/Expectation.php index ce108428..55fa626e 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -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, 'toHaveLineCountLessThan(1000); +}); + +it('fails', function () { + expect(Expectation::class)->toHaveLineCountLessThan(10); +})->throws(ArchExpectationFailedException::class); diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index f29178c0..222eba3c 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -16,7 +16,7 @@ $run = function () { test('parallel', function () use ($run) { expect($run('--exclude-group=integration')) - ->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 1052 passed (2579 assertions)') + ->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 1054 passed (2582 assertions)') ->toContain('Parallel: 3 processes'); })->skipOnWindows();