diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 000000000..1fb3e8592 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,2 @@ +*.phar +.phpunit.result.cache diff --git a/tests/README.md b/tests/README.md index 7aa410c2f..cd1227047 100644 --- a/tests/README.md +++ b/tests/README.md @@ -5,13 +5,17 @@ The `compile_test.sh` shell script just verifies all PHP files compile successfully. Please use this before pushing any commits upstream. Any other files should be PHP unit tests based on -[PHPUnit](https://phpunit.de/index.html) version 5.7, -which is the latest version that supports PHP 5.X. (The newer version of -PHPUnit requires PHP7.) +[PHPUnit](https://phpunit.de/index.html) version 8.0 +which requires PHP 7.2. + +Download a copy of phpunit-8.0 and place the phar file in your tools +directory: + + wget https://phar.phpunit.de/phpunit-8.0.phar Example usage for a single file: - phpunit --bootstrap ../includes/functions.php functionsTest.php + php phpunit-8.0.phar --bootstrap ../includes/functions.php functionsTest.php diff --git a/tests/functionsTest.php b/tests/functionsTest.php index 8f03d9453..49561099e 100644 --- a/tests/functionsTest.php +++ b/tests/functionsTest.php @@ -25,7 +25,19 @@ public function test_activate_urls() { } public function test_add_dstfree_time() { - // TODO + // 03/09/2019 @ 12:00pm (UTC) = day before DST starts + // adding 1 day should be 23 hours diff + $time = 1552132800; + $res = add_dstfree_time ( $time, 86400 ); + $diff = $res - $time; + $hours = $diff / 3600; + $this->assertEquals ( 23, $hours ); + // add another day and we should get 24 hours + $time += 3600 * 24; + $res = add_dstfree_time ( $time, 86400 ); + $diff = $res - $time; + $hours = $diff / 3600; + $this->assertEquals ( 24, $hours ); } public function test_add_duration() { diff --git a/tests/run_unit_tests.sh b/tests/run_unit_tests.sh index 15e809189..bad0046a7 100755 --- a/tests/run_unit_tests.sh +++ b/tests/run_unit_tests.sh @@ -2,6 +2,6 @@ # # Please add new unit test files below. -phpunit --bootstrap ../includes/functions.php functionsTest.php +php phpunit-8.0.phar --bootstrap ../includes/functions.php functionsTest.php exit 0