|
| 1 | +<?php |
| 2 | + |
| 3 | +use PHPUnit\Framework\ExpectationFailedException; |
| 4 | + |
| 5 | +it('passes', function (string $file): void { |
| 6 | + expect($file)->toReturnUppercase(); |
| 7 | +})->with([ |
| 8 | + 'tests/Fixtures/returnsArrayOnlyUppercase.php', |
| 9 | + 'tests/Fixtures/text/returnsOnlyUppercase.stub', |
| 10 | +]); |
| 11 | + |
| 12 | +it('passes with not', function (string $file): void { |
| 13 | + expect($file)->not->toReturnUppercase(); |
| 14 | +})->with([ |
| 15 | + 'tests/Fixtures/returnsArrayLowercaseWithUppercase.php', |
| 16 | + 'tests/Fixtures/returnsArrayOnlyLowercase.php', |
| 17 | + 'tests/Fixtures/text/returnsArrayLowercaseWithUppercase.stub', |
| 18 | +]); |
| 19 | + |
| 20 | +it('passes when all nested arrays content is uppercase', function (): void { |
| 21 | + expect('tests/Fixtures/returnsNestedUppercase.php') |
| 22 | + ->toReturnUppercase(); |
| 23 | +}); |
| 24 | + |
| 25 | +it('passes when directory is empty', function (): void { |
| 26 | + expect('tests/Fixtures/empty') |
| 27 | + ->toReturnUppercase(); |
| 28 | +}); |
| 29 | + |
| 30 | +it('passes when all directory files content are uppercase', function (): void { |
| 31 | + expect('tests/Fixtures/uppercase/allUppercase.php') |
| 32 | + ->toReturnUppercase(depth: 0); |
| 33 | +}); |
| 34 | + |
| 35 | +it('fails', function (string $file): void { |
| 36 | + expect($file)->toReturnUppercase(); |
| 37 | +})->with([ |
| 38 | + 'tests/Fixtures/returnsArrayLowercaseWithUppercase.php', |
| 39 | + 'tests/Fixtures/text/returnsArrayLowercaseWithUppercase.stub', |
| 40 | +]) |
| 41 | + ->throws(ExpectationFailedException::class); |
| 42 | + |
| 43 | +it('fails with not', function (string $file): void { |
| 44 | + expect($file)->not->toReturnUppercase(); |
| 45 | +})->with([ |
| 46 | + 'tests/Fixtures/returnsArrayOnlyUppercase.php', |
| 47 | + 'tests/Fixtures/text/returnsOnlyUppercase.stub', |
| 48 | +])->throws(ExpectationFailedException::class); |
| 49 | + |
| 50 | +it('fails when not all nested arrays content is uppercase', function (): void { |
| 51 | + expect('tests/Fixtures/returnsNestedNotAllUppercase.php') |
| 52 | + ->toReturnUppercase(); |
| 53 | +})->throws(ExpectationFailedException::class, 'Not uppercase detected: INsIDE'); |
| 54 | + |
| 55 | +describe('fails when file does not exist', function (): void { |
| 56 | + test('php file', function (): void { |
| 57 | + expect('tests/Fixtures/notExist.php')->toReturnUppercase(); |
| 58 | + })->throws(ExpectationFailedException::class, 'tests/Fixtures/notExist.php not found'); |
| 59 | + |
| 60 | + test('text file', function (): void { |
| 61 | + expect('tests/Fixtures/notExist.stub')->toReturnUppercase(); |
| 62 | + })->throws(ExpectationFailedException::class, 'tests/Fixtures/notExist.stub not found'); |
| 63 | +}); |
| 64 | + |
| 65 | +it('fails when directory does not exist', function (): void { |
| 66 | + expect('tests/Fixtures/notExist') |
| 67 | + ->toReturnUppercase(); |
| 68 | +})->throws(ExpectationFailedException::class); |
| 69 | + |
| 70 | +it('fails when not all directory files content are uppercase', function (string $directory): void { |
| 71 | + expect($directory)->toReturnUppercase(); |
| 72 | +})->with([ |
| 73 | + 'tests/Fixtures/directory1', |
| 74 | + 'tests/Fixtures/text', |
| 75 | +])->throws(ExpectationFailedException::class); |
| 76 | + |
| 77 | +it('fails when not all subdirectories files content are uppercase', function (string $directory): void { |
| 78 | + expect($directory)->toReturnUppercase(); |
| 79 | +})->with([ |
| 80 | + 'tests/Fixtures/directory1', |
| 81 | + 'tests/Fixtures/text', |
| 82 | +])->throws(ExpectationFailedException::class); |
| 83 | + |
| 84 | +it('displays words detected', function (): void { |
| 85 | + expect('tests/Fixtures/directory')->toReturnUppercase(); |
| 86 | +})->throws(ExpectationFailedException::class, 'Not uppercase detected: f@issa!oux, pest, plugin, inside, lowercase, loWer, case, nOt'); |
| 87 | + |
| 88 | +it('displays file where error detected', function (): void { |
| 89 | + expect('tests/Fixtures/directory')->toReturnUppercase(); |
| 90 | +})->throws(ExpectationFailedException::class, 'notAllLowerCase.php'); |
0 commit comments