- Notifications
You must be signed in to change notification settings - Fork1
PHPUnit for PeachPie projects
License
peachpiecompiler/phpunit-testadapter
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This project implements .NET Test Adapter for PeachPie projects containing PHPUnit tests.
PeachPie projects are PHP projects compiled into .NET usingPeachPie. It allows to run the PHP code as a regular .NET language, on top of .NET runtime.Test Adapter is an integration of unit tests into the .NET work flow. You may know it as Visual Studio's Test Explorer or the command line utilitydotnet test.
This all together allows torun, debug, and profile PHPUnit tests on top of .NET runtime, inside the Visual Studio or using other .NET build tools or continuous integration services.
The test project will be a .NET executable application (e.g. TargetFrameworknet5.0), compiling the test files (e.g.tests/**.php), and referencing the actual PeachPie/PHP application.
lib.msbuildproj:
<ProjectSdk="Peachpie.NET.Sdk/1.0.5-preview7"> <PropertyGroup> <TargetFramework>net5.0</TargetFramework> </PropertyGroup> <ItemGroup> <CompileInclude="**/*.php" /> <PackageReferenceInclude="Microsoft.NET.Test.Sdk"Version="16.6.1" /> <PackageReferenceInclude="PHPUnit.TestAdapter"Version="9.2.6-preview7" /> </ItemGroup></Project>
- src - Email.php- tests - EmailTest.php- phpunit.xml- lib.msbuildprojIn Visual Studio:
Open the project in Visual Studio. Navigate to Test / Test Explorer, and continue by running or debugging the discovered tests.
On command line:
dotnettest
src/PHPUnit.TestAdapter- The test adapter for VSTest enabling to run PHPUnit tests fromdotnet testand Test Explorer in Microsoft Visual Studio. The project references PHPUnit package, and utilizes its API to drive tests discovery and tests execution.src/phpunit.phpunit.phar-PHPUnit compiled with Peachpie to a .NET Standard assembly. The filephpunit.phargets downloaded automatically.src/dotnet-phpunit- An optional command line tooldotnet phpunitthat runsPHPUnit on a PeachPie project.
The test adapter can be tested on the following sample:
samples/Lib- A simple .NET/PHP application with PHPUnit tests.
To run them from the command line, navigate tosamples/Lib and run:
dotnettestThe output should be similar to this one (possibly preceeded by the build log):
Test run for samples\Lib\bin\Debug\netcoreapp3.1\Lib.dll(.NETCoreApp,Version=v3.1)Microsoft (R) Test Execution Command Line Tool Version 16.6.0Copyright (c) Microsoft Corporation. All rights reserved.Starting test execution, please wait...A total of 1 test files matched the specified pattern.Test Run Successful.Total tests: 3 Passed: 3 Total time: 4.2106 SecondsYou can also open either of these projects in Microsoft Visual Studio and use theTest Explorer window to inspect the existing tests, run, debug, and profile them.
To testdotnet-phpunit onsamples/Lib (which referencesphpunit.phpunit.phar as a project), just run it using the default launch settings.
To test it, run the following commands in the directorysamples/Lib:
dotnet tool install --global dotnet-phpunitdotnet builddotnet phpunit
Both variants should run PHPUnit with the output similar to this one:
Runner of PHPUnit (© Sebastian Bergmann) on PHP assemblies compiled by PeachpieBuilding "samples\Lib\Lib.msbuildproj"...Opening assembly "samples\Lib\obj\Debug\netstandard2.0\Lib.dll"...Assembly loadedPHPUnit 9.2.6 by Sebastian Bergmann and contributors.... 3 / 3 (100%)Time: 00:00.696, Memory: 39.29 KBOK (3 tests, 3 assertions)To explicitly disable building of the project (as it's already built), pass the--no-build option todotnet phunit, e.g.:
dotnet phpunit --no-build
If you wish to removedotnet-phpunit from the set of installed tools, run:
dotnet tool uninstall --global dotnet-phpunit
About
PHPUnit for PeachPie projects
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.
