PHPUnit for PeachPie projects
Перейти к файлу
Robert Husák 148b676365 Clean up dotnet-phpunit 2020-08-14 14:04:11 +02:00
nupkg Add nupkg directory to repo 2020-07-10 15:50:28 +02:00
samples Add sketch of adapter for dotnet test 2020-08-06 16:45:29 +02:00
src Clean up dotnet-phpunit 2020-08-14 14:04:11 +02:00
.gitignore Initial commit 2020-06-17 17:28:54 +02:00
Directory.Build.props Enable dynamic PHPUnit downloading of given version 2020-07-09 18:15:08 +02:00
LICENSE Add repository license 2020-06-22 19:11:19 +02:00
PeachpiePhpUnit.sln Add sketch of adapter for dotnet test 2020-08-06 16:45:29 +02:00
README.md Enable automatic project building and assembly lookup 2020-06-22 12:51:27 +02:00
global.json Update Peachpie to 0.9.990 2020-06-22 20:09:22 +02:00

README.md

PHPUnit for Peachpie

This repository contains the following NuGet packages:

  • Peachpied.PhpUnit - PHPUnit compiled by Peachpie to a .NET Standard assembly, to be referenced by projects containing tests.
  • dotnet-phpunit - A command line tool dotnet phpunit to enable running PHPUnit on Peachpie projects.

How to run the samples

At first, compile the solution by running this command in the repository root:

dotnet build

This will create the NuGet packages in the nugs folder and compile samples/Lib. To test dotnet-phpunit on samples/Lib (which references Peachpied.PhpUnit as a project), just run it using the default launch settings, as they already contain all the necessary arguments.

The second sample, LibNuget, references Peachpied.PhpUnit as a NuGet package. To test it, run the following commands in the directory samples/LibNuget:

dotnet tool install --global dotnet-phpunit
dotnet build
dotnet phpunit --bootstrap src/Email.php tests/EmailTest.php

It should run PHPUnit with the output similar to this one:

Runner of PHPUnit (© Sebastian Bergmann) on PHP assemblies compiled by Peachpie

Building "C:\repos\peachpie-phpunit\samples\LibNuget\LibNuget.msbuildproj"...
Opening assembly "C:\repos\peachpie-phpunit\samples\LibNuget\obj\Debug\netstandard2.0\LibNuget.dll"...
Assembly loaded

PHPUnit 9.2.3 by Sebastian Bergmann and contributors.

...                                                                 3 / 3 (100%)

Time: 00:00.696, Memory: 39.29 KB

OK (3 tests, 3 assertions)

To explicitly disable building of the project (as it's already built), pass the --no-build option to dotnet phunit, e.g.:

dotnet phpunit --no-build --bootstrap src/Email.php tests/EmailTest.php

If you wish to remove dotnet-phpunit from the set of installed tools, run:

dotnet tool uninstall --global dotnet-phpunit