You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/docs/utils/testing.md
+30-12Lines changed: 30 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,12 +15,18 @@ leaf install alchemy
15
15
```
16
16
17
17
```bash:no-line-numbers [Composer]
18
-
composer require leafs/alchemy
18
+
composer require leafs/alchemy --dev
19
19
```
20
20
21
21
:::
22
22
23
-
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.
23
+
Once installed, you need to run the setup command to configure Alchemy for your project.
24
+
25
+
```bash:no-line-numbers
26
+
./vendor/bin/alchemy install
27
+
```
28
+
29
+
This 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. It also sets up commands for testing and linting in your `composer.json` file.
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.
73
+
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 your test command, lint command, GitHub actions command or the alchemy command to do all of that at once.
65
74
66
75
::: code-group
67
76
68
77
```bash:no-line-numbers [Leaf CLI]
69
-
leaf run alchemy
78
+
leaf run test # Generate/Run tests
79
+
leaf run lint # Generate/Run code styling checks
80
+
leaf run actions # Generate GitHub Actions
81
+
leaf run alchemy # Run all of the above
70
82
```
71
83
72
84
```bash:no-line-numbers [Composer]
73
-
composer run alchemy
85
+
composer run test # Generate/Run tests
86
+
composer run lint # Generate/Run code styling checks
87
+
composer run actions # Generate GitHub Actions
88
+
composer run alchemy # Run all of the above
74
89
```
75
90
76
91
:::
77
92
78
-
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 also add `test` and `lint` commands to your `composer.json` file which you can use to run your tests and lint your code respectively. Finally, Alchemy will generate a `.github/workflows` directory with a `tests.yml` file and a `lint.yml` file which you can use to run your tests and linting on github actions.
79
-
80
93
## Configuring Tests
81
94
82
95
If you don't want to use Pest, Alchemy also supports PHPUnit. You can change the testing framework by editing the `alchemy.yml` file in your project root, add your tests to the `tests` directory, and run the test command again. You don't need to worry about setting up PHPUnit or Pest as Alchemy will handle that for you.
@@ -96,7 +109,8 @@ tests:
96
109
files:
97
110
- '*.test.php'
98
111
coverage:
99
-
processUncoveredFiles: true
112
+
local: false
113
+
actions: true
100
114
```
101
115
102
116
- `app`: This is a list of directories that contain your application code. Alchemy will use these directories to lint your code and also in code coverage reports. If you want to use the root directory, you can just remove the entire `app` section.
@@ -110,7 +124,7 @@ tests:
110
124
- `tests.files`: The files to look for tests in.
111
125
112
126
- `tests.coverage`: Configuration for code coverage.
113
-
- You can set `processUncoveredFiles` to `true` to process files that are not covered by tests.
127
+
- You can configure `local` to generate code coverage reports locally. By default, Alchemy will generate code coverage reports only on GitHub Actions.
114
128
- You can also set `include` to include specific directories in your code coverage report. By default Alchemy will just use the directories defined in the `app` configuration.
115
129
116
130
If you don't want code coverage reports, you can just remove the entire `coverage` section.
0 commit comments