diff --git a/.gitignore b/.gitignore index d05bc652011043c23a8b4ebbf68509a83a1f87c2..6d51f62f4f57da3c3cd74e6135108d91fdad7ce9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ composer.lock /vendor/ /vendor-bin/*/vendor/ .phpunit.result.cache +phpunit.xml \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..e8d922bdee6950426c2391c0a58090f9d2ba9eaf --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +tests: vendor phpunit.xml + vendor/bin/phpunit --colors + +phpunit.xml: + php bin/configure.php + +vendor: composer.json + composer update + touch $@ \ No newline at end of file diff --git a/bin/configure.php b/bin/configure.php new file mode 100755 index 0000000000000000000000000000000000000000..fb1d3543d5b0c6399807fcc5e4b01be66562a1b3 --- /dev/null +++ b/bin/configure.php @@ -0,0 +1,42 @@ +#!/usr/bin/env php +<?php + +// les args a passer a phpUnit +$args = $argv; +array_shift($args); + +$dir_tests = dirname(__DIR__) . '/'; +// charger SPIP +require_once $dir_tests . 'tests/spip.inc'; + +// Lister les repertoires du path qui contiennent des dossier tests/ avec des tests PHPUnit + +$dirs = []; +foreach (creer_chemin() as $d) { + if ($d and + is_dir("${d}tests") + and count(glob("${d}tests/*Test.php")) + ) { + $bases[] = "${d}tests"; + } +} + +$prefixe_dir = '../'; +while (!is_dir($dir_tests . $prefixe_dir . 'ecrire')) { + $prefixe_dir .= '../'; +} + +$testsuites = []; +foreach ($bases as $base) { + $name = dirname($base); + $testsuites[] = "<testsuite name=\"$name\"><directory>{$prefixe_dir}{$base}/</directory></testsuite>"; +} + +$testsuites = "\t\t" . implode("\n\t\t", $testsuites) . "\n"; + +// generer le phpunit.xml a jour +$config = file_get_contents($dir_tests . 'phpunit.xml.dist'); +$p = strpos($config, "\t</testsuites>"); +$config = substr_replace($config, $testsuites, $p, 0); + +file_put_contents($dir_tests . "phpunit.xml", $config); diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100755 index 0000000000000000000000000000000000000000..31327c7f7f326170d076e9dd20a7d53b392bbb07 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<phpunit bootstrap="./tests/spip.inc" + colors="true" + convertErrorsToExceptions="true" + convertNoticesToExceptions="true" + convertWarningsToExceptions="true" + stopOnFailure="false"> + <testsuites> + <testsuite name="core"><directory>./tests/</directory></testsuite> + </testsuites> +</phpunit>