From 8796392710201217ff25cc5180fe6de2c117f5b4 Mon Sep 17 00:00:00 2001 From: Taner Kucukyuruk Date: Wed, 18 May 2022 20:16:06 +0200 Subject: [PATCH] modernization. phpunit 9, package upgrades, newer php syntax and features --- .gitignore | 3 ++- README.md | 15 +++++++-------- composer.json | 11 ++++++----- phpunit.xml | 26 +++++++++----------------- src/Adder.php | 14 +++----------- tests/AdderTest.php | 14 ++++++-------- 6 files changed, 33 insertions(+), 50 deletions(-) diff --git a/.gitignore b/.gitignore index bfef211..4a315f0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ composer.lock composer.phar -/vendor/ \ No newline at end of file +/vendor/ +.phpunit.result.cache diff --git a/README.md b/README.md index 996caf7..ae4ff1e 100644 --- a/README.md +++ b/README.md @@ -31,26 +31,25 @@ and create a new one in your computer. php composer.phar create-project kata/php bowling-kata dev-master -Then add your classes to 'src/Kata' and your test cases to -'src/Kata/Tests' and run 'php bin/phpunit' to run your tests. +Then add your classes to `src/Kata` and your test cases to +`src/Kata/Tests` and run `php bin/phpunit` to run your tests. php bin/phpunit TestCase examples ================= -If you run 'php bin/phpunit' you will see the following output. +If you run `php bin/phpunit` you will see the following output. - PHPUnit 3.8-gc4f2bcd by Sebastian Bergmann. + PHPUnit 9.5.20 - Configuration read from /Users/carlosbuenosvinos/Documents/Web/bowling/phpunit.xml + ... 3 / 3 (100%) - ... + Time: 00:00.003, Memory: 6.00 MB - Time: 91 ms, Memory: 1.75Mb OK (3 tests, 3 assertions) That's because you will find one class and its TestCase in the project in order to help you. You can delete them. -Adder is a class that adds two numbers and AdderTest tests that. +`Adder` is a class that adds two numbers and `AdderTest` tests that. diff --git a/composer.json b/composer.json index c0a327c..9b6e723 100644 --- a/composer.json +++ b/composer.json @@ -1,13 +1,13 @@ { "name": "kata/php", "description": "PHP Kata skeleton", - "keywords": ["kata","TDD"], + "keywords": ["kata", "TDD"], "homepage": "https://github.com/carlosbuenosvinos/php-kata", "type": "library", "require-dev": { - "phpunit/phpunit": "5.5.*@dev", - "mockery/mockery": "dev-master@dev", - "phpspec/phpspec": "3.0.*@dev" + "phpunit/phpunit": "^9.5", + "mockery/mockery": "^1.5", + "phpspec/phpspec": "^7.0" }, "license": "MIT", "authors": [ @@ -18,7 +18,8 @@ ], "autoload": { "psr-4": { - "Kata\\": "src/" + "Kata\\": "src/", + "Kata\\Tests\\": "tests/" } }, "config": { diff --git a/phpunit.xml b/phpunit.xml index b87d5b5..6b0413b 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,16 +1,8 @@ - - + colors="true"> @@ -23,9 +15,9 @@ - - - ./src/ - - - \ No newline at end of file + + + ./src + + + diff --git a/src/Adder.php b/src/Adder.php index 38831f3..f0e0f6c 100644 --- a/src/Adder.php +++ b/src/Adder.php @@ -1,19 +1,11 @@ assertEquals( $expectedResult, @@ -20,7 +18,7 @@ public function validSums($a, $b, $expectedResult) ); } - public function validSumsProvider() + public function validSumsProvider(): array { return [ [null, null, 0], @@ -28,4 +26,4 @@ public function validSumsProvider() [1, 1, 2] ]; } -} \ No newline at end of file +}