From f39825f1a0b5b10f1d075262266c443e5458b43f Mon Sep 17 00:00:00 2001 From: peter279k Date: Sun, 27 May 2018 12:41:36 +0800 Subject: [PATCH] Test enhancement --- .travis.yml | 16 ++++++++++++++++ composer.json | 8 +++++++- phpunit.xml.dist | 6 ++++++ tests/unit/AverageHashTest.php | 11 +++++++---- tests/unit/BasicTest.php | 5 ++++- tests/unit/DifferenceHashTest.php | 11 +++++++---- tests/unit/PerceptionHashTest.php | 5 ++++- 7 files changed, 51 insertions(+), 11 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..36080a3 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +language: php +php: + - '5.6' + - '7.0' + - '7.1' + - '7.2' + - nightly + +matrix: + allow_failures: + - php: nightly +before_script: + - composer install -n + +script: + - vendor/bin/phpunit diff --git a/composer.json b/composer.json index 1daf238..6d5d477 100644 --- a/composer.json +++ b/composer.json @@ -8,10 +8,16 @@ "Image\\": "lib" } }, + "autoload-dev": { + "psr-4": { + "Image\\Tests\\": "tests/unit" + } + }, "require": { + "php": ">=5.6", "ext-gd": "*" }, "require-dev": { - "phpunit/phpunit": "4.*" + "phpunit/phpunit": "^5.7||^6.5" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c3adb6f..5eb315f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -18,4 +18,10 @@ + + + lib + + + diff --git a/tests/unit/AverageHashTest.php b/tests/unit/AverageHashTest.php index 4660b73..0ee9a7d 100644 --- a/tests/unit/AverageHashTest.php +++ b/tests/unit/AverageHashTest.php @@ -1,8 +1,11 @@ bin(); $this->assertEquals(64, strlen($bin)); - $this->assertEquals($this->bin_image2, $bin); + $this->assertEquals($this->bin_image1, $bin); } public function testCalculateHexHash() @@ -36,7 +39,7 @@ public function testCalculateHexHash() $hex = $ph->hex(); $this->assertEquals(16, strlen($hex)); - $this->assertEquals($this->hex_image2, $hex); + $this->assertEquals($this->hex_image1, $hex); } public function testCompareDifferentImages() @@ -50,7 +53,7 @@ public function testCompareDifferentImages() public function testCompareSameImages() { $ph = new PerceptualHash($this->path_image1); - $diff = $ph->compare($this->path_image2); + $diff = $ph->compare($this->path_image1); $this->assertEquals(0, $diff); } diff --git a/tests/unit/BasicTest.php b/tests/unit/BasicTest.php index 7f3ca07..1b4d60c 100644 --- a/tests/unit/BasicTest.php +++ b/tests/unit/BasicTest.php @@ -1,9 +1,12 @@ bin(); $this->assertEquals(64, strlen($bin)); - $this->assertEquals($this->bin_image2, $bin); + $this->assertEquals($this->bin_image1, $bin); } public function testCalculateHexHash() @@ -39,7 +42,7 @@ public function testCalculateHexHash() $hex = $ph->hex(); $this->assertEquals(16, strlen($hex)); - $this->assertEquals($this->hex_image2, $hex); + $this->assertEquals($this->hex_image1, $hex); } public function testCompareDifferentImages() @@ -55,7 +58,7 @@ public function testCompareSameImages() { $algorithm = new DifferenceHash; $ph = new PerceptualHash($this->path_image1, $algorithm); - $diff = $ph->compare($this->path_image2); + $diff = $ph->compare($this->path_image1); $this->assertEquals(0, $diff); } diff --git a/tests/unit/PerceptionHashTest.php b/tests/unit/PerceptionHashTest.php index c0a78fa..e672897 100644 --- a/tests/unit/PerceptionHashTest.php +++ b/tests/unit/PerceptionHashTest.php @@ -1,9 +1,12 @@