Example #1
0
 public function testHitHashAndTime()
 {
     /*//
     	test that the hit hashing stuff is working from web requests.
     	//*/
     $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     $r1 = new Nether\Avenue\Router(static::$RequestData['Root']);
     $r2 = new Nether\Avenue\Router(static::$RequestData['Test']);
     (new Verify('verify that GetHitHash() returned a hashy looking thing.', strlen($r1->GetHitHash())))->equals(32);
     (new Verify('verify that r1 and r2 GetHitHash() do not match.', $r1->GetHitHash() === $r2->GetHitHash()))->false();
     (new Verify('verify GetHitTime() returned a float', is_float($r1->GetHitTime())))->true();
     // it is actually plausable that a machine could be so fast that r1 and
     // r2 register at the exact same microsecond. if you are seeing a failed
     // test for r1 and r2 hit times matching, put a sleep(0.01) or something
     // between them. i am not doing that now intentionally to see how long
     // it takes for it to happen.
     // if they do end up matching, that is not a failure of the libarary.
     // in fact, that is a success. it means that two hits happend so fast
     // that you should ignore one of them because seriously, stop spamming
     // my server.
     // i don't expect this to happen until we have warp capabilities anyway.
     // at which point microtime is probably going to naturally be further
     // down the decimal point hole anyway.
     // it sure as f**k isn't going to happen on travis-ci.
     (new Verify('verify that r1 and r2 GetHitTime()s do not match.', $r1->GetHitTime() === $r2->GetHitTime()))->false();
     $h1 = $r1->GetHit();
     (new Verify('verify that GetHit() returned data matching GetHitHash().', $h1->Hash))->equals($r1->GetHitHash());
     (new Verify('verify that GetHit() returned data matching GetHitTime().', $h1->Time))->equals($r1->GetHitTime());
     return;
 }