@@ -54,7 +54,7 @@ class StructuresTest extends TestCase
5454 * How many iterations do for each date/time test
5555 * @var int
5656 */
57- public static $ iterations = 10 ;
57+ public static $ iterations = 50 ;
5858
5959 public function testInit (): AProtocol
6060 {
@@ -111,7 +111,7 @@ public function testDate(int $timestamp, AProtocol $protocol)
111111 public function testDateTime (int $ timestamp , string $ timezone , AProtocol $ protocol )
112112 {
113113 try {
114- $ timestamp = bcadd ( $ timestamp , sprintf ( ' %.6f ' , fmod ( microtime ( true ), 1 )), 6 );
114+ $ timestamp .= ' . ' . rand ( 0 , 9e5 );
115115 $ datetime = \DateTime::createFromFormat ('U.u ' , $ timestamp , new \DateTimeZone ($ timezone ))
116116 ->format ('Y-m-d\TH:i:s.uP ' );
117117
@@ -143,7 +143,7 @@ public function testDateTime(int $timestamp, string $timezone, AProtocol $protoc
143143 public function testDateTimeZoneId (int $ timestamp , string $ timezone , AProtocol $ protocol )
144144 {
145145 try {
146- $ timestamp = bcadd ( $ timestamp , sprintf ( ' %.6f ' , fmod ( microtime ( true ), 1 )), 6 );
146+ $ timestamp .= ' . ' . rand ( 0 , 9e5 );
147147 $ datetime = \DateTime::createFromFormat ('U.u ' , $ timestamp , new \DateTimeZone ($ timezone ))
148148 ->format ('Y-m-d\TH:i:s.u ' ) . '[ ' . $ timezone . '] ' ;
149149
@@ -214,7 +214,7 @@ public function testDuration(AProtocol $protocol)
214214 public function testLocalDateTime (int $ timestamp , AProtocol $ protocol )
215215 {
216216 try {
217- $ timestamp = bcadd ( $ timestamp , sprintf ( ' %.6f ' , fmod ( microtime ( true ), 1 )), 6 );
217+ $ timestamp .= ' . ' . rand ( 0 , 9e5 );
218218 $ datetime = \DateTime::createFromFormat ('U.u ' , $ timestamp )
219219 ->format ('Y-m-d\TH:i:s.u ' );
220220
@@ -245,7 +245,7 @@ public function testLocalDateTime(int $timestamp, AProtocol $protocol)
245245 public function testLocalTime (int $ timestamp , AProtocol $ protocol )
246246 {
247247 try {
248- $ timestamp = bcadd ( $ timestamp , sprintf ( ' %.6f ' , fmod ( microtime ( true ), 1 )), 6 );
248+ $ timestamp .= ' . ' . rand ( 0 , 9e5 );
249249 $ time = \DateTime::createFromFormat ('U.u ' , $ timestamp )
250250 ->format ('H:i:s.u ' );
251251
@@ -386,7 +386,7 @@ public function testRelationship(AProtocol $protocol)
386386 public function testTime (int $ timestamp , string $ timezone , AProtocol $ protocol )
387387 {
388388 try {
389- $ timestamp = bcadd ( $ timestamp , sprintf ( ' %.6f ' , fmod ( microtime ( true ), 1 )), 6 );
389+ $ timestamp .= ' . ' . rand ( 0 , 9e5 );
390390 $ time = \DateTime::createFromFormat ('U.u ' , $ timestamp , new \DateTimeZone ($ timezone ))
391391 ->format ('H:i:s.uP ' );
392392
@@ -436,8 +436,8 @@ private function randomTimestamp(string $timezone = '+0000'): int
436436 {
437437 try {
438438 $ zone = new \DateTimeZone ($ timezone );
439- $ start = new \DateTime (' -3 years ' , $ zone );
440- $ end = new \DateTime (' +3 years ' , $ zone );
439+ $ start = new \DateTime (date ( ' Y-m-d H:i:s ' , strtotime ( ' -10 years ', 0 )) , $ zone );
440+ $ end = new \DateTime (date ( ' Y-m-d H:i:s ' , strtotime ( ' +10 years ', 0 )) , $ zone );
441441 return rand ($ start ->getTimestamp (), $ end ->getTimestamp ());
442442 } catch (Exception $ e ) {
443443 return strtotime ('now ' . $ timezone );
0 commit comments