mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 10:49:10 -04:00
ALPHA 3.0.2a
This commit is contained in:
@@ -3,14 +3,15 @@ namespace Faker\Test\Provider;
|
||||
|
||||
use Faker\Provider\Biased;
|
||||
use Faker\Generator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BiasedTest extends \PHPUnit_Framework_TestCase
|
||||
class BiasedTest extends TestCase
|
||||
{
|
||||
const MAX = 10;
|
||||
const NUMBERS = 25000;
|
||||
protected $generator;
|
||||
protected $results = array();
|
||||
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->generator = new Generator();
|
||||
@@ -18,14 +19,14 @@ class BiasedTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->results = array_fill(1, self::MAX, 0);
|
||||
}
|
||||
|
||||
|
||||
public function performFake($function)
|
||||
{
|
||||
for($i = 0; $i < self::NUMBERS; $i++) {
|
||||
$this->results[$this->generator->biasedNumberBetween(1, self::MAX, $function)]++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function testUnbiased()
|
||||
{
|
||||
$this->performFake(array('\Faker\Provider\Biased', 'unbiased'));
|
||||
@@ -40,7 +41,7 @@ class BiasedTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertLessThan(self::NUMBERS * $assumed * 1.05, $amount, "Value was more than 5 percent over the expected value");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function testLinearHigh()
|
||||
{
|
||||
$this->performFake(array('\Faker\Provider\Biased', 'linearHigh'));
|
||||
@@ -54,7 +55,7 @@ class BiasedTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertLessThan(self::NUMBERS * $assumed * 1.1, $amount, "Value was more than 10 percent over the expected value");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function testLinearLow()
|
||||
{
|
||||
$this->performFake(array('\Faker\Provider\Biased', 'linearLow'));
|
||||
|
||||
Reference in New Issue
Block a user