From 1b7d0a2a34cd1f74d89ac739b31fc18c6da2eed2 Mon Sep 17 00:00:00 2001 From: Gintautas Miselis Date: Tue, 29 Dec 2020 18:56:33 +0200 Subject: [PATCH 1/5] Replace Codeception\Util\Stub with Codeception\Stub in tests Because Codeception\Util\Stub will be removed from Codeception 5.0 --- tests/unit/Codeception/Module/AssertsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/Codeception/Module/AssertsTest.php b/tests/unit/Codeception/Module/AssertsTest.php index a9421cb..cb00cbe 100644 --- a/tests/unit/Codeception/Module/AssertsTest.php +++ b/tests/unit/Codeception/Module/AssertsTest.php @@ -5,7 +5,7 @@ use Codeception\Lib\ModuleContainer; use Codeception\Module\Asserts; use Codeception\PHPUnit\TestCase; -use Codeception\Util\Stub; +use Codeception\Stub; use Exception; use PHPUnit\Framework\AssertionFailedError; use RuntimeException; From d5609430a22d08ab3ac1b47115cc20d165d8f405 Mon Sep 17 00:00:00 2001 From: Tavo Nieves J <64917965+TavoNiievez@users.noreply.github.com> Date: Tue, 12 Jan 2021 15:08:24 -0500 Subject: [PATCH 2/5] Standardize the `README` format (#12) --- readme.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 29960ff..ed6cb52 100644 --- a/readme.md +++ b/readme.md @@ -1,15 +1,24 @@ # Codeception Module Asserts -![Build Status](https://github.com/Codeception/module-asserts/workflows/CI/badge.svg) +[![Actions Status](https://github.com/Codeception/module-asserts/workflows/CI/badge.svg)](https://github.com/Codeception/module-asserts/actions) +[![Latest Stable Version](https://poser.pugx.org/codeception/module-asserts/v/stable)](https://github.com/Codeception/module-asserts/releases) +[![Total Downloads](https://poser.pugx.org/codeception/module-asserts/downloads)](https://packagist.org/packages/codeception/module-asserts) +[![License](https://poser.pugx.org/codeception/module-asserts/license)](/LICENSE) A Codeception module containing various assertions. ## Installation ``` -composer require --dev "codeception/module-asserts" +composer require "codeception/module-asserts" --dev ``` ## Documentation -Module documentation +See [the module documentation](https://codeception.com/docs/modules/Asserts). + +## License + +`Codeception Module Asserts` is open-sourced software licensed under the [MIT](/LICENSE) License. + +© Codeception PHP Testing Framework From e83c8070e3c8f0e2673a49e1f0ec46bf530f2035 Mon Sep 17 00:00:00 2001 From: Tavo Nieves J <64917965+TavoNiievez@users.noreply.github.com> Date: Thu, 27 May 2021 13:21:18 -0500 Subject: [PATCH 3/5] Code standards updated to PHP 7.1 (#13) --- .github/workflows/main.yml | 2 +- composer.json | 28 ++++---- readme.md | 4 ++ src/Codeception/Module/AbstractAsserts.php | 10 +-- src/Codeception/Module/Asserts.php | 67 +++++-------------- tests/unit/Codeception/Module/AssertsTest.php | 4 +- 6 files changed, 45 insertions(+), 70 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5d4e738..bfbad11 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: - php: [5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0] + php: [7.1, 7.2, 7.3, 7.4, 8.0] steps: - name: Checkout code diff --git a/composer.json b/composer.json index aaea20e..c65a50d 100644 --- a/composer.json +++ b/composer.json @@ -1,33 +1,35 @@ { - "name":"codeception/module-asserts", - "description":"Codeception module containing various assertions", - "keywords":["codeception", "asserts", "assertions"], - "homepage":"https://codeception.com/", - "type":"library", - "license":"MIT", - "authors":[ + "name": "codeception/module-asserts", + "description": "Codeception module containing various assertions", + "keywords": [ "codeception", "asserts", "assertions" ], + "homepage": "https://codeception.com/", + "type": "library", + "license": "MIT", + "authors": [ { - "name":"Michael Bodnarchuk" + "name": "Michael Bodnarchuk" }, { - "name":"Gintautas Miselis" + "name": "Gintautas Miselis" }, { - "name":"Gustavo Nieves", + "name": "Gustavo Nieves", "homepage": "https://medium.com/@ganieves" } ], "minimum-stability": "RC", "require": { - "php": ">=5.6.0 <9.0", + "php": "^7.1 || ^8.0", "codeception/lib-asserts": "^1.13.1", "codeception/codeception": "*@dev" }, "conflict": { "codeception/codeception": "<4.0" }, - "autoload":{ - "classmap": ["src/"] + "autoload": { + "classmap": [ + "src/" + ] }, "config": { "classmap-authoritative": true diff --git a/readme.md b/readme.md index ed6cb52..55cd0fc 100644 --- a/readme.md +++ b/readme.md @@ -7,6 +7,10 @@ A Codeception module containing various assertions. +## Requirements + +* `PHP 7.1` or higher. + ## Installation ``` diff --git a/src/Codeception/Module/AbstractAsserts.php b/src/Codeception/Module/AbstractAsserts.php index 9704d5c..6855f3a 100644 --- a/src/Codeception/Module/AbstractAsserts.php +++ b/src/Codeception/Module/AbstractAsserts.php @@ -1,13 +1,15 @@ expectException(MyException::class, function() { - * $this->doSomethingBad(); - * }); - * - * $I->expectException(new MyException(), function() { - * $this->doSomethingBad(); - * }); - * ``` - * If you want to check message or exception code, you can pass them with exception instance: - * ```php - * expectException(new MyException("Don't do bad things"), function() { - * $this->doSomethingBad(); - * }); - * ``` - * - * @deprecated Use expectThrowable() instead - * @param \Exception|string $exception - * @param callable $callback - */ - public function expectException($exception, $callback) - { - Notification::deprecate('Use expectThrowable() instead'); - $this->expectThrowable($exception, $callback); - } - /** * Handles and checks throwables (Exceptions/Errors) called inside the callback function. * Either throwable class name or throwable instance should be provided. @@ -65,10 +34,9 @@ public function expectException($exception, $callback) * }); * ``` * - * @param \Throwable|string $throwable - * @param callable $callback + * @param Throwable|string $throwable */ - public function expectThrowable($throwable, $callback) + public function expectThrowable($throwable, callable $callback): void { if (is_object($throwable)) { $class = get_class($throwable); @@ -82,45 +50,42 @@ public function expectThrowable($throwable, $callback) try { $callback(); - } catch (\Exception $t) { - $this->checkThrowable($t, $class, $msg, $code); - return; - } catch (\Throwable $t) { + } catch (Throwable $t) { $this->checkThrowable($t, $class, $msg, $code); return; } - $this->fail("Expected throwable of class '$class' to be thrown, but nothing was caught"); + $this->fail("Expected throwable of class '{$class}' to be thrown, but nothing was caught"); } /** * Check if the given throwable matches the expected data, * fail (throws an exception) if it does not. - * - * @param \Throwable $throwable - * @param string $expectedClass - * @param string $expectedMsg - * @param int $expectedCode */ - protected function checkThrowable($throwable, $expectedClass, $expectedMsg, $expectedCode) + protected function checkThrowable(Throwable $throwable, string $expectedClass, ?string $expectedMsg, ?int $expectedCode): void { if (!($throwable instanceof $expectedClass)) { $this->fail(sprintf( - "Exception of class '$expectedClass' expected to be thrown, but class '%s' was caught", + "Exception of class '%s' expected to be thrown, but class '%s' was caught", + $expectedClass, get_class($throwable) )); } if (null !== $expectedMsg && $throwable->getMessage() !== $expectedMsg) { $this->fail(sprintf( - "Exception of class '$expectedClass' expected to have message '$expectedMsg', but actual message was '%s'", + "Exception of class '%s' expected to have message '%s', but actual message was '%s'", + $expectedClass, + $expectedMsg, $throwable->getMessage() )); } if (null !== $expectedCode && $throwable->getCode() !== $expectedCode) { $this->fail(sprintf( - "Exception of class '$expectedClass' expected to have code '$expectedCode', but actual code was '%s'", + "Exception of class '%s' expected to have code '%s', but actual code was '%s'", + $expectedClass, + $expectedCode, $throwable->getCode() )); } diff --git a/tests/unit/Codeception/Module/AssertsTest.php b/tests/unit/Codeception/Module/AssertsTest.php index cb00cbe..48230d9 100644 --- a/tests/unit/Codeception/Module/AssertsTest.php +++ b/tests/unit/Codeception/Module/AssertsTest.php @@ -1,5 +1,7 @@ Date: Mon, 30 Aug 2021 00:46:00 +0300 Subject: [PATCH 4/5] Update readme.md (#16) --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index 55cd0fc..f08a426 100644 --- a/readme.md +++ b/readme.md @@ -21,6 +21,8 @@ composer require "codeception/module-asserts" --dev See [the module documentation](https://codeception.com/docs/modules/Asserts). +[Changelog](https://github.com/Codeception/module-asserts/releases) + ## License `Codeception Module Asserts` is open-sourced software licensed under the [MIT](/LICENSE) License. From ef4a27087b09bf3c3b88fa9025e3179848541a79 Mon Sep 17 00:00:00 2001 From: Tavo Nieves J <64917965+TavoNiievez@users.noreply.github.com> Date: Mon, 29 Nov 2021 19:38:49 -0500 Subject: [PATCH 5/5] Update codebase to PHP 7.4 (#17) --- .github/workflows/main.yml | 2 +- composer.json | 2 +- readme.md | 2 +- tests/unit/Codeception/Module/AssertsTest.php | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bfbad11..8ab4cff 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: - php: [7.1, 7.2, 7.3, 7.4, 8.0] + php: [7.4, 8.0, 8.1] steps: - name: Checkout code diff --git a/composer.json b/composer.json index c65a50d..5c46e29 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ ], "minimum-stability": "RC", "require": { - "php": "^7.1 || ^8.0", + "php": "^7.4 || ^8.0", "codeception/lib-asserts": "^1.13.1", "codeception/codeception": "*@dev" }, diff --git a/readme.md b/readme.md index f08a426..df23ddd 100644 --- a/readme.md +++ b/readme.md @@ -9,7 +9,7 @@ A Codeception module containing various assertions. ## Requirements -* `PHP 7.1` or higher. +* `PHP 7.4` or higher. ## Installation diff --git a/tests/unit/Codeception/Module/AssertsTest.php b/tests/unit/Codeception/Module/AssertsTest.php index 48230d9..21b3c76 100644 --- a/tests/unit/Codeception/Module/AssertsTest.php +++ b/tests/unit/Codeception/Module/AssertsTest.php @@ -15,8 +15,7 @@ final class AssertsTest extends TestCase { - /** @var Asserts */ - protected $module; + protected ?Asserts $module = null; public function _setUp() {