diff --git a/tests/PaletteTests.php b/tests/PaletteTests.php index 8475de6..012c7b0 100644 --- a/tests/PaletteTests.php +++ b/tests/PaletteTests.php @@ -2,17 +2,31 @@ class PaletteTests extends \PHPUnit_Framework_TestCase { - public $palette; - public function test_class_is_found_and_has_default_attributes() { - $this->palette = new \ivuorinen\Palette\Palette(); - $this->assertInstanceOf('ivuorinen\Palette\Palette', $this->palette); + $palette = new \ivuorinen\Palette\Palette(); + $this->assertInstanceOf('ivuorinen\Palette\Palette', $palette); - $this->assertInternalType('integer', $this->palette->precision); - $this->assertInternalType('integer', $this->palette->returnColors); - $this->assertInternalType('array', $this->palette->colorsArray); - $this->assertInternalType('null', $this->palette->filename); - $this->assertInternalType('string', $this->palette->destination); + $this->assertInternalType('integer', $palette->precision); + $this->assertInternalType('integer', $palette->returnColors); + $this->assertInternalType('array', $palette->colorsArray); + $this->assertInternalType('null', $palette->filename); + $this->assertInternalType('string', $palette->destination); + } + + public function test_known_images() + { + $location = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR; + $images = ['black.png' => '000000', 'red.png' => 'CC3333']; + + foreach ($images as $imageFile => $hex) { + $image = $location . $imageFile; + $this->assertTrue(file_exists($image)); + + $palette = new \ivuorinen\Palette\Palette($image); + $this->assertCount(1, $palette->colorsArray); + $this->assertArrayHasKey($hex, $palette->colorsArray); + $this->assertEquals($image, $palette->filename); + } } } \ No newline at end of file diff --git a/tests/assets/black.png b/tests/assets/black.png new file mode 100644 index 0000000..eca4404 Binary files /dev/null and b/tests/assets/black.png differ diff --git a/tests/assets/red.png b/tests/assets/red.png new file mode 100644 index 0000000..f7ba5c0 Binary files /dev/null and b/tests/assets/red.png differ