Skip to content

Commit

Permalink
Added phpunit code coverage support.
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaChriz committed Sep 26, 2018
1 parent 09c159c commit 5950900
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
coverage
33 changes: 33 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="tests/bootstrap.php" colors="true">
<php>
<!-- Set error reporting to E_ALL. -->
<ini name="error_reporting" value="32767"/>
<!-- Do not limit the amount of memory tests take to run. -->
<ini name="memory_limit" value="-1"/>
</php>
<testsuites>
<testsuite name="Addressfield lookup Unit Test Suite">
<directory>./tests/src/Unit</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="\Drupal\Tests\Listeners\DrupalListener">
</listener>
</listeners>
<!-- Filter for coverage reports. -->
<filter>
<whitelist>
<directory>./src</directory>
<!-- By definition test classes have no tests. -->
<exclude>
<directory suffix="Test.php">./</directory>
<directory suffix="TestBase.php">./</directory>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="coverage" showUncoveredFiles="true"/>
</logging>
</phpunit>
27 changes: 27 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/**
* @file
* Searches for the core bootstrap file.
*/

$dir = __DIR__;

// Match against previous dir for Windows.
$previous_dir = '';

while ($dir = dirname($dir)) {
// We've reached the root.
if ($dir === $previous_dir) {
break;
}

$previous_dir = $dir;

if (is_file($dir . '/core/tests/bootstrap.php')) {
require_once $dir . '/core/tests/bootstrap.php';
return;
}
}

throw new RuntimeException('Unable to load core bootstrap.php.');

0 comments on commit 5950900

Please sign in to comment.