Skip to content
Permalink
Browse files

Updated unit tests for use with phpunit-8.0

  • Loading branch information...
craigk5n committed Mar 15, 2019
1 parent 6e5ec5d commit 667bfb32c9f1865b72c7082762e120bf4cf9a2fa
Showing with 24 additions and 6 deletions.
  1. +2 −0 tests/.gitignore
  2. +8 −4 tests/README.md
  3. +13 −1 tests/functionsTest.php
  4. +1 −1 tests/run_unit_tests.sh
@@ -0,0 +1,2 @@
*.phar
.phpunit.result.cache
@@ -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



@@ -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() {
@@ -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

0 comments on commit 667bfb3

Please sign in to comment.
You can’t perform that action at this time.