Download the PHP package vasek-purchart/phing-tester without Composer

On this page you can find all versions of the php package vasek-purchart/phing-tester. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package phing-tester

Phing Tester

Phing is a build system which you can extend by writing PHP code. This is really useful, especially for PHP projects so that you do not need any additional technologies and can potentially reuse existing code. But when you are writing such extensions, you should also test them. And because the nature of the build system is printing output, manipulating files and other "system" stuff, then writing isolated tests becomes an issue. Phing Tester should help with this task by providing a way to run Phing targets from PHPUnit tests as if they were run from the command line itself.

Usage

With Phing Tester you can write a XML buildfile as usual with Phing and then run its targets from PHP code:

Testing output

In the example above the target lorem-ipsum is executed in the context of the buildfile and then you can check whatever the target was supposed to achieve, in this case it should print out a message. For testing purposes it would be problematic if the actual output would be printed out, so there are Phing Tester method for output checking such as:

assertLogMessage searches all log messages if any contains the given string. You can also search for log messages using regexp. It is handy to refine the results by specifying target which should produce the message and/or its priority.

Testing errors

If the build fails a \BuildException is thrown as usual in Phing. If you only want to test the exception and its message you can use standard PHPUnits tools:

But if you want to also check the state after the target execution, this is not enough since the code in the test is interrupted by the exception. If you want to do that, use expectFailedBuild instead of executeTarget and you can continue with asserts:

If you need to check the thrown exception thoroughly, you can pass a callback to expectFailedBuild and you will get the exception as parameter:

Testing properties

When writing Phing tests you might want to check the state of some properties or use them for writing other assertions:

Convention

There is no enforced convention for using this tool, you can use it in tests however you feel right, but this approach works for me in terms of readability the most:

1) Match one TestCase with one buildfile. 2) Targets in the buildfile represent individual tests and their name matches (if there is no need to reuse the targets or use more targets for one test). 3) When asserting log output, try to be more specific - use target name and output priority to minimalize false positives/negatives.

The pair can then look something like:

Installation

1) Install package vasek-purchart/phing-tester with Composer:

2) Add Phing initialization to your tests bootstrap file (example in this repo):


All versions of phing-tester with dependencies

PHP Build Version
Package Version
Requires php Version ~7.2
phing/phing Version ^2.16.3
phpunit/phpunit Version ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package vasek-purchart/phing-tester contains the following files

Loading the files please wait ...