assertSame(0, Grpc\Timeval::compare($zero, $zero)); } public function testPastIsLessThanZero() { $zero = Grpc\Timeval::zero(); $past = Grpc\Timeval::infPast(); $this->assertLessThan(0, Grpc\Timeval::compare($past, $zero)); $this->assertGreaterThan(0, Grpc\Timeval::compare($zero, $past)); } public function testFutureIsGreaterThanZero() { $zero = Grpc\Timeval::zero(); $future = Grpc\Timeval::infFuture(); $this->assertLessThan(0, Grpc\Timeval::compare($zero, $future)); $this->assertGreaterThan(0, Grpc\Timeval::compare($future, $zero)); } /** * @depends testFutureIsGreaterThanZero */ public function testNowIsBetweenZeroAndFuture() { $zero = Grpc\Timeval::zero(); $future = Grpc\Timeval::infFuture(); $now = Grpc\Timeval::now(); $this->assertLessThan(0, Grpc\Timeval::compare($zero, $now)); $this->assertLessThan(0, Grpc\Timeval::compare($now, $future)); } public function testNowAndAdd() { $now = Grpc\Timeval::now(); $delta = new Grpc\Timeval(1000); $deadline = $now->add($delta); $this->assertGreaterThan(0, Grpc\Timeval::compare($deadline, $now)); } public function testNowAndSubtract() { $now = Grpc\Timeval::now(); $delta = new Grpc\Timeval(1000); $deadline = $now->subtract($delta); $this->assertLessThan(0, Grpc\Timeval::compare($deadline, $now)); } public function testAddAndSubtract() { $now = Grpc\Timeval::now(); $delta = new Grpc\Timeval(1000); $deadline = $now->add($delta); $back_to_now = $deadline->subtract($delta); $this->assertSame(0, Grpc\Timeval::compare($back_to_now, $now)); } }