Skip to content

Commit

Permalink
Add PHPUnit as a dev dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
brianlmoon committed Aug 20, 2018
1 parent 9b88c58 commit 8599805
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 3 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Test files
tests/tests-config.php
tests/report*
tests/run-tests.log
tests/run-tests.log

# Dependencies
vendor
composer.lock
12 changes: 10 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@
"issues": "https://github.com/brianlmoon/net_gearman/issues"
},
"require": {
"php": ">=5.6.0"
"php": "^7.0.0"
},
"autoload": {
"classmap": [ "Net/Gearman" ]
},
"autoload-dev": {
"psr-4": {
"Net\\Gearman\\Tests\\": "tests/"
}
},
"include-path": [
"."
]
],
"require-dev": {
"phpunit/phpunit": "^7.3"
}
}
19 changes: 19 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/bootstrap.php"
colors="true">
<testsuites>
<testsuite name="Main">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<groups>
<exclude>
<group>functional</group>
</exclude>
</groups>
<filter>
<whitelist>
<directory>./Net</directory>
</whitelist>
</filter>
</phpunit>
25 changes: 25 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

require __DIR__ . '/../vendor/autoload.php';

/**
* Function for helping debug tests since modern PHP Unit
* does not allow var_dump to send output to STDOUT.
*/
function _debug() {
$bt = debug_backtrace();
fwrite(STDERR, "\nSTART DEBUG\n");
foreach ($bt as $pos => $t) {
if (!isset($t["file"])) {
break;
}
fwrite(STDERR, "#$pos {$t["file"]} on line {$t["line"]}\n");
}
fwrite(STDERR, "###########\n");
$args = func_get_args();
foreach ($args as $arg) {
fwrite(STDERR, trim(var_export($arg, true))."\n");
}
fwrite(STDERR, "###########\n");
fwrite(STDERR, "END DEBUG\n\n");
}

0 comments on commit 8599805

Please sign in to comment.