PHPUnit packaging checks how PHAR archive?

Is it possible to pack PHPUnit tests as PHAR and run them with phpunit?

I created php followed by a script:

<?php $cPhar = new Phar('mytests-archive.phar', 0); $cPhar->addFile('mytest.php'); $sStub = <<<ENDSTUB #! /usr/bin/php <?php Phar::mapPhar('mytest-archive.phar'); require 'phar://mytests-archive.phar/mytest.php'; __HALT_COMPILER(); ENDSTUB; $cPhar->setStub($sStub); $cPhar->compressFiles(Phar::GZ); $cPhar->stopBuffering(); ?> 

But when I try to run the resulting archive as follows:

 phpunit mytests-archive.phar 

I get an error message:

 #! /usr/bin/php PHPUnit 3.3.17 by Sebastian Bergmann. Class MyTestClass could not be found in /path/to/mytests-archive.phar 

Does PHPUnit support PHAR files, or did I skip a step in my build script? (This is my first attempt to use PHAR)

+4
source share
1 answer

I do not think PHPUnit understands the tests that are in the PHAR archive. PHPUnit does not just interpret the transferred file and run the tests; he reads the source code of the test and runs it. Therefore, when he searches for the source of MyTestClass, he cannot find it because it is wrapped inside the archive.

+2
source

Source: https://habr.com/ru/post/1307791/


All Articles