mirror of
https://github.com/fzaninotto/Faker.git
synced 2025-03-19 06:49:50 +01:00
fixed unit test and changed arrays name to a better name
This commit is contained in:
parent
99024404da
commit
9ce3d44ea2
@ -16,13 +16,13 @@ class Color extends Base
|
||||
'a', 'b', 'c', 'd', 'e', 'f'
|
||||
);
|
||||
|
||||
protected static $oldBrowserNames = array(
|
||||
protected static $safeColorNames = array(
|
||||
'black', 'maroon', 'green', 'navy', 'olive',
|
||||
'purple', 'teal', 'lime', 'blue', 'silver',
|
||||
'gray', 'yellow', 'fuchsia', 'aqua', 'white'
|
||||
);
|
||||
|
||||
protected static $newBrowserNames = array(
|
||||
protected static $allColorNames = array(
|
||||
'AliceBlue', 'AntiqueWhite', 'Aqua', 'Aquamarine',
|
||||
'Azure', 'Beige', 'Bisque', 'Black', 'BlanchedAlmond',
|
||||
'Blue', 'BlueViolet', 'Brown', 'BurlyWood', 'CadetBlue',
|
||||
@ -110,7 +110,7 @@ class Color extends Base
|
||||
*/
|
||||
public static function safeColorName()
|
||||
{
|
||||
return static::randomElement(static::$oldBrowserNames);
|
||||
return static::randomElement(static::$safeColorNames);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -118,7 +118,7 @@ class Color extends Base
|
||||
*/
|
||||
public static function colorName()
|
||||
{
|
||||
return static::randomElement(static::$newBrowserNames);
|
||||
return static::randomElement(static::$allColorNames);
|
||||
}
|
||||
|
||||
}
|
@ -2,31 +2,25 @@
|
||||
|
||||
namespace Faker\Test\Provider;
|
||||
|
||||
use Faker;
|
||||
use Faker\Provider\Color;
|
||||
|
||||
class ColorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function testHexColor()
|
||||
{
|
||||
$faker = Faker\Factory::create();
|
||||
$color = $faker->hexColor;
|
||||
$this->assertRegExp('/^#[a-f0-9]{6}$/i', $color);
|
||||
$this->assertRegExp('/^#[a-f0-9]{6}$/i', Color::hexColor());
|
||||
}
|
||||
|
||||
public function testRgbColorAsArray()
|
||||
{
|
||||
$faker = Faker\Factory::create();
|
||||
$color = $faker->rgbColorAsArray;
|
||||
$this->assertEquals(3, count($color));
|
||||
$this->assertEquals(3, count(Color::rgbColorAsArray()));
|
||||
}
|
||||
|
||||
public function testRgbColor()
|
||||
{
|
||||
$faker = Faker\Factory::create();
|
||||
$color = $faker->rgbColor();
|
||||
$regexp = '([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])';
|
||||
$this->assertRegExp('/^' . $regexp . ',' . $regexp . ',' . $regexp . '$/i', $color);
|
||||
$this->assertRegExp('/^' . $regexp . ',' . $regexp . ',' . $regexp . '$/i', Color::rgbColor());
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user