From 9ce3d44ea260e9bc5260a674bdc616b01346444d Mon Sep 17 00:00:00 2001 From: lsv Date: Mon, 17 Jun 2013 01:29:06 +0200 Subject: [PATCH] fixed unit test and changed arrays name to a better name --- src/Faker/Provider/Color.php | 8 ++++---- test/Faker/Provider/ColorTest.php | 14 ++++---------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/Faker/Provider/Color.php b/src/Faker/Provider/Color.php index ff7b679d..1b852383 100644 --- a/src/Faker/Provider/Color.php +++ b/src/Faker/Provider/Color.php @@ -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); } } \ No newline at end of file diff --git a/test/Faker/Provider/ColorTest.php b/test/Faker/Provider/ColorTest.php index e9eb67bc..8010a0aa 100644 --- a/test/Faker/Provider/ColorTest.php +++ b/test/Faker/Provider/ColorTest.php @@ -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()); } } \ No newline at end of file