From a437f8e62ab62b6d206a2ac4ca8bd4632a7c3d60 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Thu, 27 Feb 2014 10:00:41 +0000 Subject: [PATCH] Adding PHPUnit tests git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1208 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- Tests/.htaccess | 1 + Tests/TESTS | 12 ++++++++++++ Tests/autoload.php | 6 ++++++ Tests/test_outputjson.php | 24 ++++++++++++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 Tests/.htaccess create mode 100755 Tests/TESTS create mode 100644 Tests/autoload.php create mode 100644 Tests/test_outputjson.php diff --git a/Tests/.htaccess b/Tests/.htaccess new file mode 100644 index 0000000..8d2f256 --- /dev/null +++ b/Tests/.htaccess @@ -0,0 +1 @@ +deny from all diff --git a/Tests/TESTS b/Tests/TESTS new file mode 100755 index 0000000..6957b34 --- /dev/null +++ b/Tests/TESTS @@ -0,0 +1,12 @@ +#!/bin/bash +#To run the tests, you need "phpunit" software. +# All the documentation is here : +# phpunit.de/manual/current/en/writing-tests-for-phpunit.html + +#From the root dir of the project, run the tests like : +cd `dirname $0`/.. +phpunit --bootstrap Tests/autoload.php Tests/test* + +# You can run specific test with : +# cd `dirname $0`/.. +# phpunit --bootstrap Tests/autoload.php Tests/testXXXXXXX.php diff --git a/Tests/autoload.php b/Tests/autoload.php new file mode 100644 index 0000000..3ed1e23 --- /dev/null +++ b/Tests/autoload.php @@ -0,0 +1,6 @@ +expectOutputString("\"\""); + $output = new outputjson (); + $output->out (""); + } + + public function testoutputjson2 () + { + $this->expectOutputString("\"string\""); + $output = new outputjson (); + $output->out ("string"); + } + + public function testoutputjson3 () + { + $this->expectOutputString("[1,2,3]"); + $output = new outputjson (); + $output->out (array (1,2,3)); + } +}