@@ -49,9 +49,16 @@ public function testSetCreator(): void
4949 */
5050 public function testSetCreated (null |int $ expectedCreationTime , null |int |string $ created ): void
5151 {
52- $ expectedCreationTime = $ expectedCreationTime ?? $ this ->startTime ;
53-
54- $ this ->properties ->setCreated ($ created );
52+ if ($ expectedCreationTime === null ) {
53+ do {
54+ // loop to avoid rare situation where timestamp changes
55+ $ expectedCreationTime = (float ) (new DateTime ())->format ('U ' );
56+ $ this ->properties ->setCreated ($ created );
57+ $ endTime = (float ) (new DateTime ())->format ('U ' );
58+ } while ($ expectedCreationTime !== $ endTime );
59+ } else {
60+ $ this ->properties ->setCreated ($ created );
61+ }
5562 self ::assertEquals ($ expectedCreationTime , $ this ->properties ->getCreated ());
5663 }
5764
@@ -78,9 +85,16 @@ public function testSetModifier(): void
7885 */
7986 public function testSetModified (mixed $ expectedModifiedTime , null |int |string $ modified ): void
8087 {
81- $ expectedModifiedTime = $ expectedModifiedTime ?? $ this ->startTime ;
82-
83- $ this ->properties ->setModified ($ modified );
88+ if ($ expectedModifiedTime === null ) {
89+ do {
90+ // loop to avoid rare situation where timestamp changes
91+ $ expectedModifiedTime = (float ) (new DateTime ())->format ('U ' );
92+ $ this ->properties ->setModified ($ modified );
93+ $ endTime = (float ) (new DateTime ())->format ('U ' );
94+ } while ($ expectedModifiedTime !== $ endTime );
95+ } else {
96+ $ this ->properties ->setModified ($ modified );
97+ }
8498 self ::assertEquals ($ expectedModifiedTime , $ this ->properties ->getModified ());
8599 }
86100
0 commit comments