diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 0d2579d..2d47ab6 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -36,4 +36,4 @@ jobs: # Docs: https://getcomposer.org/doc/articles/scripts.md - name: Run test suite - run: vendor/bin/phpunit + run: composer run-script test diff --git a/composer.json b/composer.json index 305fb3c..c1ff20f 100644 --- a/composer.json +++ b/composer.json @@ -19,10 +19,19 @@ "psr-0": { "ivuorinen\\Palette\\": "src/" }, "classmap": ["src/"] }, + "autoload-dev": { + "psr-0": { + "ivuorinen\\Palette\\Tests\\": "tests/" + } + }, "require": { "php": ">=5.6.0" }, "require-dev": { - "phpunit/phpunit": "9.5.21" + "phpunit/phpunit": "9.5.21", + "squizlabs/php_codesniffer": "^3.7" + }, + "scripts": { + "test": "vendor/bin/phpunit" } } diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..1decab6 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,21 @@ + + + PHP Code Sniffer configuration file. + + . + + + + + + + + + + */vendor/* + + diff --git a/tests/PaletteTest.php b/tests/PaletteTest.php index abb0af0..833ff51 100644 --- a/tests/PaletteTest.php +++ b/tests/PaletteTest.php @@ -1,23 +1,27 @@ assertInstanceOf('ivuorinen\Palette\Palette', $palette); - $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); + $this->assertIsInt($palette->precision); + $this->assertIsInt($palette->returnColors); + $this->assertIsArray($palette->colorsArray); + $this->assertNull($palette->filename); + $this->assertIsString($palette->destination); } - public function test_known_images_with_one_color() + public function testKnownImagesWithOneColor() { $location = __DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR; - $images = ['black.png' => '000000', 'red.png' => 'CC3333']; + $images = [ 'black.png' => '000000', 'red.png' => 'CC3333' ]; foreach ($images as $imageFile => $hex) { $image = $location . $imageFile; @@ -30,10 +34,10 @@ class PaletteTest extends \PHPUnit_Framework_TestCase } } - public function test_known_images_with_many_colors() + public function testKnownImagesWithManyColors() { $location = __DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR; - $images = ['example.gif', 'example.jpg', 'example.png']; + $images = [ 'example.gif', 'example.jpg', 'example.png' ]; foreach ($images as $imageFile) { $image = $location . $imageFile; @@ -45,20 +49,21 @@ class PaletteTest extends \PHPUnit_Framework_TestCase } } - public function test_failure_no_image() + public function testFailureNoImage() { $palette = new \ivuorinen\Palette\Palette(''); - $this->expectException(ErrorException::class); + $this->expectException(\ErrorException::class); $this->expectExceptionMessage('Image was not provided'); $palette->getPalette(); } - public function test_failure_not_an_image() + public function testFailureNotAnImage() { - $palette = new \ivuorinen\Palette\Palette(); + $palette = new \ivuorinen\Palette\Palette(); $palette->filename = 'NOT_HERE'; - $this->expectException(ErrorException::class); + $this->expectException(\ErrorException::class); $this->expectExceptionMessage('Image ' . $palette->filename . ' is not readable'); + $palette->getPalette(); } }