Skip to content

Commit

Permalink
test: add unit test for getFormattedTimeDiff() in SingleEventData
Browse files Browse the repository at this point in the history
  • Loading branch information
thorbrink committed Dec 18, 2024
1 parent 04e452b commit 2ac92da
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/phpunit/tests/Helper/SingleEventData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace EventManagerIntegration\tests\Helper;

use EventManagerIntegration\Helper\SingleEventData;
use WP_Mock\Tools\TestCase;

class SingleEventDataTest extends TestCase {

/**
* @testdox getFormattedTimeDiff() should return the formatted time difference between two timestamps without rounding minutes.
*/
public function testGetFormattedTimeDiff() {
define('DAY_IN_SECONDS', 86400);
define('HOUR_IN_SECONDS', 3600);
define('MINUTE_IN_SECONDS', 60);

$start = strtotime('2021-01-01 12:00:00');
$end = strtotime('2021-01-01 13:31:30');
$this->assertEquals('1 hour 31 mins', SingleEventData::getFormattedTimeDiff($start, $end));
}
}

0 comments on commit 2ac92da

Please sign in to comment.