phingofficial / task-phpunit Goto Github PK
View Code? Open in Web Editor NEW[READ-ONLY] PHPUnit task
[READ-ONLY] PHPUnit task
Describe the bug
I have been trying to set up a phpunit task in my build.xml. I have had been trying to use the pharlocation attribute as documented here: https://www.phing.info/guide/chunkhtml/PHPUnitTask.html. But my tests are never ran.
I've downloded the phing-3.0.0-RC3.phar from the releases github page. After extracting that, directly invoking it, and debugging through the code, it seems that the 3.0.0 phar has its own bundled phpunit. So when the pharlocation attribute is set on the phpunit task, it blows up (silently) since phpunit is already loaded. I changed this block of code to see the issue:
Original:
private function loadPHPUnit()
{
if (!empty($this->pharLocation)) {
$GLOBALS['_SERVER']['SCRIPT_NAME'] = '-';
ob_start();
@include $this->pharLocation;
ob_end_clean();
}
Changed to show errors:
private function loadPHPUnit()
{
if (!empty($this->pharLocation)) {
$GLOBALS['_SERVER']['SCRIPT_NAME'] = '-';
//ob_start();
include $this->pharLocation;
//ob_end_clean();
}
Steps To Reproduce
Create a simple build.xml file to run phpunit tests:
<target name="test" description="runs phpunit unit tests" depends="set.props.main.test,enforce.build.dirs,genautoload">
<echo msg="${phpunit.location}" />
<echo msg="buildDir: ${build.dir}" />
<phpunit bootstrap="${build.dir}/bootstraptests.php" pharLocation="${phpunit.location}" printsummary="true" haltonfailure="true" haltonerror="true">
<formatter type="plain" usefile="false"/>
<batchtest>
<fileset dir="${build.dir}">
<include name="**/*Test.php"/>
</fileset>
</batchtest>
</phpunit>
</target>
Expected behavior
PHPUnit test cases are run.
Screenshots / terminal output
This is the output after making my above changes to see the errors:
[echo] /home/pi/files/utils/php/phpunit.phar
[echo] buildDir: /var/www/html/checkHookPlugin/build-test
#!/usr/bin/env php
PHP Fatal error: Cannot declare class PHPUnit\Framework\Constraint\Constraint, because the name is already in use in phar:///home/pi/files/utils/php/phpunit.phar/phpunit/Framework/Constraint/Constraint.php on line 23
Additional context
After removing the pharlocation attribute in my build.xml, the tests run as expected.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.