Skip to content

Commit

Permalink
Updated unit tests for use with phpunit-8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
craigk5n committed Mar 15, 2019
1 parent 6e5ec5d commit 667bfb3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
2 changes: 2 additions & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.phar
.phpunit.result.cache
12 changes: 8 additions & 4 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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



14 changes: 13 additions & 1 deletion tests/functionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion tests/run_unit_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.