https://github.com/leafsphp/alchemy
⚗️ Modern and Delightful PHP testing library focused on simplicity
https://github.com/leafsphp/alchemy
Last synced: 11 months ago
JSON representation
⚗️ Modern and Delightful PHP testing library focused on simplicity
- Host: GitHub
- URL: https://github.com/leafsphp/alchemy
- Owner: leafsphp
- License: mit
- Created: 2021-12-13T10:09:11.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-09-28T11:52:26.000Z (over 2 years ago)
- Last Synced: 2024-05-23T06:01:12.040Z (over 1 year ago)
- Language: PHP
- Homepage: https://leafphp.dev/docs/tooling/testing
- Size: 38.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
Alchemy
[](https://packagist.org/packages/leafs/alchemy)
[](https://packagist.org/packages/leafs/alchemy)
[](https://packagist.org/packages/leafs/alchemy)
Alchemy is an integrated testing/style fixing tool for your PHP applications. Alchemy handles your test/linting setup and any other integration you might need to run your tests like CI/CD. Alchemy is not a testing framework or style fixer, it's a tool that manages all the nasty setup for you.
## 📦 Setting Up
You can install alchemy with leaf CLI
```bash
leaf install alchemy
```
Or with composer
```bash
composer require leafs/alchemy
```
Once installed, Alchemy will automatically set up an `alchemy.yml` file in your project's root which you can use to configure your tests, linting and github actions.
## 🗂 Your Alchemy File
The `alchemy.yml` file should look something like this:
```yaml
app:
- app
- src
tests:
engine: pest
parallel: true
paths:
- tests
files:
- '*.test.php'
coverage:
processUncoveredFiles: true
lint:
preset: 'PSR12'
ignore_dot_files: true
rules:
array_syntax:
syntax: 'short'
no_unused_imports: true
single_quote: true
ordered_imports:
imports_order: null
case_sensitive: false
sort_algorithm: 'alpha'
actions:
run:
- 'lint'
- 'test'
php:
extensions: json, zip
versions:
- '8.3'
event:
- 'push'
- 'pull_request'
```
You can make edits to this file to suit your needs. The `app` key is an array of directories to look for your app files in. The `tests` key is an array of configurations for your tests. The `lint` key is an array of configurations for your code styling checks. Once you're done setting up your `alchemy.yml` file, you can run the setup script.
```bash
leaf run alchemy # or composer run alchemy
```
This will install your test engine, PHP CS Fixer and any other dependencies you might need, and then generate dummy tests using the test engine you chose. It will then lint your code, run your tests and generate a coverage report (if you selected that option). It will also add a `test` and `lint` command to your `composer.json` file which you can use to run your tests and lint your code respectively. Finally, it will generate a `.github/workflows` directory with a `test.yml` file and a `lint.yml` file which you can use to run your tests and linting on github actions.
Based on your engine, you might see either of the outputs below
- PEST PHP

- PHPUnit