From c175abaf77716946df935a7af2362210f5fcd88e Mon Sep 17 00:00:00 2001 From: El RIDO Date: Wed, 6 Jul 2016 09:01:10 +0200 Subject: [PATCH] improvements to get the HHVM build to pass --- tst/bootstrap.php | 3 ++- tst/trafficlimiter.php | 4 ++-- tst/zerobin.php | 8 ++++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tst/bootstrap.php b/tst/bootstrap.php index 5585e79..f1ba046 100644 --- a/tst/bootstrap.php +++ b/tst/bootstrap.php @@ -1,5 +1,6 @@ assertTrue(trafficlimiter::canPass(), 'first request may pass'); - sleep(2); + sleep(1); $this->assertFalse(trafficlimiter::canPass(), 'second request is to fast, may not pass'); - sleep(3); + sleep(4); $this->assertTrue(trafficlimiter::canPass(), 'third request waited long enough and may pass'); $_SERVER['REMOTE_ADDR'] = '2001:1620:2057:dead:beef::cafe:babe'; $this->assertTrue(trafficlimiter::canPass(), 'fourth request has different ip and may pass'); diff --git a/tst/zerobin.php b/tst/zerobin.php index 8b865fd..9b5af64 100644 --- a/tst/zerobin.php +++ b/tst/zerobin.php @@ -124,7 +124,9 @@ class zerobinTest extends PHPUnit_Framework_TestCase $file = PATH . $dir . DIRECTORY_SEPARATOR . '.htaccess'; @unlink($file); } + ob_start(); new zerobin; + ob_end_clean(); foreach ($dirs as $dir) { $file = PATH . $dir . DIRECTORY_SEPARATOR . '.htaccess'; $this->assertFileExists( @@ -145,7 +147,7 @@ class zerobinTest extends PHPUnit_Framework_TestCase file_put_contents(CONF, ''); ob_start(); new zerobin; - $content = ob_get_contents(); + ob_end_clean(); } /** @@ -185,6 +187,7 @@ class zerobinTest extends PHPUnit_Framework_TestCase $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest'; $_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['REMOTE_ADDR'] = '::1'; + trafficlimiter::setLimit(30); trafficlimiter::canPass(); ob_start(); new zerobin; @@ -312,6 +315,7 @@ class zerobinTest extends PHPUnit_Framework_TestCase $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest'; $_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['REMOTE_ADDR'] = '::1'; + $time = time(); ob_start(); new zerobin; $content = ob_get_contents(); @@ -324,7 +328,7 @@ class zerobinTest extends PHPUnit_Framework_TestCase ); $this->assertTrue($this->_model->exists($response['id']), 'paste exists after posting data'); $paste = $this->_model->read($response['id']); - $this->assertEquals(time() + 300, $paste->meta->expire_date, 'time is set correctly'); + $this->assertEquals($time + 300, $paste->meta->expire_date, 'time is set correctly'); $this->assertEquals(1, $paste->meta->opendiscussion, 'time is set correctly'); }