Skip to content

Commit

Permalink
Fixed phpGH-8400: bug73837.phpt makes no sense
Browse files Browse the repository at this point in the history
Replaces the indeed silly test with something that actually does the job,
albeit much slower.
  • Loading branch information
derickr committed Apr 22, 2022
1 parent 1dc6dba commit c854bb2
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions ext/date/tests/bug73837.phpt
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
--TEST--
Bug #73837: Milliseconds in DateTime()
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
$collect = [];

for ( $i = 0; $i < 1000; $i++ )
{
$a = new DateTime();
$key = "s" . $a->format( "u" );
$collect[$key] = true;
$startTS = time();
$prev_dt = new DateTime();
while (time() < $startTS + 2) {
$dt = new DateTime();
if ($prev_dt > $dt) {
var_dump($prev_dt->format("Y-m-d H:i:s.u"));
var_dump($dt->format("Y-m-d H:i:s.u"));
break;
}
$prev_dt = $dt;
}

var_dump($n = count( $collect ));
echo ( $n > 700 ) ? "microseconds differ\n" : "microseconds do not differ enough ($n)\n";
echo "Finished\n";
?>
--EXPECTF--
int(%d)
microseconds differ
Finished

0 comments on commit c854bb2

Please sign in to comment.