wkhayrattee/php-utils

A list of reusable functions to use across PHP projects, with Test cases

dev-main 2022-12-01 12:51 UTC

This package is auto-updated.

Last update: 2024-03-29 04:20:10 UTC


README

A list of reusable functions to use across PHP projects, with Test cases

Testing With PEST

Installing PEST

$ composer require pestphp/pest --dev --with-all-dependencies

$ vendor/bin/pest --init

The init command will create the following files & folders as mentioned in the output:

   DONE  Created `tests` directory.
   DONE  Created `phpunit.xml` file.
   DONE  Created `tests/Pest.php` file.
   DONE  Created `tests/ExampleTest.php` file.

   DONE  Pest initialised.

Test Code Coverage aka PCOV

Installing PCOV

$ git clone https://github.com/krakjoe/pcov.git
$ cd pcov
$ phpize
$ ./configure --enable-pcov
$ make
$ make test
$ make install

Enabling PCOV

  1. Note the /path/to/the/pcov.so on your CLI just after the executing the make install command
  2. Add the below on your CLI's php.ini (since we are using cli and not web)
[pcov]
extension=/usr/lib/php/20210902/pcov.so
pcov.enabled = 1

For list of values to customise in php.ini, see this doc here

Executing the Test Coverage:

$ vendor/bin/pest --coverage

With report format

$ vendor/bin/pest --coverage --testdox

References & Recommended Resources