mirror of
https://github.com/ivuorinen/palette.git
synced 2026-03-02 23:57:10 +00:00
Merge pull request #4 from ivuorinen/renovate/phpunit-phpunit-9.x
Update dependency phpunit/phpunit to v9
This commit is contained in:
2
.github/workflows/php.yml
vendored
2
.github/workflows/php.yml
vendored
@@ -36,4 +36,4 @@ jobs:
|
|||||||
# Docs: https://getcomposer.org/doc/articles/scripts.md
|
# Docs: https://getcomposer.org/doc/articles/scripts.md
|
||||||
|
|
||||||
- name: Run test suite
|
- name: Run test suite
|
||||||
run: vendor/bin/phpunit
|
run: composer run-script test
|
||||||
|
|||||||
@@ -19,10 +19,19 @@
|
|||||||
"psr-0": { "ivuorinen\\Palette\\": "src/" },
|
"psr-0": { "ivuorinen\\Palette\\": "src/" },
|
||||||
"classmap": ["src/"]
|
"classmap": ["src/"]
|
||||||
},
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-0": {
|
||||||
|
"ivuorinen\\Palette\\Tests\\": "tests/"
|
||||||
|
}
|
||||||
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.6.0"
|
"php": ">=5.6.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "5.7.27"
|
"phpunit/phpunit": "9.5.21",
|
||||||
|
"squizlabs/php_codesniffer": "^3.7"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "vendor/bin/phpunit"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
21
phpcs.xml.dist
Normal file
21
phpcs.xml.dist
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<ruleset
|
||||||
|
name="PHP_CodeSniffer"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"
|
||||||
|
>
|
||||||
|
<description>PHP Code Sniffer configuration file.</description>
|
||||||
|
|
||||||
|
<file>.</file>
|
||||||
|
|
||||||
|
<arg name="basepath" value="."/>
|
||||||
|
<arg name="colors"/>
|
||||||
|
<arg name="extensions" value="php"/>
|
||||||
|
<arg name="parallel" value="10"/>
|
||||||
|
|
||||||
|
<!-- base rule: set to PSR12-->
|
||||||
|
<!-- https://www.php-fig.org/psr/psr-12/ -->
|
||||||
|
<rule ref="PSR12">
|
||||||
|
<exclude-pattern>*/vendor/*</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
</ruleset>
|
||||||
@@ -1,23 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class PaletteTest extends \PHPUnit_Framework_TestCase
|
namespace ivuorinen\Palette\Tests;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class PaletteTest extends TestCase
|
||||||
{
|
{
|
||||||
public function test_class_is_found_and_has_default_attributes()
|
public function testClassIsFoundAndHasDefaultAttributes()
|
||||||
{
|
{
|
||||||
$palette = new \ivuorinen\Palette\Palette();
|
$palette = new \ivuorinen\Palette\Palette();
|
||||||
$this->assertInstanceOf('ivuorinen\Palette\Palette', $palette);
|
$this->assertInstanceOf('ivuorinen\Palette\Palette', $palette);
|
||||||
|
|
||||||
$this->assertInternalType('integer', $palette->precision);
|
$this->assertIsInt($palette->precision);
|
||||||
$this->assertInternalType('integer', $palette->returnColors);
|
$this->assertIsInt($palette->returnColors);
|
||||||
$this->assertInternalType('array', $palette->colorsArray);
|
$this->assertIsArray($palette->colorsArray);
|
||||||
$this->assertInternalType('null', $palette->filename);
|
$this->assertNull($palette->filename);
|
||||||
$this->assertInternalType('string', $palette->destination);
|
$this->assertIsString($palette->destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_known_images_with_one_color()
|
public function testKnownImagesWithOneColor()
|
||||||
{
|
{
|
||||||
$location = __DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR;
|
$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) {
|
foreach ($images as $imageFile => $hex) {
|
||||||
$image = $location . $imageFile;
|
$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;
|
$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) {
|
foreach ($images as $imageFile) {
|
||||||
$image = $location . $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('');
|
$palette = new \ivuorinen\Palette\Palette('');
|
||||||
$this->expectException(ErrorException::class);
|
$this->expectException(\ErrorException::class);
|
||||||
$this->expectExceptionMessage('Image was not provided');
|
$this->expectExceptionMessage('Image was not provided');
|
||||||
$palette->getPalette();
|
$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';
|
$palette->filename = 'NOT_HERE';
|
||||||
$this->expectException(ErrorException::class);
|
$this->expectException(\ErrorException::class);
|
||||||
$this->expectExceptionMessage('Image ' . $palette->filename . ' is not readable');
|
$this->expectExceptionMessage('Image ' . $palette->filename . ' is not readable');
|
||||||
|
|
||||||
$palette->getPalette();
|
$palette->getPalette();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user