faissaloux/pest-plugin-inside

Files content plugin for Pest PHP

v1.5.1 2024-10-26 13:23 UTC

This package is auto-updated.

Last update: 2024-11-30 16:50:31 UTC


README

This plugin checks what's inside the files.

Tests Codecov Packagist Version Packagist License

Available Methods

toReturnLowercase

Make sure a file or directory files returns an array with all lowercase values.

expect('file.php')->toReturnLowercase();

toReturnUnique

Make sure a file or directory files returns an array with unique values.

expect('file.php')->toReturnUnique();

toReturnSingleWords

Make sure a file or directory files returns an array with single words.

expect('file.php')->toReturnSingleWords();

Success

<?php

// lowercase.php

return [
    'lower',
    'case',
    'lowercase',
    'array' => [
        'lower',
        'case',
    ],
];
expect('lowercase.php')->toReturnLowercase();

Failure

<?php

// notlowercase.php

return [
    'lower',
    'caSe',
    'lowercase',
];
expect('notlowercase.php')->toReturnLowercase();

Scan directory

directory
├── file.js
├── file.php
├── subdirectory
    ├── file.json
    ├── file1.php
    ├── file2.php
  • To scan all the php files in directory and all its subdirectories (file.php, file1.php and file2.php), we can use:
expect('directory')->toReturnLowercase();
  • We can also specify the scan depth using depth.
expect('directory')->toReturnLowercase(depth:0);

In this case it will only scan direct php file which is file.php.