Laravel 5.6 updates
Travis config update Removed HHVM script as Laravel no longer support HHVM after releasing 5.3
This commit is contained in:
133
vendor/phpunit/php-timer/tests/TimerTest.php
vendored
133
vendor/phpunit/php-timer/tests/TimerTest.php
vendored
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_Timer package.
|
||||
* This file is part of phpunit/php-timer.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
@@ -8,91 +8,114 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Timer;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PHP_TimerTest extends TestCase
|
||||
/**
|
||||
* @covers \SebastianBergmann\Timer\Timer
|
||||
*/
|
||||
class TimerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers PHP_Timer::start
|
||||
* @covers PHP_Timer::stop
|
||||
*/
|
||||
public function testStartStop()
|
||||
public function testStartStop(): void
|
||||
{
|
||||
$this->assertInternalType('float', PHP_Timer::stop());
|
||||
$this->assertInternalType('float', Timer::stop());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Timer::secondsToTimeString
|
||||
* @dataProvider secondsProvider
|
||||
*/
|
||||
public function testSecondsToTimeString($string, $seconds)
|
||||
public function testSecondsToTimeString(string $string, string $seconds): void
|
||||
{
|
||||
$this->assertEquals(
|
||||
$string,
|
||||
PHP_Timer::secondsToTimeString($seconds)
|
||||
Timer::secondsToTimeString($seconds)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Timer::timeSinceStartOfRequest
|
||||
*/
|
||||
public function testTimeSinceStartOfRequest()
|
||||
public function testTimeSinceStartOfRequest(): void
|
||||
{
|
||||
$this->assertStringMatchesFormat(
|
||||
'%f %s',
|
||||
PHP_Timer::timeSinceStartOfRequest()
|
||||
Timer::timeSinceStartOfRequest()
|
||||
);
|
||||
}
|
||||
|
||||
public function testTimeSinceStartOfRequest2(): void
|
||||
{
|
||||
if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {
|
||||
unset($_SERVER['REQUEST_TIME_FLOAT']);
|
||||
}
|
||||
|
||||
$this->assertStringMatchesFormat(
|
||||
'%f %s',
|
||||
Timer::timeSinceStartOfRequest()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Timer::resourceUsage
|
||||
* @backupGlobals enabled
|
||||
*/
|
||||
public function testResourceUsage()
|
||||
public function testTimeSinceStartOfRequest3(): void
|
||||
{
|
||||
if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {
|
||||
unset($_SERVER['REQUEST_TIME_FLOAT']);
|
||||
}
|
||||
|
||||
if (isset($_SERVER['REQUEST_TIME'])) {
|
||||
unset($_SERVER['REQUEST_TIME']);
|
||||
}
|
||||
|
||||
$this->expectException(RuntimeException::class);
|
||||
|
||||
Timer::timeSinceStartOfRequest();
|
||||
}
|
||||
|
||||
public function testResourceUsage(): void
|
||||
{
|
||||
$this->assertStringMatchesFormat(
|
||||
'Time: %s, Memory: %fMB',
|
||||
PHP_Timer::resourceUsage()
|
||||
Timer::resourceUsage()
|
||||
);
|
||||
}
|
||||
|
||||
public function secondsProvider()
|
||||
{
|
||||
return array(
|
||||
array('0 ms', 0),
|
||||
array('1 ms', .001),
|
||||
array('10 ms', .01),
|
||||
array('100 ms', .1),
|
||||
array('999 ms', .999),
|
||||
array('1 second', .9999),
|
||||
array('1 second', 1),
|
||||
array('2 seconds', 2),
|
||||
array('59.9 seconds', 59.9),
|
||||
array('59.99 seconds', 59.99),
|
||||
array('59.99 seconds', 59.999),
|
||||
array('1 minute', 59.9999),
|
||||
array('59 seconds', 59.001),
|
||||
array('59.01 seconds', 59.01),
|
||||
array('1 minute', 60),
|
||||
array('1.01 minutes', 61),
|
||||
array('2 minutes', 120),
|
||||
array('2.01 minutes', 121),
|
||||
array('59.99 minutes', 3599.9),
|
||||
array('59.99 minutes', 3599.99),
|
||||
array('59.99 minutes', 3599.999),
|
||||
array('1 hour', 3599.9999),
|
||||
array('59.98 minutes', 3599.001),
|
||||
array('59.98 minutes', 3599.01),
|
||||
array('1 hour', 3600),
|
||||
array('1 hour', 3601),
|
||||
array('1 hour', 3601.9),
|
||||
array('1 hour', 3601.99),
|
||||
array('1 hour', 3601.999),
|
||||
array('1 hour', 3601.9999),
|
||||
array('1.01 hours', 3659.9999),
|
||||
array('1.01 hours', 3659.001),
|
||||
array('1.01 hours', 3659.01),
|
||||
array('2 hours', 7199.9999),
|
||||
);
|
||||
return [
|
||||
['0 ms', 0],
|
||||
['1 ms', .001],
|
||||
['10 ms', .01],
|
||||
['100 ms', .1],
|
||||
['999 ms', .999],
|
||||
['1 second', .9999],
|
||||
['1 second', 1],
|
||||
['2 seconds', 2],
|
||||
['59.9 seconds', 59.9],
|
||||
['59.99 seconds', 59.99],
|
||||
['59.99 seconds', 59.999],
|
||||
['1 minute', 59.9999],
|
||||
['59 seconds', 59.001],
|
||||
['59.01 seconds', 59.01],
|
||||
['1 minute', 60],
|
||||
['1.01 minutes', 61],
|
||||
['2 minutes', 120],
|
||||
['2.01 minutes', 121],
|
||||
['59.99 minutes', 3599.9],
|
||||
['59.99 minutes', 3599.99],
|
||||
['59.99 minutes', 3599.999],
|
||||
['1 hour', 3599.9999],
|
||||
['59.98 minutes', 3599.001],
|
||||
['59.98 minutes', 3599.01],
|
||||
['1 hour', 3600],
|
||||
['1 hour', 3601],
|
||||
['1 hour', 3601.9],
|
||||
['1 hour', 3601.99],
|
||||
['1 hour', 3601.999],
|
||||
['1 hour', 3601.9999],
|
||||
['1.01 hours', 3659.9999],
|
||||
['1.01 hours', 3659.001],
|
||||
['1.01 hours', 3659.01],
|
||||
['2 hours', 7199.9999],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user