2017 © Pedro PelĂĄez
 

library probedock-phpunit

PHPUnit probe to publish test results to Probe Dock.

image

probedock/probedock-phpunit

PHPUnit probe to publish test results to Probe Dock.

  • Friday, July 8, 2016
  • by AlphaHydrae
  • Repository
  • 2 Watchers
  • 0 Stars
  • 159 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

PHPUnit probe for Probe Dock

PHPUnit listener to publish test results to Probe Dock., (*1)

, (*2)

Setup

Add probedock-phpunit as a dependency in your composer.json file:, (*3)

{
  "name": "my/package",
  "require": {
    "probedock/probedock-phpunit": "^0.2.0"
  }
}

Then run php composer.phar update., (*4)

If you haven't done so already, set up your Probe Dock configuration file(s). This procedure is described here:, (*5)

You must then add the Probe Dock PHPUnit listener to your PHPUnit configuration file (e.g. phpunit.xml.dist). This is the listener you must add:, (*6)

<listener class="ProbeDock\ProbeDockPHPUnit\ProbeDockPHPUnitListener">
  <arguments>
  </arguments>
</listener>

Here's a complete sample of a phpunit.xml.dist configuration file from a Symfony project, showing where to add the listener (at the bottom):, (*7)




<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
         backupGlobals="false"
         colors="true"
         bootstrap="app/autoload.php">

  <php>
    <ini name="error_reporting" value="-1" />
    <server name="KERNEL_DIR" value="app/" />
  </php>

  <testsuites>
    <testsuite name="Project Test Suite">
      <directory>tests</directory>
    </testsuite>
  </testsuites>

  <filter>
    <whitelist>
      <directory>src</directory>
      <exclude>
        <directory>src/*Bundle/Resources</directory>
        <directory>src/*/*Bundle/Resources</directory>
        <directory>src/*/Bundle/*Bundle/Resources</directory>
      </exclude>
    </whitelist>
  </filter>

  <listeners>
    <listener class="ProbeDock\ProbeDockPHPUnit\ProbeDockPHPUnitListener">
      <arguments>
      </arguments>
    </listener>
  </listeners>
</phpunit>

All test results will now be published to Probe Dock the next time you run your test suite!, (*8)

, (*9)

Usage

To enrich tests with more information, you can use the @ProbeDock annotation:, (*10)

request('GET', '/');

    $this->assertEquals(200, $client->getResponse()->getStatusCode());
    $this->assertContains('Welcome to Symfony', $crawler->filter('#container h1')->text());
  }
}
```




### Troubleshooting




#### AnnotationException: the annotation was never imported

This library uses [Doctrine annotations](http://doctrine-orm.readthedocs.io/projects/doctrine-common/en/latest/reference/annotations.html)
so you can enrich tests with additional information such as tags.

If you are using other annotations, they may come into conflict with the Doctrine annotations library.
For example, this error may occur in a project where an `@expectedException` annotation was used in the tests:

```
Uncaught Doctrine\Common\Annotations\AnnotationException: [Semantical Error] The annotation "@expectedException" in method My\Class::testMethod() was never imported. Did you maybe forget to add a "use" statement for this annotation?
```

To solve this issue, you must add the annotations not known by Doctrine to its global ignore list.
The following code in your tests' bootstrap file will do the trick:

```php
namespace Doctrine\Common\Annotations {
  require __DIR__ . '/../vendor/autoload.php';
  use Doctrine\Common\Annotations\AnnotationReader;

  AnnotationReader::addGlobalIgnoredName('expectedException');
  // Repeat the line above to ignore other annotations...
}
```

If you do not already have a bootstrap file for your tests, you can create it and add its path to the `` tag in your `phpunit.xml.dist` configuration file:

```xml

<phpunit bootstrap="./tests/bootstrap.php" colors="true">
  
</phpunit>

Contributing

  • Fork
  • Create a topic branch - git checkout -b feature
  • Push to your branch - git push origin feature
  • Create a pull request from your branch

Please add a changelog entry with your name for new features and bug fixes., (*11)

Contributors

License

probedock-phpunit is licensed under the MIT License. See LICENSE.txt for the full text., (*12)

The Versions

08/07 2016