]> git.agnieray.net Git - galette.git/commitdiff
Migrate to phpunit; closes #1674
authorJohan Cwiklinski <johan@x-tnd.be>
Tue, 14 Mar 2023 08:11:55 +0000 (09:11 +0100)
committerJohan Cwiklinski <johan@x-tnd.be>
Fri, 24 Mar 2023 04:39:41 +0000 (05:39 +0100)
Good bye atoum :'(

61 files changed:
.github/workflows/ci-linux.yml
galette/composer.json
galette/composer.lock
galette/includes/dependencies.php
galette/lib/Galette/Core/CheckModules.php
galette/lib/Galette/IO/News.php
galette/lib/Galette/Middleware/Authenticate.php
tests/Galette/Controllers/tests/units/PdfController.php
tests/Galette/Core/tests/units/CheckModules.php
tests/Galette/Core/tests/units/Db.php
tests/Galette/Core/tests/units/Galette.php
tests/Galette/Core/tests/units/History.php
tests/Galette/Core/tests/units/I18n.php
tests/Galette/Core/tests/units/Install.php
tests/Galette/Core/tests/units/L10n.php
tests/Galette/Core/tests/units/Links.php
tests/Galette/Core/tests/units/Login.php
tests/Galette/Core/tests/units/Logo.php
tests/Galette/Core/tests/units/Password.php
tests/Galette/Core/tests/units/Picture.php
tests/Galette/Core/tests/units/Plugins.php
tests/Galette/Core/tests/units/Preferences.php
tests/Galette/Core/tests/units/PrintLogo.php
tests/Galette/DynamicFields/tests/units/Boolean.php
tests/Galette/DynamicFields/tests/units/Choice.php
tests/Galette/DynamicFields/tests/units/Date.php
tests/Galette/DynamicFields/tests/units/DynamicField.php
tests/Galette/DynamicFields/tests/units/File.php
tests/Galette/DynamicFields/tests/units/Line.php
tests/Galette/DynamicFields/tests/units/Separator.php
tests/Galette/DynamicFields/tests/units/Text.php
tests/Galette/Entity/tests/units/Adherent.php
tests/Galette/Entity/tests/units/Contribution.php
tests/Galette/Entity/tests/units/FieldsConfig.php
tests/Galette/Entity/tests/units/Group.php
tests/Galette/Entity/tests/units/ListsConfig.php
tests/Galette/Entity/tests/units/PaymentType.php
tests/Galette/Entity/tests/units/PdfModel.php
tests/Galette/Entity/tests/units/SavedSeach.php [deleted file]
tests/Galette/Entity/tests/units/SavedSearch.php [new file with mode: 0644]
tests/Galette/Entity/tests/units/Social.php
tests/Galette/Entity/tests/units/Status.php
tests/Galette/Entity/tests/units/Texts.php
tests/Galette/Entity/tests/units/Title.php
tests/Galette/Entity/tests/units/Transaction.php
tests/Galette/IO/tests/units/CsvIn.php
tests/Galette/IO/tests/units/News.php
tests/Galette/Repository/tests/units/Groups.php
tests/Galette/Repository/tests/units/Members.php
tests/Galette/Repository/tests/units/PaymentTypes.php
tests/Galette/Repository/tests/units/PdfModels.php
tests/Galette/Repository/tests/units/Reminders.php
tests/Galette/Util/tests/units/Password.php
tests/Galette/Util/tests/units/Telemetry.php
tests/GaletteTestCase.php
tests/GaletteUpdate/Core/tests/units/Install.php
tests/README
tests/TestsBootstrap.php
tests/clover.php [deleted file]
tests/coverage.php [deleted file]
tests/fixtures/translations.php

index 7429e75a86354c20c7578e30a828af5219d2bfcd..a58e45f5eca2fe83ea70fcde0c3b48e207fbad4a 100644 (file)
@@ -132,7 +132,7 @@ jobs:
         if: startsWith(matrix.db-image, 'mysql') || startsWith(matrix.db-image, 'mariadb')
 
       - name: Update database tests
-        run: galette/vendor/bin/atoum -mcn 1 -bf tests/TestsBootstrap.php --no-cc -d tests/GaletteUpdate/
+        run: UPDATE=UPDATE galette/vendor/bin/phpunit --test-suffix=.php --bootstrap tests/TestsBootstrap.php --no-coverage --process-isolation tests/GaletteUpdate/
         if: matrix.coverage != 'xdebug'
 
       - name: Init for PostgreSQL
@@ -150,11 +150,11 @@ jobs:
         if: startsWith(matrix.db-image, 'mysql') || startsWith(matrix.db-image, 'mariadb')
 
       - name: Unit tests
-        run: galette/vendor/bin/atoum -mcn 1 -bf tests/TestsBootstrap.php --no-cc -d tests/Galette/
+        run: galette/vendor/bin/phpunit --test-suffix=.php --bootstrap tests/TestsBootstrap.php --no-coverage --process-isolation tests/Galette/
         if: matrix.coverage != 'xdebug'
 
       - name: Unit tests (with coverage)
-        run: galette/vendor/bin/atoum -mcn 1 -bf tests/TestsBootstrap.php -c tests/clover.php -d tests/Galette/
+        run: galette/vendor/bin/phpunit --test-suffix=.php --bootstrap tests/TestsBootstrap.php --process-isolation --coverage-filter galette/lib --coverage-clover tests/clover.xml tests/Galette/
         if: matrix.coverage == 'xdebug'
 
       - name: Upload code coverage (scrutinizer)
index af09424f469734da8f26218751731daa42f17bf6..bc57e8ac2d81eabe7877de5640633ab145687ba4 100644 (file)
         "symfony/yaml": "^6.2"
     },
     "require-dev": {
-        "atoum/atoum": "dev-main",
         "squizlabs/php_codesniffer": "^3.7",
         "friendsoftwig/twigcs": "^6.2",
-        "phpstan/phpstan": "^1.9"
+        "phpstan/phpstan": "^1.9",
+        "phpunit/phpunit": "^10.0"
     },
     "config": {
         "optimize-autoloader": true,
index d21d9a32e15c6f524193f2e82f9fdcee2cae250f..1575f9af8a604b317a500d9086f8286c51a3fa45 100644 (file)
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "aa17238d71273466c4c9228450487eed",
+    "content-hash": "493df3e560936f2a6d908f78b36b7198",
     "packages": [
         {
             "name": "akrabat/rka-slim-session-middleware",
     ],
     "packages-dev": [
         {
-            "name": "atoum/atoum",
-            "version": "dev-main",
+            "name": "friendsoftwig/twigcs",
+            "version": "6.2.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/friendsoftwig/twigcs.git",
+                "reference": "da697cc1bf6bf22feb1d8dbefcbdb1451e6a35f6"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/friendsoftwig/twigcs/zipball/da697cc1bf6bf22feb1d8dbefcbdb1451e6a35f6",
+                "reference": "da697cc1bf6bf22feb1d8dbefcbdb1451e6a35f6",
+                "shasum": ""
+            },
+            "require": {
+                "ext-ctype": "*",
+                "ext-hash": "*",
+                "ext-json": "*",
+                "ext-mbstring": "*",
+                "ext-simplexml": "*",
+                "php": "~8.0.0 || ~8.1.0 || ~8.2.0",
+                "symfony/console": "^4.4 || ^5.3 || ^6.0",
+                "symfony/filesystem": "^4.4 || ^5.3 || ^6.0",
+                "symfony/finder": "^4.4 || ^5.3 || ^6.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^9.5.27",
+                "symfony/phpunit-bridge": "^6.2.3"
+            },
+            "bin": [
+                "bin/twigcs"
+            ],
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "FriendsOfTwig\\Twigcs\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Tristan Maindron",
+                    "email": "tmaindron@gmail.com"
+                }
+            ],
+            "description": "Checkstyle automation for Twig",
+            "support": {
+                "issues": "https://github.com/friendsoftwig/twigcs/issues",
+                "source": "https://github.com/friendsoftwig/twigcs/tree/6.2.0"
+            },
+            "time": "2023-01-13T16:02:00+00:00"
+        },
+        {
+            "name": "myclabs/deep-copy",
+            "version": "1.11.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/myclabs/DeepCopy.git",
+                "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c",
+                "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^7.1 || ^8.0"
+            },
+            "conflict": {
+                "doctrine/collections": "<1.6.8",
+                "doctrine/common": "<2.13.3 || >=3,<3.2.2"
+            },
+            "require-dev": {
+                "doctrine/collections": "^1.6.8",
+                "doctrine/common": "^2.13.3 || ^3.2.2",
+                "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13"
+            },
+            "type": "library",
+            "autoload": {
+                "files": [
+                    "src/DeepCopy/deep_copy.php"
+                ],
+                "psr-4": {
+                    "DeepCopy\\": "src/DeepCopy/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "description": "Create deep copies (clones) of your objects",
+            "keywords": [
+                "clone",
+                "copy",
+                "duplicate",
+                "object",
+                "object graph"
+            ],
+            "support": {
+                "issues": "https://github.com/myclabs/DeepCopy/issues",
+                "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1"
+            },
+            "funding": [
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2023-03-08T13:26:56+00:00"
+        },
+        {
+            "name": "nikic/php-parser",
+            "version": "v4.15.4",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/nikic/PHP-Parser.git",
+                "reference": "6bb5176bc4af8bcb7d926f88718db9b96a2d4290"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/6bb5176bc4af8bcb7d926f88718db9b96a2d4290",
+                "reference": "6bb5176bc4af8bcb7d926f88718db9b96a2d4290",
+                "shasum": ""
+            },
+            "require": {
+                "ext-tokenizer": "*",
+                "php": ">=7.0"
+            },
+            "require-dev": {
+                "ircmaxell/php-yacc": "^0.0.7",
+                "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0"
+            },
+            "bin": [
+                "bin/php-parse"
+            ],
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "4.9-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "PhpParser\\": "lib/PhpParser"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Nikita Popov"
+                }
+            ],
+            "description": "A PHP parser written in PHP",
+            "keywords": [
+                "parser",
+                "php"
+            ],
+            "support": {
+                "issues": "https://github.com/nikic/PHP-Parser/issues",
+                "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.4"
+            },
+            "time": "2023-03-05T19:49:14+00:00"
+        },
+        {
+            "name": "phar-io/manifest",
+            "version": "2.0.3",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/phar-io/manifest.git",
+                "reference": "97803eca37d319dfa7826cc2437fc020857acb53"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53",
+                "reference": "97803eca37d319dfa7826cc2437fc020857acb53",
+                "shasum": ""
+            },
+            "require": {
+                "ext-dom": "*",
+                "ext-phar": "*",
+                "ext-xmlwriter": "*",
+                "phar-io/version": "^3.0.1",
+                "php": "^7.2 || ^8.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "2.0.x-dev"
+                }
+            },
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Arne Blankerts",
+                    "email": "arne@blankerts.de",
+                    "role": "Developer"
+                },
+                {
+                    "name": "Sebastian Heuer",
+                    "email": "sebastian@phpeople.de",
+                    "role": "Developer"
+                },
+                {
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de",
+                    "role": "Developer"
+                }
+            ],
+            "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
+            "support": {
+                "issues": "https://github.com/phar-io/manifest/issues",
+                "source": "https://github.com/phar-io/manifest/tree/2.0.3"
+            },
+            "time": "2021-07-20T11:28:43+00:00"
+        },
+        {
+            "name": "phar-io/version",
+            "version": "3.2.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/phar-io/version.git",
+                "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74",
+                "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^7.2 || ^8.0"
+            },
+            "type": "library",
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Arne Blankerts",
+                    "email": "arne@blankerts.de",
+                    "role": "Developer"
+                },
+                {
+                    "name": "Sebastian Heuer",
+                    "email": "sebastian@phpeople.de",
+                    "role": "Developer"
+                },
+                {
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de",
+                    "role": "Developer"
+                }
+            ],
+            "description": "Library for handling version information and constraints",
+            "support": {
+                "issues": "https://github.com/phar-io/version/issues",
+                "source": "https://github.com/phar-io/version/tree/3.2.1"
+            },
+            "time": "2022-02-21T01:04:05+00:00"
+        },
+        {
+            "name": "phpstan/phpstan",
+            "version": "1.9.14",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/phpstan/phpstan.git",
+                "reference": "e5fcc96289cf737304286a9b505fbed091f02e58"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e5fcc96289cf737304286a9b505fbed091f02e58",
+                "reference": "e5fcc96289cf737304286a9b505fbed091f02e58",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^7.2|^8.0"
+            },
+            "conflict": {
+                "phpstan/phpstan-shim": "*"
+            },
+            "bin": [
+                "phpstan",
+                "phpstan.phar"
+            ],
+            "type": "library",
+            "autoload": {
+                "files": [
+                    "bootstrap.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "description": "PHPStan - PHP Static Analysis Tool",
+            "keywords": [
+                "dev",
+                "static analysis"
+            ],
+            "support": {
+                "issues": "https://github.com/phpstan/phpstan/issues",
+                "source": "https://github.com/phpstan/phpstan/tree/1.9.14"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/ondrejmirtes",
+                    "type": "github"
+                },
+                {
+                    "url": "https://github.com/phpstan",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2023-01-19T10:47:09+00:00"
+        },
+        {
+            "name": "phpunit/php-code-coverage",
+            "version": "10.0.2",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
+                "reference": "20800e84296ea4732f9a125e08ce86b4004ae3e4"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/20800e84296ea4732f9a125e08ce86b4004ae3e4",
+                "reference": "20800e84296ea4732f9a125e08ce86b4004ae3e4",
+                "shasum": ""
+            },
+            "require": {
+                "ext-dom": "*",
+                "ext-libxml": "*",
+                "ext-xmlwriter": "*",
+                "nikic/php-parser": "^4.15",
+                "php": ">=8.1",
+                "phpunit/php-file-iterator": "^4.0",
+                "phpunit/php-text-template": "^3.0",
+                "sebastian/code-unit-reverse-lookup": "^3.0",
+                "sebastian/complexity": "^3.0",
+                "sebastian/environment": "^6.0",
+                "sebastian/lines-of-code": "^2.0",
+                "sebastian/version": "^4.0",
+                "theseer/tokenizer": "^1.2.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^10.0"
+            },
+            "suggest": {
+                "ext-pcov": "PHP extension that provides line coverage",
+                "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "10.0-dev"
+                }
+            },
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de",
+                    "role": "lead"
+                }
+            ],
+            "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
+            "homepage": "https://github.com/sebastianbergmann/php-code-coverage",
+            "keywords": [
+                "coverage",
+                "testing",
+                "xunit"
+            ],
+            "support": {
+                "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
+                "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.0.2"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/sebastianbergmann",
+                    "type": "github"
+                }
+            ],
+            "time": "2023-03-06T13:00:19+00:00"
+        },
+        {
+            "name": "phpunit/php-file-iterator",
+            "version": "4.0.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/sebastianbergmann/php-file-iterator.git",
+                "reference": "fd9329ab3368f59fe1fe808a189c51086bd4b6bd"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/fd9329ab3368f59fe1fe808a189c51086bd4b6bd",
+                "reference": "fd9329ab3368f59fe1fe808a189c51086bd4b6bd",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=8.1"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^10.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "4.0-dev"
+                }
+            },
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de",
+                    "role": "lead"
+                }
+            ],
+            "description": "FilterIterator implementation that filters files based on a list of suffixes.",
+            "homepage": "https://github.com/sebastianbergmann/php-file-iterator/",
+            "keywords": [
+                "filesystem",
+                "iterator"
+            ],
+            "support": {
+                "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues",
+                "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/4.0.1"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/sebastianbergmann",
+                    "type": "github"
+                }
+            ],
+            "time": "2023-02-10T16:53:14+00:00"
+        },
+        {
+            "name": "phpunit/php-invoker",
+            "version": "4.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/sebastianbergmann/php-invoker.git",
+                "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7",
+                "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=8.1"
+            },
+            "require-dev": {
+                "ext-pcntl": "*",
+                "phpunit/phpunit": "^10.0"
+            },
+            "suggest": {
+                "ext-pcntl": "*"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "4.0-dev"
+                }
+            },
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de",
+                    "role": "lead"
+                }
+            ],
+            "description": "Invoke callables with a timeout",
+            "homepage": "https://github.com/sebastianbergmann/php-invoker/",
+            "keywords": [
+                "process"
+            ],
+            "support": {
+                "issues": "https://github.com/sebastianbergmann/php-invoker/issues",
+                "source": "https://github.com/sebastianbergmann/php-invoker/tree/4.0.0"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/sebastianbergmann",
+                    "type": "github"
+                }
+            ],
+            "time": "2023-02-03T06:56:09+00:00"
+        },
+        {
+            "name": "phpunit/php-text-template",
+            "version": "3.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/sebastianbergmann/php-text-template.git",
+                "reference": "9f3d3709577a527025f55bcf0f7ab8052c8bb37d"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/9f3d3709577a527025f55bcf0f7ab8052c8bb37d",
+                "reference": "9f3d3709577a527025f55bcf0f7ab8052c8bb37d",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=8.1"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^10.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "3.0-dev"
+                }
+            },
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de",
+                    "role": "lead"
+                }
+            ],
+            "description": "Simple template engine.",
+            "homepage": "https://github.com/sebastianbergmann/php-text-template/",
+            "keywords": [
+                "template"
+            ],
+            "support": {
+                "issues": "https://github.com/sebastianbergmann/php-text-template/issues",
+                "source": "https://github.com/sebastianbergmann/php-text-template/tree/3.0.0"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/sebastianbergmann",
+                    "type": "github"
+                }
+            ],
+            "time": "2023-02-03T06:56:46+00:00"
+        },
+        {
+            "name": "phpunit/php-timer",
+            "version": "6.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/sebastianbergmann/php-timer.git",
+                "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/e2a2d67966e740530f4a3343fe2e030ffdc1161d",
+                "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=8.1"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^10.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "6.0-dev"
+                }
+            },
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de",
+                    "role": "lead"
+                }
+            ],
+            "description": "Utility class for timing",
+            "homepage": "https://github.com/sebastianbergmann/php-timer/",
+            "keywords": [
+                "timer"
+            ],
+            "support": {
+                "issues": "https://github.com/sebastianbergmann/php-timer/issues",
+                "source": "https://github.com/sebastianbergmann/php-timer/tree/6.0.0"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/sebastianbergmann",
+                    "type": "github"
+                }
+            ],
+            "time": "2023-02-03T06:57:52+00:00"
+        },
+        {
+            "name": "phpunit/phpunit",
+            "version": "10.0.16",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/sebastianbergmann/phpunit.git",
+                "reference": "07d386a11ac7094032900f07cada1c8975d16607"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/07d386a11ac7094032900f07cada1c8975d16607",
+                "reference": "07d386a11ac7094032900f07cada1c8975d16607",
+                "shasum": ""
+            },
+            "require": {
+                "ext-dom": "*",
+                "ext-json": "*",
+                "ext-libxml": "*",
+                "ext-mbstring": "*",
+                "ext-xml": "*",
+                "ext-xmlwriter": "*",
+                "myclabs/deep-copy": "^1.10.1",
+                "phar-io/manifest": "^2.0.3",
+                "phar-io/version": "^3.0.2",
+                "php": ">=8.1",
+                "phpunit/php-code-coverage": "^10.0",
+                "phpunit/php-file-iterator": "^4.0",
+                "phpunit/php-invoker": "^4.0",
+                "phpunit/php-text-template": "^3.0",
+                "phpunit/php-timer": "^6.0",
+                "sebastian/cli-parser": "^2.0",
+                "sebastian/code-unit": "^2.0",
+                "sebastian/comparator": "^5.0",
+                "sebastian/diff": "^5.0",
+                "sebastian/environment": "^6.0",
+                "sebastian/exporter": "^5.0",
+                "sebastian/global-state": "^6.0",
+                "sebastian/object-enumerator": "^5.0",
+                "sebastian/recursion-context": "^5.0",
+                "sebastian/type": "^4.0",
+                "sebastian/version": "^4.0"
+            },
+            "suggest": {
+                "ext-soap": "To be able to generate mocks based on WSDL files"
+            },
+            "bin": [
+                "phpunit"
+            ],
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "10.0-dev"
+                }
+            },
+            "autoload": {
+                "files": [
+                    "src/Framework/Assert/Functions.php"
+                ],
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de",
+                    "role": "lead"
+                }
+            ],
+            "description": "The PHP Unit Testing framework.",
+            "homepage": "https://phpunit.de/",
+            "keywords": [
+                "phpunit",
+                "testing",
+                "xunit"
+            ],
+            "support": {
+                "issues": "https://github.com/sebastianbergmann/phpunit/issues",
+                "source": "https://github.com/sebastianbergmann/phpunit/tree/10.0.16"
+            },
+            "funding": [
+                {
+                    "url": "https://phpunit.de/sponsors.html",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/sebastianbergmann",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2023-03-13T09:02:40+00:00"
+        },
+        {
+            "name": "sebastian/cli-parser",
+            "version": "2.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/sebastianbergmann/cli-parser.git",
+                "reference": "efdc130dbbbb8ef0b545a994fd811725c5282cae"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/efdc130dbbbb8ef0b545a994fd811725c5282cae",
+                "reference": "efdc130dbbbb8ef0b545a994fd811725c5282cae",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=8.1"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^10.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "2.0-dev"
+                }
+            },
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de",
+                    "role": "lead"
+                }
+            ],
+            "description": "Library for parsing CLI options",
+            "homepage": "https://github.com/sebastianbergmann/cli-parser",
+            "support": {
+                "issues": "https://github.com/sebastianbergmann/cli-parser/issues",
+                "source": "https://github.com/sebastianbergmann/cli-parser/tree/2.0.0"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/sebastianbergmann",
+                    "type": "github"
+                }
+            ],
+            "time": "2023-02-03T06:58:15+00:00"
+        },
+        {
+            "name": "sebastian/code-unit",
+            "version": "2.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/sebastianbergmann/code-unit.git",
+                "reference": "a81fee9eef0b7a76af11d121767abc44c104e503"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/a81fee9eef0b7a76af11d121767abc44c104e503",
+                "reference": "a81fee9eef0b7a76af11d121767abc44c104e503",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=8.1"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^10.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "2.0-dev"
+                }
+            },
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de",
+                    "role": "lead"
+                }
+            ],
+            "description": "Collection of value objects that represent the PHP code units",
+            "homepage": "https://github.com/sebastianbergmann/code-unit",
+            "support": {
+                "issues": "https://github.com/sebastianbergmann/code-unit/issues",
+                "source": "https://github.com/sebastianbergmann/code-unit/tree/2.0.0"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/sebastianbergmann",
+                    "type": "github"
+                }
+            ],
+            "time": "2023-02-03T06:58:43+00:00"
+        },
+        {
+            "name": "sebastian/code-unit-reverse-lookup",
+            "version": "3.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git",
+                "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/5e3a687f7d8ae33fb362c5c0743794bbb2420a1d",
+                "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=8.1"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^10.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "3.0-dev"
+                }
+            },
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de"
+                }
+            ],
+            "description": "Looks up which function or method a line of code belongs to",
+            "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
+            "support": {
+                "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues",
+                "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/3.0.0"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/sebastianbergmann",
+                    "type": "github"
+                }
+            ],
+            "time": "2023-02-03T06:59:15+00:00"
+        },
+        {
+            "name": "sebastian/comparator",
+            "version": "5.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/sebastianbergmann/comparator.git",
+                "reference": "72f01e6586e0caf6af81297897bd112eb7e9627c"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/72f01e6586e0caf6af81297897bd112eb7e9627c",
+                "reference": "72f01e6586e0caf6af81297897bd112eb7e9627c",
+                "shasum": ""
+            },
+            "require": {
+                "ext-dom": "*",
+                "ext-mbstring": "*",
+                "php": ">=8.1",
+                "sebastian/diff": "^5.0",
+                "sebastian/exporter": "^5.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^10.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "5.0-dev"
+                }
+            },
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de"
+                },
+                {
+                    "name": "Jeff Welch",
+                    "email": "whatthejeff@gmail.com"
+                },
+                {
+                    "name": "Volker Dusch",
+                    "email": "github@wallbash.com"
+                },
+                {
+                    "name": "Bernhard Schussek",
+                    "email": "bschussek@2bepublished.at"
+                }
+            ],
+            "description": "Provides the functionality to compare PHP values for equality",
+            "homepage": "https://github.com/sebastianbergmann/comparator",
+            "keywords": [
+                "comparator",
+                "compare",
+                "equality"
+            ],
+            "support": {
+                "issues": "https://github.com/sebastianbergmann/comparator/issues",
+                "source": "https://github.com/sebastianbergmann/comparator/tree/5.0.0"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/sebastianbergmann",
+                    "type": "github"
+                }
+            ],
+            "time": "2023-02-03T07:07:16+00:00"
+        },
+        {
+            "name": "sebastian/complexity",
+            "version": "3.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/sebastianbergmann/complexity.git",
+                "reference": "e67d240970c9dc7ea7b2123a6d520e334dd61dc6"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/e67d240970c9dc7ea7b2123a6d520e334dd61dc6",
+                "reference": "e67d240970c9dc7ea7b2123a6d520e334dd61dc6",
+                "shasum": ""
+            },
+            "require": {
+                "nikic/php-parser": "^4.10",
+                "php": ">=8.1"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^10.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "3.0-dev"
+                }
+            },
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de",
+                    "role": "lead"
+                }
+            ],
+            "description": "Library for calculating the complexity of PHP code units",
+            "homepage": "https://github.com/sebastianbergmann/complexity",
+            "support": {
+                "issues": "https://github.com/sebastianbergmann/complexity/issues",
+                "source": "https://github.com/sebastianbergmann/complexity/tree/3.0.0"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/sebastianbergmann",
+                    "type": "github"
+                }
+            ],
+            "time": "2023-02-03T06:59:47+00:00"
+        },
+        {
+            "name": "sebastian/diff",
+            "version": "5.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/sebastianbergmann/diff.git",
+                "reference": "70dd1b20bc198da394ad542e988381b44e64e39f"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/70dd1b20bc198da394ad542e988381b44e64e39f",
+                "reference": "70dd1b20bc198da394ad542e988381b44e64e39f",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=8.1"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^10.0",
+                "symfony/process": "^4.2 || ^5"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "5.0-dev"
+                }
+            },
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de"
+                },
+                {
+                    "name": "Kore Nordmann",
+                    "email": "mail@kore-nordmann.de"
+                }
+            ],
+            "description": "Diff implementation",
+            "homepage": "https://github.com/sebastianbergmann/diff",
+            "keywords": [
+                "diff",
+                "udiff",
+                "unidiff",
+                "unified diff"
+            ],
+            "support": {
+                "issues": "https://github.com/sebastianbergmann/diff/issues",
+                "source": "https://github.com/sebastianbergmann/diff/tree/5.0.0"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/sebastianbergmann",
+                    "type": "github"
+                }
+            ],
+            "time": "2023-02-03T07:00:31+00:00"
+        },
+        {
+            "name": "sebastian/environment",
+            "version": "6.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/sebastianbergmann/environment.git",
+                "reference": "b6f3694c6386c7959915a0037652e0c40f6f69cc"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/b6f3694c6386c7959915a0037652e0c40f6f69cc",
+                "reference": "b6f3694c6386c7959915a0037652e0c40f6f69cc",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=8.1"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^10.0"
+            },
+            "suggest": {
+                "ext-posix": "*"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "6.0-dev"
+                }
+            },
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de"
+                }
+            ],
+            "description": "Provides functionality to handle HHVM/PHP environments",
+            "homepage": "https://github.com/sebastianbergmann/environment",
+            "keywords": [
+                "Xdebug",
+                "environment",
+                "hhvm"
+            ],
+            "support": {
+                "issues": "https://github.com/sebastianbergmann/environment/issues",
+                "source": "https://github.com/sebastianbergmann/environment/tree/6.0.0"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/sebastianbergmann",
+                    "type": "github"
+                }
+            ],
+            "time": "2023-02-03T07:03:04+00:00"
+        },
+        {
+            "name": "sebastian/exporter",
+            "version": "5.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/sebastianbergmann/exporter.git",
+                "reference": "f3ec4bf931c0b31e5b413f5b4fc970a7d03338c0"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/f3ec4bf931c0b31e5b413f5b4fc970a7d03338c0",
+                "reference": "f3ec4bf931c0b31e5b413f5b4fc970a7d03338c0",
+                "shasum": ""
+            },
+            "require": {
+                "ext-mbstring": "*",
+                "php": ">=8.1",
+                "sebastian/recursion-context": "^5.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^10.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "5.0-dev"
+                }
+            },
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de"
+                },
+                {
+                    "name": "Jeff Welch",
+                    "email": "whatthejeff@gmail.com"
+                },
+                {
+                    "name": "Volker Dusch",
+                    "email": "github@wallbash.com"
+                },
+                {
+                    "name": "Adam Harvey",
+                    "email": "aharvey@php.net"
+                },
+                {
+                    "name": "Bernhard Schussek",
+                    "email": "bschussek@gmail.com"
+                }
+            ],
+            "description": "Provides the functionality to export PHP variables for visualization",
+            "homepage": "https://www.github.com/sebastianbergmann/exporter",
+            "keywords": [
+                "export",
+                "exporter"
+            ],
+            "support": {
+                "issues": "https://github.com/sebastianbergmann/exporter/issues",
+                "source": "https://github.com/sebastianbergmann/exporter/tree/5.0.0"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/sebastianbergmann",
+                    "type": "github"
+                }
+            ],
+            "time": "2023-02-03T07:06:49+00:00"
+        },
+        {
+            "name": "sebastian/global-state",
+            "version": "6.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/sebastianbergmann/global-state.git",
+                "reference": "aab257c712de87b90194febd52e4d184551c2d44"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/aab257c712de87b90194febd52e4d184551c2d44",
+                "reference": "aab257c712de87b90194febd52e4d184551c2d44",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=8.1",
+                "sebastian/object-reflector": "^3.0",
+                "sebastian/recursion-context": "^5.0"
+            },
+            "require-dev": {
+                "ext-dom": "*",
+                "phpunit/phpunit": "^10.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "6.0-dev"
+                }
+            },
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de"
+                }
+            ],
+            "description": "Snapshotting of global state",
+            "homepage": "http://www.github.com/sebastianbergmann/global-state",
+            "keywords": [
+                "global state"
+            ],
+            "support": {
+                "issues": "https://github.com/sebastianbergmann/global-state/issues",
+                "source": "https://github.com/sebastianbergmann/global-state/tree/6.0.0"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/sebastianbergmann",
+                    "type": "github"
+                }
+            ],
+            "time": "2023-02-03T07:07:38+00:00"
+        },
+        {
+            "name": "sebastian/lines-of-code",
+            "version": "2.0.0",
             "source": {
                 "type": "git",
-                "url": "https://github.com/atoum/atoum.git",
-                "reference": "e866f3d4ad683c35757cd73fc6da3e3d5e563667"
+                "url": "https://github.com/sebastianbergmann/lines-of-code.git",
+                "reference": "17c4d940ecafb3d15d2cf916f4108f664e28b130"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/atoum/atoum/zipball/e866f3d4ad683c35757cd73fc6da3e3d5e563667",
-                "reference": "e866f3d4ad683c35757cd73fc6da3e3d5e563667",
+                "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/17c4d940ecafb3d15d2cf916f4108f664e28b130",
+                "reference": "17c4d940ecafb3d15d2cf916f4108f664e28b130",
                 "shasum": ""
             },
             "require": {
-                "ext-hash": "*",
-                "ext-json": "*",
-                "ext-tokenizer": "*",
-                "ext-xml": "*",
-                "php": "^7.4 || ^8.0"
+                "nikic/php-parser": "^4.10",
+                "php": ">=8.1"
             },
-            "replace": {
-                "mageekguy/atoum": "*"
+            "require-dev": {
+                "phpunit/phpunit": "^10.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "2.0-dev"
+                }
+            },
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de",
+                    "role": "lead"
+                }
+            ],
+            "description": "Library for counting the lines of code in PHP source code",
+            "homepage": "https://github.com/sebastianbergmann/lines-of-code",
+            "support": {
+                "issues": "https://github.com/sebastianbergmann/lines-of-code/issues",
+                "source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.0"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/sebastianbergmann",
+                    "type": "github"
+                }
+            ],
+            "time": "2023-02-03T07:08:02+00:00"
+        },
+        {
+            "name": "sebastian/object-enumerator",
+            "version": "5.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/sebastianbergmann/object-enumerator.git",
+                "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/202d0e344a580d7f7d04b3fafce6933e59dae906",
+                "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=8.1",
+                "sebastian/object-reflector": "^3.0",
+                "sebastian/recursion-context": "^5.0"
             },
             "require-dev": {
-                "friendsofphp/php-cs-fixer": "^3.2"
+                "phpunit/phpunit": "^10.0"
             },
-            "suggest": {
-                "atoum/stubs": "Provides IDE support (like autocompletion) for atoum",
-                "ext-mbstring": "Provides support for UTF-8 strings",
-                "ext-xdebug": "Provides code coverage report (>= 2.3)"
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "5.0-dev"
+                }
             },
-            "default-branch": true,
-            "bin": [
-                "bin/atoum"
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de"
+                }
+            ],
+            "description": "Traverses array structures and object graphs to enumerate all referenced objects",
+            "homepage": "https://github.com/sebastianbergmann/object-enumerator/",
+            "support": {
+                "issues": "https://github.com/sebastianbergmann/object-enumerator/issues",
+                "source": "https://github.com/sebastianbergmann/object-enumerator/tree/5.0.0"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/sebastianbergmann",
+                    "type": "github"
+                }
             ],
+            "time": "2023-02-03T07:08:32+00:00"
+        },
+        {
+            "name": "sebastian/object-reflector",
+            "version": "3.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/sebastianbergmann/object-reflector.git",
+                "reference": "24ed13d98130f0e7122df55d06c5c4942a577957"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/24ed13d98130f0e7122df55d06c5c4942a577957",
+                "reference": "24ed13d98130f0e7122df55d06c5c4942a577957",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=8.1"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^10.0"
+            },
             "type": "library",
             "extra": {
                 "branch-alias": {
-                    "dev-master": "4.x-dev"
+                    "dev-main": "3.0-dev"
                 }
             },
             "autoload": {
                 "classmap": [
-                    "classes/"
+                    "src/"
                 ]
             },
             "notification-url": "https://packagist.org/downloads/",
             ],
             "authors": [
                 {
-                    "name": "Frédéric Hardy",
-                    "email": "frederic.hardy@atoum.org",
-                    "homepage": "http://blog.mageekbox.net"
-                },
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de"
+                }
+            ],
+            "description": "Allows reflection of object attributes, including inherited and non-public ones",
+            "homepage": "https://github.com/sebastianbergmann/object-reflector/",
+            "support": {
+                "issues": "https://github.com/sebastianbergmann/object-reflector/issues",
+                "source": "https://github.com/sebastianbergmann/object-reflector/tree/3.0.0"
+            },
+            "funding": [
                 {
-                    "name": "François Dussert",
-                    "email": "francois.dussert@atoum.org"
-                },
+                    "url": "https://github.com/sebastianbergmann",
+                    "type": "github"
+                }
+            ],
+            "time": "2023-02-03T07:06:18+00:00"
+        },
+        {
+            "name": "sebastian/recursion-context",
+            "version": "5.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/sebastianbergmann/recursion-context.git",
+                "reference": "05909fb5bc7df4c52992396d0116aed689f93712"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/05909fb5bc7df4c52992396d0116aed689f93712",
+                "reference": "05909fb5bc7df4c52992396d0116aed689f93712",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=8.1"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^10.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "5.0-dev"
+                }
+            },
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
                 {
-                    "name": "Gérald Croes",
-                    "email": "gerald.croes@atoum.org"
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de"
                 },
                 {
-                    "name": "Julien Bianchi",
-                    "email": "julien.bianchi@atoum.org"
+                    "name": "Jeff Welch",
+                    "email": "whatthejeff@gmail.com"
                 },
                 {
-                    "name": "Ludovic Fleury",
-                    "email": "ludovic.fleury@atoum.org"
+                    "name": "Adam Harvey",
+                    "email": "aharvey@php.net"
                 }
             ],
-            "description": "Simple modern and intuitive unit testing framework for PHP 5.3+",
-            "homepage": "http://www.atoum.org",
-            "keywords": [
-                "TDD",
-                "atoum",
-                "test",
-                "unit testing"
-            ],
+            "description": "Provides functionality to recursively process PHP variables",
+            "homepage": "https://github.com/sebastianbergmann/recursion-context",
             "support": {
-                "issues": "https://github.com/atoum/atoum/issues",
-                "source": "https://github.com/atoum/atoum/tree/4.1.0"
+                "issues": "https://github.com/sebastianbergmann/recursion-context/issues",
+                "source": "https://github.com/sebastianbergmann/recursion-context/tree/5.0.0"
             },
-            "time": "2022-11-20T20:18:31+00:00"
+            "funding": [
+                {
+                    "url": "https://github.com/sebastianbergmann",
+                    "type": "github"
+                }
+            ],
+            "time": "2023-02-03T07:05:40+00:00"
         },
         {
-            "name": "friendsoftwig/twigcs",
-            "version": "6.2.0",
+            "name": "sebastian/type",
+            "version": "4.0.0",
             "source": {
                 "type": "git",
-                "url": "https://github.com/friendsoftwig/twigcs.git",
-                "reference": "da697cc1bf6bf22feb1d8dbefcbdb1451e6a35f6"
+                "url": "https://github.com/sebastianbergmann/type.git",
+                "reference": "462699a16464c3944eefc02ebdd77882bd3925bf"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/friendsoftwig/twigcs/zipball/da697cc1bf6bf22feb1d8dbefcbdb1451e6a35f6",
-                "reference": "da697cc1bf6bf22feb1d8dbefcbdb1451e6a35f6",
+                "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/462699a16464c3944eefc02ebdd77882bd3925bf",
+                "reference": "462699a16464c3944eefc02ebdd77882bd3925bf",
                 "shasum": ""
             },
             "require": {
-                "ext-ctype": "*",
-                "ext-hash": "*",
-                "ext-json": "*",
-                "ext-mbstring": "*",
-                "ext-simplexml": "*",
-                "php": "~8.0.0 || ~8.1.0 || ~8.2.0",
-                "symfony/console": "^4.4 || ^5.3 || ^6.0",
-                "symfony/filesystem": "^4.4 || ^5.3 || ^6.0",
-                "symfony/finder": "^4.4 || ^5.3 || ^6.0"
+                "php": ">=8.1"
             },
             "require-dev": {
-                "phpunit/phpunit": "^9.5.27",
-                "symfony/phpunit-bridge": "^6.2.3"
+                "phpunit/phpunit": "^10.0"
             },
-            "bin": [
-                "bin/twigcs"
-            ],
             "type": "library",
-            "autoload": {
-                "psr-4": {
-                    "FriendsOfTwig\\Twigcs\\": "src/"
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "4.0-dev"
                 }
             },
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
             "notification-url": "https://packagist.org/downloads/",
             "license": [
-                "MIT"
+                "BSD-3-Clause"
             ],
             "authors": [
                 {
-                    "name": "Tristan Maindron",
-                    "email": "tmaindron@gmail.com"
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de",
+                    "role": "lead"
                 }
             ],
-            "description": "Checkstyle automation for Twig",
+            "description": "Collection of value objects that represent the types of the PHP type system",
+            "homepage": "https://github.com/sebastianbergmann/type",
             "support": {
-                "issues": "https://github.com/friendsoftwig/twigcs/issues",
-                "source": "https://github.com/friendsoftwig/twigcs/tree/6.2.0"
+                "issues": "https://github.com/sebastianbergmann/type/issues",
+                "source": "https://github.com/sebastianbergmann/type/tree/4.0.0"
             },
-            "time": "2023-01-13T16:02:00+00:00"
+            "funding": [
+                {
+                    "url": "https://github.com/sebastianbergmann",
+                    "type": "github"
+                }
+            ],
+            "time": "2023-02-03T07:10:45+00:00"
         },
         {
-            "name": "phpstan/phpstan",
-            "version": "1.9.14",
+            "name": "sebastian/version",
+            "version": "4.0.1",
             "source": {
                 "type": "git",
-                "url": "https://github.com/phpstan/phpstan.git",
-                "reference": "e5fcc96289cf737304286a9b505fbed091f02e58"
+                "url": "https://github.com/sebastianbergmann/version.git",
+                "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e5fcc96289cf737304286a9b505fbed091f02e58",
-                "reference": "e5fcc96289cf737304286a9b505fbed091f02e58",
+                "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c51fa83a5d8f43f1402e3f32a005e6262244ef17",
+                "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17",
                 "shasum": ""
             },
             "require": {
-                "php": "^7.2|^8.0"
-            },
-            "conflict": {
-                "phpstan/phpstan-shim": "*"
+                "php": ">=8.1"
             },
-            "bin": [
-                "phpstan",
-                "phpstan.phar"
-            ],
             "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "4.0-dev"
+                }
+            },
             "autoload": {
-                "files": [
-                    "bootstrap.php"
+                "classmap": [
+                    "src/"
                 ]
             },
             "notification-url": "https://packagist.org/downloads/",
             "license": [
-                "MIT"
+                "BSD-3-Clause"
             ],
-            "description": "PHPStan - PHP Static Analysis Tool",
-            "keywords": [
-                "dev",
-                "static analysis"
+            "authors": [
+                {
+                    "name": "Sebastian Bergmann",
+                    "email": "sebastian@phpunit.de",
+                    "role": "lead"
+                }
             ],
+            "description": "Library that helps with managing the version number of Git-hosted PHP projects",
+            "homepage": "https://github.com/sebastianbergmann/version",
             "support": {
-                "issues": "https://github.com/phpstan/phpstan/issues",
-                "source": "https://github.com/phpstan/phpstan/tree/1.9.14"
+                "issues": "https://github.com/sebastianbergmann/version/issues",
+                "source": "https://github.com/sebastianbergmann/version/tree/4.0.1"
             },
             "funding": [
                 {
-                    "url": "https://github.com/ondrejmirtes",
-                    "type": "github"
-                },
-                {
-                    "url": "https://github.com/phpstan",
+                    "url": "https://github.com/sebastianbergmann",
                     "type": "github"
-                },
-                {
-                    "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan",
-                    "type": "tidelift"
                 }
             ],
-            "time": "2023-01-19T10:47:09+00:00"
+            "time": "2023-02-07T11:34:05+00:00"
         },
         {
             "name": "squizlabs/php_codesniffer",
                 }
             ],
             "time": "2022-12-14T16:11:27+00:00"
+        },
+        {
+            "name": "theseer/tokenizer",
+            "version": "1.2.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/theseer/tokenizer.git",
+                "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e",
+                "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e",
+                "shasum": ""
+            },
+            "require": {
+                "ext-dom": "*",
+                "ext-tokenizer": "*",
+                "ext-xmlwriter": "*",
+                "php": "^7.2 || ^8.0"
+            },
+            "type": "library",
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Arne Blankerts",
+                    "email": "arne@blankerts.de",
+                    "role": "Developer"
+                }
+            ],
+            "description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
+            "support": {
+                "issues": "https://github.com/theseer/tokenizer/issues",
+                "source": "https://github.com/theseer/tokenizer/tree/1.2.1"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/theseer",
+                    "type": "github"
+                }
+            ],
+            "time": "2021-07-28T10:34:58+00:00"
         }
     ],
     "aliases": [],
     "minimum-stability": "stable",
-    "stability-flags": {
-        "atoum/atoum": 20
-    },
+    "stability-flags": [],
     "prefer-stable": false,
     "prefer-lowest": false,
     "platform": {
index e6667367d66513285a362e936bef3d546f490529..d485694689fec610ea23d01b724a4f9884014d6b 100644 (file)
@@ -286,7 +286,7 @@ $container->set(
 $container->set('Galette\Core\History', \DI\autowire());
 
 $container->set('acls', function (ContainerInterface $c) {
-    include_once GALETTE_ROOT . 'includes/core_acls.php';
+    include GALETTE_ROOT . 'includes/core_acls.php';
     $acls = $core_acls;
 
     foreach ($c->get('plugins')->getModules() as $plugin) {
@@ -311,7 +311,7 @@ $container->set('texts_fields', function (ContainerInterface $c) {
 });
 
 $container->set('members_fields', function (ContainerInterface $c) {
-    include_once GALETTE_ROOT . 'includes/fields_defs/members_fields.php';
+    include GALETTE_ROOT . 'includes/fields_defs/members_fields.php';
     return $members_fields;
 });
 
@@ -326,7 +326,7 @@ $container->set('members_form_fields', function (ContainerInterface $c) {
 });
 
 $container->set('members_fields_cats', function (ContainerInterface $c) {
-    include_once GALETTE_ROOT . 'includes/fields_defs/members_fields_cats.php';
+    include GALETTE_ROOT . 'includes/fields_defs/members_fields_cats.php';
     return $members_fields_cats;
 });
 
index fd3d43aa54deee70229cc124ef347df01473b2fe..73985c30d4fa65ce449814ac4d231b1855238b16 100644 (file)
@@ -102,8 +102,8 @@ class CheckModules
                     $mstring = _T("either 'mysql' or 'pgsql' PDO driver");
                 }
                 if (
-                    !extension_loaded('pdo_mysql')
-                    && !extension_loaded('pdo_pgsql')
+                    !$this->isExtensionLoaded('pdo_mysql')
+                    && !$this->isExtensionLoaded('pdo_pgsql')
                 ) {
                     $this->missing[] = $mstring;
                 } else {
@@ -111,7 +111,7 @@ class CheckModules
                 }
             } else {
                 $mstring = str_replace('%s', $name, $string);
-                if (!extension_loaded($name)) {
+                if (!$this->isExtensionLoaded($name)) {
                     if ($required) {
                         $this->missing[] = $mstring;
                     } else {
@@ -211,4 +211,16 @@ class CheckModules
     {
         return $this->missing;
     }
+
+    /**
+     * Check if a module is loaded
+     *
+     * @param string $ext Module name
+     *
+     * @return bool
+     */
+    protected function isExtensionLoaded(string $ext): bool
+    {
+        return extension_loaded($ext);
+    }
 }
index 3dcd5324c961f01b724df5e4362c5599a8a4e31b..bab8414900deef867bf49bfe2461faa12e8e5037 100644 (file)
@@ -189,7 +189,7 @@ class News
     private function parseFeed()
     {
         try {
-            if (!ini_get('allow_url_fopen')) {
+            if (!$this->allowURLFOpen()) {
                 throw new \RuntimeException(
                     'allow_url_fopen is set to false; cannot load news.'
                 );
@@ -296,4 +296,14 @@ class News
 
         return $url;
     }
+
+    /**
+     * Check if allow_url_fopen is enabled
+     *
+     * @return boolean
+     */
+    protected function allowURLFOpen(): bool
+    {
+        return ini_get('allow_url_fopen');
+    }
 }
index 34057ce3756b4d8e27dc1441b971d3ef8b120cf0..5239fffe506f87e04349395ffac8d1deff117a57 100644 (file)
@@ -181,7 +181,6 @@ class Authenticate
                             _T("Unknown ACL rule '%acl'!")
                         )
                     );
-                    break;
             }
             if (!$go) {
                 Analog::log(
@@ -219,8 +218,7 @@ class Authenticate
             foreach ($this->acls as $regex => $route_acl) {
                 if (preg_match('@/(.+)/[imsxADU]?@', $regex)) {
                     //looks like a regular expression, go
-                    $matches = [];
-                    if (preg_match($regex, $name, $matches)) {
+                    if (preg_match($regex, $name)) {
                         return $route_acl;
                     }
                 }
index 528586a133855cb9068ffb258f50451c788f5e3f..46bfa44353638b1191b47df2d67ae78dbc20ab72 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\Controllers\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 use Galette\GaletteTestCase;
 use Slim\Psr7\Headers;
 use Slim\Psr7\Request;
@@ -61,13 +61,11 @@ class PdfController extends GaletteTestCase
     /**
      * Set up tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
-        parent::beforeTestMethod($method);
+        parent::setUp();
 
         $this->initModels();
         $this->initStatus();
@@ -86,7 +84,7 @@ class PdfController extends GaletteTestCase
      *
      * @return void
      */
-    public function tearDown()
+    public function tearDown(): void
     {
         $this->zdb = new \Galette\Core\Db();
 
@@ -101,6 +99,17 @@ class PdfController extends GaletteTestCase
         $this->cleanHistory();
     }
 
+    /**
+     * Cleanup after class
+     *
+     * @return void
+     */
+    public static function tearDownAfterClass(): void
+    {
+        $self = new self(__METHOD__);
+        $self->tearDown();
+    }
+
     /**
      * Test store models
      *
@@ -109,7 +118,7 @@ class PdfController extends GaletteTestCase
     public function testStoreModels()
     {
         $model = new \Galette\Entity\PdfInvoice($this->zdb, $this->preferences);
-        $this->string($model->title)->isIdenticalTo('_T("Invoice") {CONTRIBUTION_YEAR}-{CONTRIBUTION_ID}');
+        $this->assertSame('_T("Invoice") {CONTRIBUTION_YEAR}-{CONTRIBUTION_ID}', $model->title);
 
         $ufactory = new \Slim\Psr7\Factory\UriFactory();
         $sfactory = new \Slim\Psr7\Factory\StreamFactory();
@@ -135,14 +144,17 @@ class PdfController extends GaletteTestCase
         $controller = new \Galette\Controllers\PdfController($this->container);
 
         $test_response = $controller->storeModels($request, $response);
-        $this->array($this->flash_data['slimFlash'])->isIdenticalTo([
-            'success_detected' => [
-                'Model has been successfully stored!'
-            ]
-        ]);
+        $this->assertSame(
+            [
+                'success_detected' => [
+                    'Model has been successfully stored!'
+                ]
+            ],
+            $this->flash_data['slimFlash']
+        );
 
         $model = new \Galette\Entity\PdfInvoice($this->zdb, $this->preferences);
-        $this->string($model->title)->isIdenticalTo('DaTitle');
+        $this->assertSame('DaTitle', $model->title);
     }
 
     /**
@@ -171,57 +183,83 @@ class PdfController extends GaletteTestCase
 
         //test with non-logged-in user
         $test_response = $controller->membersCards($request, $response, $this->adh->id);
-        $this->array($test_response->getHeaders())->isIdenticalTo(['Location' => ['/member/me']]);
-        $this->integer($test_response->getStatusCode())->isIdenticalTo(200);
-        $this->array($this->flash_data['slimFlash'])->isIdenticalTo([
-            'error_detected' => [
-                'You do not have permission for requested URL.'
-            ]
-        ]);
+        $this->assertSame(['Location' => ['/member/me']], $test_response->getHeaders());
+        $this->assertSame(200, $test_response->getStatusCode());
+        $this->assertSame(
+            [
+                'error_detected' => [
+                    'You do not have permission for requested URL.'
+                ]
+            ],
+            $this->flash_data['slimFlash']
+        );
         $this->flash_data = [];
 
         //test logged-in as superadmin
         $this->logSuperAdmin();
         $test_response = null;
-        $this
-            ->output(
-                function () use ($controller, $request, $response, &$test_response) {
-                    $test_response = $controller->membersCards($request, $response, $this->adh->id);
-                }
-            )->isNotEmpty();
 
-        $this->integer($test_response->getStatusCode())->isIdenticalTo(200);
-        $this->string($test_response->getHeader('Content-type')[0])->isIdenticalTo('application/pdf');
-        $this->string($test_response->getHeader('Content-Disposition')[0])->isIdenticalTo('attachment;filename="cards.pdf"');
+        $this->expectOutputRegex('/^%PDF-\d\.\d\.');
+        $test_response = $controller->membersCards($request, $response, $this->adh->id);
+
+        $this->assertSame(200, $test_response->getStatusCode());
+        $this->assertSame('application/pdf', $test_response->getHeader('Content-type')[0]);
+        $this->assertSame('attachment;filename="cards.pdf"', $test_response->getHeader('Content-Disposition')[0]);
 
         //test no selection
-        $test_response = null;
         $test_response = $controller->membersCards($request, $response);
-        $this->array($test_response->getHeaders())->isIdenticalTo(['Location' => ['/members']]);
-        $this->integer($test_response->getStatusCode())->isIdenticalTo(301);
-        $this->array($this->flash_data['slimFlash'])->isIdenticalTo([
-            'error_detected' => [
-                'No member was selected, please check at least one name.'
-            ]
-        ]);
+        $this->assertSame(['Location' => ['/members']], $test_response->getHeaders());
+        $this->assertSame(301, $test_response->getStatusCode());
+        $this->assertSame(
+            [
+                'error_detected' => [
+                    'No member was selected, please check at least one name.'
+                ]
+            ],
+            $this->flash_data['slimFlash']
+        );
         $this->flash_data = [];
+    }
 
-        //test again from filters
-        $test_response = null;
+    /**
+     * Test filtered membersCards
+     *
+     * @return void
+     */
+    public function testFilteredMembersCards()
+    {
+        $this->getMemberOne();
+
+        $ufactory = new \Slim\Psr7\Factory\UriFactory();
+        $sfactory = new \Slim\Psr7\Factory\StreamFactory();
+
+        $request = new Request(
+            'POST',
+            $ufactory->createUri('/members/card/' . $this->adh->id),
+            new Headers(['Content-Type' => ['text/html']]),
+            [],
+            [],
+            $sfactory->createStream()
+        );
+
+        $response = new \Slim\Psr7\Response();
+        $controller = new \Galette\Controllers\PdfController($this->container);
+
+        //test logged-in as superadmin
+        $this->logSuperAdmin();
+
+        //test with filters
         $filters = new \Galette\Filters\MembersList();
         $filters->selected = [$this->adh->id];
         $this->session->filter_members = $filters;
-        $this
-            ->output(
-                function () use ($controller, $request, $response, &$test_response) {
-                    $test_response = $controller->membersCards($request, $response);
-                }
-            )->isNotEmpty();
+
+        $this->expectOutputRegex('/^%PDF-\d.\d.');
+        $test_response = $controller->membersCards($request, $response);
 
         unset($this->session->filter_members);
-        $this->integer($test_response->getStatusCode())->isIdenticalTo(200);
-        $this->string($test_response->getHeader('Content-type')[0])->isIdenticalTo('application/pdf');
-        $this->string($test_response->getHeader('Content-Disposition')[0])->isIdenticalTo('attachment;filename="cards.pdf"');
+        $this->assertSame(200, $test_response->getStatusCode());
+        $this->assertSame('application/pdf', $test_response->getHeader('Content-type')[0]);
+        $this->assertSame('attachment;filename="cards.pdf"', $test_response->getHeader('Content-Disposition')[0]);
     }
 
     /**
@@ -251,13 +289,16 @@ class PdfController extends GaletteTestCase
 
         //test with non-logged-in user
         $test_response = $controller->membersLabels($request, $response, $this->adh->id);
-        $this->array($test_response->getHeaders())->isIdenticalTo(['Location' => ['/members']]);
-        $this->integer($test_response->getStatusCode())->isIdenticalTo(301);
-        $this->array($this->flash_data['slimFlash'])->isIdenticalTo([
-            'error_detected' => [
-                'No member was selected, please check at least one name.'
-            ]
-        ]);
+        $this->assertSame(['Location' => ['/members']], $test_response->getHeaders());
+        $this->assertSame(301, $test_response->getStatusCode());
+        $this->assertSame(
+            [
+                'error_detected' => [
+                    'No member was selected, please check at least one name.'
+                ]
+            ],
+            $this->flash_data['slimFlash']
+        );
         $this->flash_data = [];
 
         //test again from filters
@@ -265,16 +306,13 @@ class PdfController extends GaletteTestCase
         $filters = new \Galette\Filters\MembersList();
         $filters->selected = [$this->adh->id];
         $this->session->filter_members = $filters;
-        $this
-            ->output(
-                function () use ($controller, $request, $response, &$test_response) {
-                    $test_response = $controller->membersLabels($request, $response);
-                }
-            )->isNotEmpty();
-
-        $this->integer($test_response->getStatusCode())->isIdenticalTo(200);
-        $this->string($test_response->getHeader('Content-type')[0])->isIdenticalTo('application/pdf');
-        $this->string($test_response->getHeader('Content-Disposition')[0])->isIdenticalTo('attachment;filename="labels_print_filename.pdf"');
+
+        $this->expectOutputRegex('/^%PDF-\d\.\d');
+        $test_response = $controller->membersLabels($request, $response);
+
+        $this->assertSame(200, $test_response->getStatusCode());
+        $this->assertSame('application/pdf', $test_response->getHeader('Content-type')[0]);
+        $this->assertSame('attachment;filename="labels_print_filename.pdf"', $test_response->getHeader('Content-Disposition')[0]);
         unset($this->session->filter_members);
 
         //test logged-in as superadmin
@@ -282,30 +320,58 @@ class PdfController extends GaletteTestCase
         //test no selection
         $test_response = null;
         $test_response = $controller->membersCards($request, $response);
-        $this->array($test_response->getHeaders())->isIdenticalTo(['Location' => ['/members']]);
-        $this->integer($test_response->getStatusCode())->isIdenticalTo(301);
-        $this->array($this->flash_data['slimFlash'])->isIdenticalTo([
-            'error_detected' => [
-                'No member was selected, please check at least one name.'
-            ]
-        ]);
+        $this->assertSame(['Location' => ['/members']], $test_response->getHeaders());
+        $this->assertSame(301, $test_response->getStatusCode());
+        $this->assertSame(
+            [
+                'error_detected' => [
+                    'No member was selected, please check at least one name.'
+                ]
+            ],
+            $this->flash_data['slimFlash']
+        );
         $this->flash_data = [];
+    }
+
+    /**
+     * Test filtered membersLabels
+     *
+     * @return void
+     */
+    public function testFilteredMembersLabels()
+    {
+        unset($this->session->filter_members);
+        $this->getMemberOne();
+
+        $ufactory = new \Slim\Psr7\Factory\UriFactory();
+        $sfactory = new \Slim\Psr7\Factory\StreamFactory();
+
+        $request = new Request(
+            'POST',
+            $ufactory->createUri('/members/labels'),
+            new Headers(['Content-Type' => ['text/html']]),
+            [],
+            [],
+            $sfactory->createStream()
+        );
+
+        $response = new \Slim\Psr7\Response();
+        $controller = new \Galette\Controllers\PdfController($this->container);
+
+        //test logged-in as superadmin
+        $this->logSuperAdmin();
 
         //test again from filters
-        $test_response = null;
         $filters = new \Galette\Filters\MembersList();
         $filters->selected = [$this->adh->id];
         $this->session->filter_members = $filters;
-        $this
-            ->output(
-                function () use ($controller, $request, $response, &$test_response) {
-                    $test_response = $controller->membersCards($request, $response);
-                }
-            )->isNotEmpty();
-
-        $this->integer($test_response->getStatusCode())->isIdenticalTo(200);
-        $this->string($test_response->getHeader('Content-type')[0])->isIdenticalTo('application/pdf');
-        $this->string($test_response->getHeader('Content-Disposition')[0])->isIdenticalTo('attachment;filename="cards.pdf"');
+
+        $this->expectOutputRegex('/^%PDF-\d\.\d');
+        $test_response = $controller->membersCards($request, $response);
+
+        $this->assertSame(200, $test_response->getStatusCode());
+        $this->assertSame('application/pdf', $test_response->getHeader('Content-type')[0]);
+        $this->assertSame('attachment;filename="cards.pdf"', $test_response->getHeader('Content-Disposition')[0]);
     }
 
     /**
@@ -335,28 +401,28 @@ class PdfController extends GaletteTestCase
 
         //test with non-logged-in user
         $test_response = $controller->adhesionForm($request, $response, $this->adh->id);
-        $this->array($test_response->getHeaders())->isIdenticalTo(['Location' => ['/member/me']]);
-        $this->integer($test_response->getStatusCode())->isIdenticalTo(200);
-        $this->array($this->flash_data['slimFlash'])->isIdenticalTo([
-            'error_detected' => [
-                'You do not have permission for requested URL.'
-            ]
-        ]);
+        $this->assertSame(['Location' => ['/member/me']], $test_response->getHeaders());
+        $this->assertSame(200, $test_response->getStatusCode());
+        $this->assertSame(
+            [
+                'error_detected' => [
+                    'You do not have permission for requested URL.'
+                ]
+            ],
+            $this->flash_data['slimFlash']
+        );
         $this->flash_data = [];
 
         //test logged-in as superadmin
         $this->logSuperAdmin();
         $test_response = null;
-        $this
-            ->output(
-                function () use ($controller, $request, $response, &$test_response) {
-                    $test_response = $controller->adhesionForm($request, $response, $this->adh->id);
-                }
-            )->isNotEmpty();
-
-        $this->integer($test_response->getStatusCode())->isIdenticalTo(200);
-        $this->string($test_response->getHeader('Content-type')[0])->isIdenticalTo('application/pdf');
-        $this->string($test_response->getHeader('Content-Disposition')[0])->isIdenticalTo('attachment;filename="adherent_form.' . $this->adh->id . '.pdf"');
+
+        $this->expectOutputRegex('/^%PDF-\d\.\d/');
+        $test_response = $controller->adhesionForm($request, $response, $this->adh->id);
+
+        $this->assertSame(200, $test_response->getStatusCode());
+        $this->assertSame('application/pdf', $test_response->getHeader('Content-type')[0]);
+        $this->assertSame('attachment;filename="adherent_form.' . $this->adh->id . '.pdf"', $test_response->getHeader('Content-Disposition')[0]);
     }
 
     /**
@@ -386,13 +452,16 @@ class PdfController extends GaletteTestCase
         //test no selection
         $test_response = null;
         $test_response = $controller->membersCards($request, $response);
-        $this->array($test_response->getHeaders())->isIdenticalTo(['Location' => ['/members']]);
-        $this->integer($test_response->getStatusCode())->isIdenticalTo(301);
-        $this->array($this->flash_data['slimFlash'])->isIdenticalTo([
-            'error_detected' => [
-                'No member was selected, please check at least one name.'
-            ]
-        ]);
+        $this->assertSame(['Location' => ['/members']], $test_response->getHeaders());
+        $this->assertSame(301, $test_response->getStatusCode());
+        $this->assertSame(
+            [
+                'error_detected' => [
+                    'No member was selected, please check at least one name.'
+                ]
+            ],
+            $this->flash_data['slimFlash']
+        );
         $this->flash_data = [];
 
         //test with selection
@@ -403,16 +472,13 @@ class PdfController extends GaletteTestCase
         );
 
         $test_response = null;
-        $this
-            ->output(
-                function () use ($controller, $request, $response, &$test_response) {
-                    $test_response = $controller->attendanceSheet($request, $response);
-                }
-            )->isNotEmpty();
-
-        $this->integer($test_response->getStatusCode())->isIdenticalTo(200);
-        $this->string($test_response->getHeader('Content-type')[0])->isIdenticalTo('application/pdf');
-        $this->string($test_response->getHeader('Content-Disposition')[0])->isIdenticalTo('attachment;filename="attendance_sheet.pdf"');
+
+        $this->expectOutputRegex('/^%PDF-\d\.\d/');
+        $test_response = $controller->attendanceSheet($request, $response);
+
+        $this->assertSame(200, $test_response->getStatusCode());
+        $this->assertSame('application/pdf', $test_response->getHeader('Content-type')[0]);
+        $this->assertSame('attachment;filename="attendance_sheet.pdf"', $test_response->getHeader('Content-Disposition')[0]);
     }
 
     /**
@@ -442,27 +508,27 @@ class PdfController extends GaletteTestCase
 
         //test not logged
         $test_response = $controller->contribution($request, $response, $this->contrib->id);
-        $this->array($test_response->getHeaders())->isIdenticalTo(['Location' => ['/contributions']]);
-        $this->integer($test_response->getStatusCode())->isIdenticalTo(301);
-        $this->array($this->flash_data['slimFlash'])->isIdenticalTo([
-            'error_detected' => [
-                'Unable to load contribution #' . $this->contrib->id . '!'
-            ]
-        ]);
+        $this->assertSame(['Location' => ['/contributions']], $test_response->getHeaders());
+        $this->assertSame(301, $test_response->getStatusCode());
+        $this->assertSame(
+            [
+                'error_detected' => [
+                    'Unable to load contribution #' . $this->contrib->id . '!'
+                ]
+            ],
+            $this->flash_data['slimFlash']
+        );
         $this->flash_data = [];
 
         //test superadmin
         $this->logSuperAdmin();
         $test_response = null;
-        $this
-            ->output(
-                function () use ($controller, $request, $response, &$test_response) {
-                    $test_response = $controller->contribution($request, $response, $this->contrib->id);
-                }
-            )->isNotEmpty();
-
-        $this->integer($test_response->getStatusCode())->isIdenticalTo(200);
-        $this->string($test_response->getHeader('Content-type')[0])->isIdenticalTo('application/pdf');
-        $this->string($test_response->getHeader('Content-Disposition')[0])->isIdenticalTo('attachment;filename="contribution_' . $this->contrib->id . '_invoice.pdf"');
+
+        $this->expectOutputRegex('/^%PDF-\d\.\d\/');
+        $test_response = $controller->contribution($request, $response, $this->contrib->id);
+
+        $this->assertSame(200, $test_response->getStatusCode());
+        $this->assertSame('application/pdf', $test_response->getHeader('Content-type')[0]);
+        $this->assertSame('attachment;filename="contribution_' . $this->contrib->id . '_invoice.pdf"', $test_response->getHeader('Content-Disposition')[0]);
     }
 }
index 2959764d5b11c3b5a2af1d18f45d7fc7737727d2..305da30d3d16c55ecf8a968e167e025ae84383ca 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\Core\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * CheckModules tests class
@@ -51,21 +51,20 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2016-11-09
  */
-class CheckModules extends atoum
+class CheckModules extends TestCase
 {
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
         if (TYPE_DB === 'mysql') {
             $zdb = new \Galette\Core\Db();
-            $this->array($zdb->getWarnings())->isIdenticalTo([]);
+            $this->assertSame([], $zdb->getWarnings());
         }
+        parent::tearDown();
     }
 
     /**
@@ -76,16 +75,12 @@ class CheckModules extends atoum
     public function testAllOK()
     {
         $checks = new \Galette\Core\CheckModules();
-        $this->boolean($checks->isValid())->isTrue();
-        $this->integer(count($checks->getGoods()))
-            ->isLessThanOrEqualTo(10)
-            ->isGreaterThanOrEqualTo(6);
-        $this->array($checks->getMissings())
-            ->isEmpty();
-        $this->array($checks->getShoulds())
-            ->isEmpty();
-        $this->boolean($checks->isGood('mbstring'))
-            ->isTrue();
+        $this->assertTrue($checks->isValid());
+        $this->assertGreaterThanOrEqual(6, count($checks->getGoods()));
+        $this->assertLessThanOrEqual(10, count($checks->getGoods()));
+        $this->assertSame([], $checks->getMissings());
+        $this->assertSame([], $checks->getShoulds());
+        $this->assertTrue($checks->isGood('mbstring'));
     }
 
     /**
@@ -95,21 +90,20 @@ class CheckModules extends atoum
      */
     public function testAllKO()
     {
-        $this->assert('All PHP extensions missing')
-            ->given($checks = new \Galette\Core\CheckModules(false))
-            ->if($this->function->extension_loaded = false)
-            ->then
-                ->if($checks->doCheck())
-                    ->then
-                        ->array($checks->getGoods())
-                            ->hasSize(0)
-                        ->array($checks->getShoulds())
-                            ->hasSize(3)
-                        ->array($checks->getMissings())
-                            ->hasSize(6)
-                        ->string($checks->toHtml())
-                            ->notContains('green check icon')
-                            ->hasLength(1026);
+        $checks = $this->getMockBuilder(\Galette\Core\CheckModules::class)
+            ->setConstructorArgs([false])
+            ->onlyMethods(array('isExtensionLoaded'))
+            ->getMock();
+        $checks->method('isExtensionLoaded')->willReturn(false);
+
+        $checks->doCheck(false);
+        $this->assertSame(0, count($checks->getGoods()));
+        $this->assertSame(3, count($checks->getShoulds()));
+        $this->assertSame(6, count($checks->getMissings()));
+
+        $html = $checks->toHtml();
+        $this->assertStringNotContainsString('green check icon', $html);
+        $this->assertSame(1026, strlen($html));
     }
 
     /**
@@ -122,8 +116,7 @@ class CheckModules extends atoum
         $checks = new \Galette\Core\CheckModules();
         $checks->doCheck();
         $html = $checks->toHtml();
-        $this->string($html)
-            ->notContains('icon-invalid.png')
-            ->length->isGreaterThanOrEqualTo(908);
+        $this->assertStringNotContainsString('icon-invalid.png', $html);
+        $this->assertGreaterThanOrEqual(908, strlen($html));
     }
 }
index 796d5b9664573badbeb2c3eb544b7a9ed7ea2f0c..95ac8961372956c244f36e053f1ea41a978b08e9 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\Core\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Database tests class
@@ -51,18 +51,17 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2013-02-05
  */
-class Db extends atoum
+class Db extends TestCase
 {
     private \Galette\Core\Db $db;
+    private array $have_warnings = [];
 
     /**
      * Set up tests
      *
-     * @param stgring $method Method tested
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $this->db = new \Galette\Core\Db();
     }
@@ -70,24 +69,14 @@ class Db extends atoum
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
-        if (TYPE_DB === 'mysql' and $method !== 'testExecuteWException') {
-            $this->array($this->db->getWarnings())->isIdenticalTo([]);
+        if (TYPE_DB === 'mysql') {
+            $this->assertEquals($this->db->getWarnings(), $this->have_warnings);
         }
-    }
 
-    /**
-     * Cleanup after tests
-     *
-     * @return void
-     */
-    public function tearDown()
-    {
         $this->db = new \Galette\Core\Db();
         $delete = $this->db->delete(\Galette\Entity\Title::TABLE);
         $delete->where([\Galette\Entity\Title::PK => '150']);
@@ -103,8 +92,7 @@ class Db extends atoum
     {
         $db = new \Galette\Core\Db();
         $type = $db->type_db;
-        $this->string($type)
-            ->isIdenticalTo(TYPE_DB);
+        $this->assertSame(TYPE_DB, $type);
 
         $dsn = array(
             'TYPE_DB'   => TYPE_DB,
@@ -121,25 +109,18 @@ class Db extends atoum
 
         switch (TYPE_DB) {
             case 'pgsql':
-                $this->boolean($is_pg)
-                    ->isTrue();
-                $this->string($type)
-                    ->isIdenticalTo(\Galette\Core\Db::PGSQL);
+                $this->assertTrue($is_pg);
+                $this->assertSame(\Galette\Core\Db::PGSQL, $type);
                 break;
             case \Galette\Core\Db::MYSQL:
-                $this->boolean($is_pg)
-                    ->isFalse();
-                $this->string($type)
-                    ->isIdenticalTo(\Galette\Core\Db::MYSQL);
+                $this->assertFalse($is_pg);
+                $this->assertSame(\Galette\Core\Db::MYSQL, $type);
                 break;
         }
 
-        $this->exception(
-            function () use ($dsn) {
-                $dsn['TYPE_DB'] = 'DOES_NOT_EXISTS';
-                $db = new \Galette\Core\Db($dsn);
-            }
-        );
+        $this->expectException(\Exception::class);
+        $dsn['TYPE_DB'] = 'DOES_NOT_EXISTS';
+        $db = new \Galette\Core\Db($dsn);
     }
 
     /**
@@ -157,7 +138,7 @@ class Db extends atoum
             PORT_DB,
             NAME_DB
         );
-        $this->boolean($res)->isTrue();
+        $this->assertTrue($res);
     }
 
     /**
@@ -179,17 +160,13 @@ class Db extends atoum
         );
         $result = $this->db->grantCheck();
 
-        $this->array($result)
-            ->hasSize(6)
-            ->isIdenticalTo($expected);
+        $this->assertSame($expected, $result);
 
         //in update mode, we need alter
         $result = $this->db->grantCheck('u');
 
         $expected['alter'] = true;
-        $this->array($result)
-            ->hasSize(7)
-            ->isIdenticalTo($expected);
+        $this->assertSame($result, $expected);
     }
 
     /**
@@ -202,89 +179,129 @@ class Db extends atoum
         $atoum = $this;
 
         //test insert failing
-        $this->db = new \mock\Galette\Core\Db();
-        $this->calling($this->db)->execute = function ($o) {
-            if ($o instanceof \Laminas\Db\Sql\Insert) {
-                throw new \LogicException('Error executing query!', 123);
-            }
-        };
+        $this->db = $this->getMockBuilder(\Galette\Core\Db::class)
+            ->onlyMethods(array('execute'))
+            ->getMock();
+
+        $this->db->method('execute')
+            ->will(
+                $this->returnCallback(
+                    function ($o) {
+                        if ($o instanceof \Laminas\Db\Sql\Insert) {
+                            throw new \LogicException('Error executing query!', 123);
+                        }
+                    }
+                )
+            );
 
         $result = $this->db->grantCheck('u');
 
-        $this->array($result)
-            ->boolean['create']->isTrue()
-            ->boolean['alter']->isTrue()
-            ->object['insert']->isInstanceOf('\LogicException')
-            ->boolean['update']->isFalse()
-            ->boolean['select']->isFalse()
-            ->boolean['delete']->isFalse()
-            ->boolean['drop']->isTrue();
+        $this->assertTrue($result['create']);
+        $this->assertTrue($result['alter']);
+        $this->assertInstanceOf(\LogicException::class, $result['insert']);
+        $this->assertFalse($result['update']);
+        $this->assertFalse($result['select']);
+        $this->assertFalse($result['delete']);
+        $this->assertTrue($result['drop']);
 
         //test select failing
-        $this->calling($this->db)->execute = function ($o) use ($atoum) {
-            if ($o instanceof \Laminas\Db\Sql\Select) {
-                throw new \LogicException('Error executing query!', 123);
-            } else {
-                $rs = new \mock\Laminas\Db\ResultSet();
-                $atoum->calling($rs)->count = 1;
-                return $rs;
-            }
-        };
+        $this->db = $this->getMockBuilder(\Galette\Core\Db::class)
+            ->onlyMethods(array('execute'))
+            ->getMock();
+
+        $this->db->method('execute')
+            ->will(
+                $this->returnCallback(
+                    function ($o) {
+                        if ($o instanceof \Laminas\Db\Sql\Select) {
+                            throw new \LogicException('Error executing query!', 123);
+                        } else {
+                            $rs = $this->getMockBuilder(\Laminas\Db\ResultSet\ResultSet::class)
+                                ->onlyMethods(array('count'))
+                                ->getMock();
+                            $rs->method('count')
+                                ->willReturn(1);
+                            return $rs;
+                        }
+                    }
+                )
+            );
 
         $result = $this->db->grantCheck('u');
 
-        $this->array($result)
-            ->boolean['create']->isTrue()
-            ->boolean['alter']->isTrue()
-            ->boolean['insert']->isTrue()
-            ->boolean['update']->isTrue()
-            ->object['select']->isInstanceOf('\LogicException')
-            ->boolean['delete']->isTrue()
-            ->boolean['drop']->isTrue();
+        $this->assertTrue($result['create']);
+        $this->assertTrue($result['alter']);
+        $this->assertTrue($result['insert']);
+        $this->assertTrue($result['update']);
+        $this->assertInstanceOf(\LogicException::class, $result['select']);
+        $this->assertTrue($result['delete']);
+        $this->assertTrue($result['drop']);
 
         //test update failing
-        $this->calling($this->db)->execute = function ($o) use ($atoum) {
-            if ($o instanceof \Laminas\Db\Sql\Update) {
-                throw new \LogicException('Error executing query!', 123);
-            } else {
-                $rs = new \mock\Laminas\Db\ResultSet();
-                $atoum->calling($rs)->count = 1;
-                return $rs;
-            }
-        };
+        $this->db = $this->getMockBuilder(\Galette\Core\Db::class)
+            ->onlyMethods(array('execute'))
+            ->getMock();
+
+        $this->db->method('execute')
+            ->will(
+                $this->returnCallback(
+                    function ($o) {
+                        if ($o instanceof \Laminas\Db\Sql\Update) {
+                            throw new \LogicException('Error executing query!', 123);
+                        } else {
+                            $rs = $this->getMockBuilder(\Laminas\Db\ResultSet\ResultSet::class)
+                                ->onlyMethods(array('count'))
+                                ->getMock();
+                            $rs->method('count')
+                                ->willReturn(1);
+                            return $rs;
+                        }
+                    }
+                )
+            );
 
         $result = $this->db->grantCheck('u');
 
-        $this->array($result)
-            ->boolean['create']->isTrue()
-            ->boolean['alter']->isTrue()
-            ->boolean['insert']->isTrue()
-            ->object['update']->isInstanceOf('\LogicException')
-            ->boolean['select']->isTrue()
-            ->boolean['delete']->isTrue()
-            ->boolean['drop']->isTrue();
+        $this->assertTrue($result['create']);
+        $this->assertTrue($result['alter']);
+        $this->assertTrue($result['insert']);
+        $this->assertInstanceOf(\LogicException::class, $result['update']);
+        $this->assertTrue($result['select']);
+        $this->assertTrue($result['delete']);
+        $this->assertTrue($result['drop']);
 
         //test delete failing
-        $this->calling($this->db)->execute = function ($o) use ($atoum) {
-            if ($o instanceof \Laminas\Db\Sql\Delete) {
-                throw new \LogicException('Error executing query!', 123);
-            } else {
-                $rs = new \mock\Laminas\Db\ResultSet();
-                $atoum->calling($rs)->count = 1;
-                return $rs;
-            }
-        };
+        $this->db = $this->getMockBuilder(\Galette\Core\Db::class)
+            ->onlyMethods(array('execute'))
+            ->getMock();
+
+        $this->db->method('execute')
+            ->will(
+                $this->returnCallback(
+                    function ($o) {
+                        if ($o instanceof \Laminas\Db\Sql\Delete) {
+                            throw new \LogicException('Error executing query!', 123);
+                        } else {
+                            $rs = $this->getMockBuilder(\Laminas\Db\ResultSet\ResultSet::class)
+                                ->onlyMethods(array('count'))
+                                ->getMock();
+                            $rs->method('count')
+                                ->willReturn(1);
+                            return $rs;
+                        }
+                    }
+                )
+            );
 
         $result = $this->db->grantCheck('u');
 
-        $this->array($result)
-            ->boolean['create']->isTrue()
-            ->boolean['alter']->isTrue()
-            ->boolean['insert']->isTrue()
-            ->boolean['update']->isTrue()
-            ->boolean['select']->isTrue()
-            ->object['delete']->isInstanceOf('\LogicException')
-            ->boolean['drop']->isTrue();
+        $this->assertTrue($result['create']);
+        $this->assertTrue($result['alter']);
+        $this->assertTrue($result['insert']);
+        $this->assertTrue($result['update']);
+        $this->assertTrue($result['select']);
+        $this->assertInstanceOf(\LogicException::class, $result['delete']);
+        $this->assertTrue($result['drop']);
     }
 
     /**
@@ -298,12 +315,10 @@ class Db extends atoum
 
         switch (TYPE_DB) {
             case 'pgsql':
-                $this->boolean($is_pg)
-                    ->isTrue();
+                $this->assertTrue($is_pg);
                 break;
             default:
-                $this->boolean($is_pg)
-                    ->isFalse();
+                $this->assertFalse($is_pg);
                 break;
         }
     }
@@ -318,29 +333,25 @@ class Db extends atoum
         switch (TYPE_DB) {
             case 'pgsql':
                 $type = $this->db->type_db;
-                $this->string($type)
-                    ->isIdenticalTo('pgsql');
+                $this->assertSame('pgsql', $type);
                 break;
             case 'mysql':
                 $type = $this->db->type_db;
-                $this->string($type)
-                    ->isIdenticalTo('mysql');
+                $this->assertSame('mysql', $type);
                 break;
         }
 
         $db = $this->db->db;
-        $this->object($db)->isInstanceOf('Laminas\Db\Adapter\Adapter');
+        $this->assertInstanceOf('Laminas\Db\Adapter\Adapter', $db);
 
         $sql = $this->db->sql;
-        $this->object($sql)->isInstanceOf('Laminas\Db\Sql\Sql');
+        $this->assertInstanceOf('Laminas\Db\Sql\Sql', $sql);
 
         $connection = $this->db->connection;
-        $this->object($connection)
-            ->isInstanceOf('Laminas\Db\Adapter\Driver\Pdo\Connection');
+        $this->assertInstanceOf('Laminas\Db\Adapter\Driver\Pdo\Connection', $connection);
 
         $driver = $this->db->driver;
-        $this->object($driver)
-            ->isInstanceOf('Laminas\Db\Adapter\Driver\Pdo\Pdo');
+        $this->assertInstanceOf('Laminas\Db\Adapter\Driver\Pdo\Pdo', $driver);
     }
 
     /**
@@ -365,7 +376,7 @@ class Db extends atoum
                 'WHERE `p`.`nom_pref` = \'pref_nom\'';
         }
 
-        $this->string($query)->isIdenticalTo($expected);
+        $this->assertSame($expected, $query);
     }
 
     /**
@@ -376,7 +387,7 @@ class Db extends atoum
     public function testSelectAll()
     {
         $all = $this->db->selectAll('preferences');
-        $this->object($all)->isInstanceOf('Laminas\Db\ResultSet\ResultSet');
+        $this->assertInstanceOf('Laminas\Db\ResultSet\ResultSet', $all);
     }
 
     /**
@@ -399,12 +410,12 @@ class Db extends atoum
         $select->where(['t.id_title' => $data['id_title']]);
 
         $results = $this->db->execute($select);
-        $this->integer($results->count())->isIdenticalTo(1);
+        $this->assertSame(1, $results->count());
 
         if (TYPE_DB === 'pgsql') {
             $data['id_title'] = (int)$data['id_title'];
         }
-        $this->array((array)$results->current())->isEqualTo($data);
+        $this->assertEquals((array)$results->current(), $data);
     }
 
     /**
@@ -414,6 +425,15 @@ class Db extends atoum
      */
     public function testUpdate()
     {
+        $insert = $this->db->insert('titles');
+        $data = [
+            'id_title'      => '150',
+            'short_label'   => 'Dr',
+            'long_label'    => 'Doctor'
+        ];
+        $insert->values($data);
+        $res = $this->db->execute($insert);
+
         $update = $this->db->update('titles');
         $data = [
             'long_label'    => 'DoctorS'
@@ -426,18 +446,18 @@ class Db extends atoum
         $results = $this->db->execute($select);
 
         $long_label = $results->current()->long_label;
-        $this->string($long_label)->isIdenticalTo('Doctor');
+        $this->assertSame('Doctor', $long_label);
 
         $update->set($data);
         $update->where($where);
         $res = $this->db->execute($update);
-        $this->integer($res->count())->isIdenticalTo(1);
+        $this->assertSame(1, $res->count());
 
         $results = $this->db->execute($select);
-        $this->integer($results->count())->isIdenticalTo(1);
+        $this->assertSame(1, $results->count());
 
         $long_label = $results->current()->long_label;
-        $this->string($long_label)->isIdenticalTo('DoctorS');
+        $this->assertSame('DoctorS', $long_label);
     }
 
     /**
@@ -447,20 +467,29 @@ class Db extends atoum
      */
     public function testDelete()
     {
+        $insert = $this->db->insert('titles');
+        $data = [
+            'id_title'      => '150',
+            'short_label'   => 'Dr',
+            'long_label'    => 'Doctor'
+        ];
+        $insert->values($data);
+        $res = $this->db->execute($insert);
+
         $delete = $this->db->delete('titles');
         $where = ['id_title' => 150];
 
         $select = $this->db->select('titles', 't');
         $select->where($where);
         $results = $this->db->execute($select);
-        $this->integer($results->count())->isIdenticalTo(1);
+        $this->assertSame(1, $results->count());
 
         $delete->where($where);
         $res = $this->db->execute($delete);
-        $this->integer($res->count())->isIdenticalTo(1);
+        $this->assertSame(1, $res->count());
 
         $results = $this->db->execute($select);
-        $this->integer($results->count())->isIdenticalTo(0);
+        $this->assertSame(0, $results->count());
     }
 
     /**
@@ -471,10 +500,10 @@ class Db extends atoum
     public function testDbVersion()
     {
         $db_version = $this->db->getDbVersion();
-        $this->variable($db_version)->isIdenticalTo(GALETTE_DB_VERSION);
+        $this->assertSame(GALETTE_DB_VERSION, $db_version);
 
         $res = $this->db->checkDbVersion();
-        $this->boolean($res)->isTrue();
+        $this->assertTrue($res);
     }
 
     /**
@@ -484,20 +513,21 @@ class Db extends atoum
      */
     public function testDbVersionWException()
     {
-        $this->db = new \mock\Galette\Core\Db();
-        $this->calling($this->db)->execute = function ($o) {
-            throw new \LogicException('Error executing query!', 123);
-        };
+        $this->db = $this->getMockBuilder(\Galette\Core\Db::class)
+            ->onlyMethods(array('execute'))
+            ->getMock();
+        $this->db->method('execute')
+            ->will(
+                $this->returnCallback(
+                    function ($table, $where) {
+                        throw new \LogicException('Error executing query!', 123);
+                    }
+                )
+            );
 
-        $db = $this->db;
-        $this
-            ->exception(
-                function () use ($db) {
-                    $db->getDbVersion();
-                }
-            )->isInstanceOf('\LogicException');
-
-        $this->boolean($db->checkDbVersion())->isFalse();
+        $this->expectException('LogicException');
+        $this->db->getDbVersion();
+        $this->assertFalse($this->db->checkDbVersion());
     }
 
     /**
@@ -509,21 +539,21 @@ class Db extends atoum
     {
         $cols = $this->db->getColumns('preferences');
 
-        $this->array($cols)->hasSize(3);
+        $this->assertCount(3, $cols);
 
         $columns = array();
         foreach ($cols as $c) {
             $columns[] = $c->getName();
         }
 
-        $this->array($columns)
-            ->containsValues(
-                array(
-                    'id_pref',
-                    'nom_pref',
-                    'val_pref'
-                )
-            );
+        $this->assertSame(
+            array(
+                'id_pref',
+                'nom_pref',
+                'val_pref'
+            ),
+            array_values($columns)
+        );
     }
 
     /**
@@ -577,9 +607,7 @@ class Db extends atoum
         sort($tables);
         sort($expected);
 
-        $this->array($tables)
-            ->hasSize(count($expected), print_r($tables, true) . ' ' . print_r($expected, true))
-            ->isIdenticalTo($expected);
+        $this->assertSame($expected, $tables);
     }
 
     /**
@@ -589,11 +617,8 @@ class Db extends atoum
      */
     public function testConvertToUtf()
     {
-        if (TYPE_DB === \Galette\Core\Db::MYSQL) {
-            $convert = $this->db->convertToUTF();
-
-            $this->variable($convert)->isNull();
-        }
+        $convert = $this->db->convertToUTF();
+        $this->assertNull($convert);
     }
 
     /**
@@ -609,8 +634,7 @@ class Db extends atoum
             "'somethin'' to \"quote\"'" :
             "'somethin\\' to \\\"quote\\\"'";
 
-        $this->string($quoted)
-            ->isIdenticalTo($expected);
+        $this->assertSame($expected, $quoted);
     }
 
     /**
@@ -624,8 +648,7 @@ class Db extends atoum
         $select->where(['p.nom_pref' => 'azerty']);
         $results = $this->db->execute($select);
 
-        $this->object($results)
-            ->isInstanceOf('\Laminas\Db\ResultSet\ResultSet');
+        $this->assertInstanceOf('\Laminas\Db\ResultSet\ResultSet', $results);
     }
 
     /**
@@ -635,15 +658,21 @@ class Db extends atoum
      */
     public function testExecuteWException()
     {
+        $this->have_warnings = [
+            new \ArrayObject(
+                [
+                    'Level' => 'Error',
+                    'Code' => 1054,
+                    'Message' => "Unknown column 'p.notknown' in 'where clause'"
+                ]
+            )
+        ];
         $select = $this->db->select('preferences', 'p');
         $select->where(['p.nom_pref' => 'azerty']);
+        $select->where(['p.notknown' => 'azerty']);
 
-        $this->exception(
-            function () use ($select) {
-                $select->where(['p.notknown' => 'azerty']);
-                $results = $this->db->execute($select);
-            }
-        )->isInstanceOf('\PDOException');
+        $this->expectException('\PDOException');
+        $results = $this->db->execute($select);
     }
 
     /**
@@ -655,10 +684,9 @@ class Db extends atoum
     {
         $db = $this->db;
         $serialized = serialize($db);
-        $this->string($serialized)
-            ->isNotNull();
+        $this->assertNotNull($serialized);
 
         $unserialized = unserialize($serialized);
-        $this->object($unserialized)->isInstanceOf('Galette\Core\Db');
+        $this->assertInstanceOf('Galette\Core\Db', $unserialized);
     }
 }
index 76d8f812ae8596209796f96385317635042328d0..6a5fdd82426f3edb30f63c947e5e2e77848b02b2 100644 (file)
@@ -7,7 +7,7 @@
  *
  * PHP version 5
  *
- * Copyright © 2021 The Galette Team
+ * Copyright © 2021-2023 The Galette Team
  *
  * This file is part of Galette (http://galette.tuxfamily.org).
  *
@@ -28,7 +28,7 @@
  * @package   GaletteTests
  *
  * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2021 The Galette Team
+ * @copyright 2021-2023 The Galette Team
  * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
  * @version   SVN: $Id$
  * @link      http://galette.tuxfamily.org
@@ -46,7 +46,7 @@ use Galette\GaletteTestCase;
  * @name      Galette
  * @package   GaletteTests
  * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2021 The Galette Team
+ * @copyright 2021-2023 The Galette Team
  * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
  * @link      http://galette.tuxfamily.org
  * @since     2021-11-23
@@ -61,20 +61,18 @@ class Galette extends GaletteTestCase
     public function testGitVersion()
     {
         $gitversion = \Galette\Core\Galette::gitVersion();
-        $this->boolean(str_starts_with(
-            $gitversion,
-            GALETTE_VERSION
-        ))->isTrue();
-        $this->integer(
+        $this->assertStringStartsWith(GALETTE_VERSION, $gitversion);
+        $this->assertSame(
+            1,
             preg_match(
-                '/-git-\w (\d{4}-\d{2}-\d{2})/',
+                '/-git-.+ \(\d{4}-\d{2}-\d{2}\)/',
                 str_replace(GALETTE_VERSION, '', $gitversion)
             )
         );
     }
 
     /**
-     * Test storign into session of various objects to detect serialization issues
+     * Test storing into session of various objects to detect serialization issues
      *
      * @return void
      */
@@ -83,68 +81,68 @@ class Galette extends GaletteTestCase
         //global objects
         $login = new \Galette\Core\Login($this->zdb, $this->i18n);
         $this->session->login_test = $login;
-        $this->object($this->session->login_test)->isInstanceOf(\Galette\Core\Login::class);
+        $this->assertInstanceOf(\Galette\Core\Login::class, $this->session->login_test);
 
         $mailing = new \Galette\Core\Mailing($this->preferences);
         $this->session->mailing_test = $mailing;
-        $this->object($this->session->mailing_test)->isInstanceOf(\Galette\Core\Mailing::class);
+        $this->assertInstanceOf(\Galette\Core\Mailing::class, $this->session->mailing_test);
 
         $gaptcha = new \Galette\Core\Gaptcha($this->i18n);
         $this->session->gaptcha_test = $gaptcha;
-        $this->object($this->session->gaptcha_test)->isInstanceOf(\Galette\Core\Gaptcha::class);
+        $this->assertInstanceOf(\Galette\Core\Gaptcha::class, $this->session->gaptcha_test);
 
         $plugin_install = new \Galette\Core\PluginInstall();
         $this->session->plugininstall_test = $plugin_install;
-        $this->object($this->session->plugininstall_test)->isInstanceOf(\Galette\Core\PluginInstall::class);
+        $this->assertInstanceOf(\Galette\Core\PluginInstall::class, $this->session->plugininstall_test);
 
         $i18n = new \Galette\Core\I18n();
         $this->session->i18n_test = $i18n;
-        $this->object($this->session->i18n_test)->isInstanceOf(\Galette\Core\I18n::class);
+        $this->assertInstanceOf(\Galette\Core\I18n::class, $this->session->i18n_test);
 
         //entities
         $contribution = new \Galette\Entity\Contribution($this->zdb, $this->login);
         $this->session->contribution_test = $contribution;
-        $this->object($this->session->contribution_test)->isInstanceOf(\Galette\Entity\Contribution::class);
+        $this->assertInstanceOf(\Galette\Entity\Contribution::class, $this->session->contribution_test);
 
         $df = \Galette\DynamicFields\DynamicField::getFieldType($this->zdb, \Galette\DynamicFields\DynamicField::LINE);
         $this->session->df_filter_test = $df;
-        $this->object($this->session->df_filter_test)->isInstanceOf(\Galette\DynamicFields\Line::class);
+        $this->assertInstanceOf(\Galette\DynamicFields\Line::class, $this->session->df_filter_test);
 
         $member = new \Galette\Entity\Adherent($this->zdb);
         $this->session->member_test = $member;
-        $this->object($this->session->member_test)->isInstanceOf(\Galette\Entity\Adherent::class);
+        $this->assertInstanceOf(\Galette\Entity\Adherent::class, $this->session->member_test);
 
         $transaction = new \Galette\Entity\Transaction($this->zdb, $this->login);
         $this->session->transaction_test = $transaction;
-        $this->object($this->session->transaction_test)->isInstanceOf(\Galette\Entity\Transaction::class);
+        $this->assertInstanceOf(\Galette\Entity\Transaction::class, $this->session->transaction_test);
 
         //filters
         $contribution_filter = new \Galette\Filters\ContributionsList();
         $this->session->contribution_filter_test = $contribution_filter;
-        $this->object($this->session->contribution_filter_test)->isInstanceOf(\Galette\Filters\ContributionsList::class);
+        $this->assertInstanceOf(\Galette\Filters\ContributionsList::class, $this->session->contribution_filter_test);
 
         $member_advanced_filter = new \Galette\Filters\AdvancedMembersList();
         $this->session->member_advanced_filter_test = $member_advanced_filter;
-        $this->object($this->session->member_advanced_filter_test)->isInstanceOf(\Galette\Filters\AdvancedMembersList::class);
+        $this->assertInstanceOf(\Galette\Filters\AdvancedMembersList::class, $this->session->member_advanced_filter_test);
 
         $member_filter = new \Galette\Filters\MembersList();
         $this->session->member_filter_test = $member_filter;
-        $this->object($this->session->member_filter_test)->isInstanceOf(\Galette\Filters\MembersList::class);
+        $this->assertInstanceOf(\Galette\Filters\MembersList::class, $this->session->member_filter_test);
 
         $history_filter = new \Galette\Filters\HistoryList();
         $this->session->history_filter_test = $history_filter;
-        $this->object($this->session->history_filter_test)->isInstanceOf(\Galette\Filters\HistoryList::class);
+        $this->assertInstanceOf(\Galette\Filters\HistoryList::class, $this->session->history_filter_test);
 
         $mailing_filter = new \Galette\Filters\MailingsList();
         $this->session->mailing_filter_test = $mailing_filter;
-        $this->object($this->session->mailing_filter_test)->isInstanceOf(\Galette\Filters\MailingsList::class);
+        $this->assertInstanceOf(\Galette\Filters\MailingsList::class, $this->session->mailing_filter_test);
 
         $saved_filter = new \Galette\Filters\SavedSearchesList();
         $this->session->saved_filter_test = $saved_filter;
-        $this->object($this->session->saved_filter_test)->isInstanceOf(\Galette\Filters\SavedSearchesList::class);
+        $this->assertInstanceOf(\Galette\Filters\SavedSearchesList::class, $this->session->saved_filter_test);
 
         $transaction_filter = new \Galette\Filters\TransactionsList();
         $this->session->transaction_filter_test = $transaction_filter;
-        $this->object($this->session->transaction_filter_test)->isInstanceOf(\Galette\Filters\TransactionsList::class);
+        $this->assertInstanceOf(\Galette\Filters\TransactionsList::class, $this->session->transaction_filter_test);
     }
 }
index 2cfacd794febf24d613da060e92cc8ad9c5f756a..fb18bffdb04793ca02110d0a02917aa36a8b0af4 100644 (file)
@@ -60,8 +60,8 @@ class History extends GaletteTestCase
      */
     public function testConstants()
     {
-        $this->string(\Galette\Core\History::TABLE)->isIdenticalTo('logs');
-        $this->string(\Galette\Core\History::PK)->isIdenticalTo('id_log');
+        $this->assertSame('logs', \Galette\Core\History::TABLE);
+        $this->assertSame('id_log', \Galette\Core\History::PK);
     }
 
     /**
@@ -74,54 +74,57 @@ class History extends GaletteTestCase
         $this->i18n->changeLanguage('en_US');
         //nothing in the logs at the beginning
         $list = $this->history->getHistory();
-        $this->array($list)->hasSize(0);
+        $this->assertCount(0, $list);
 
         //add some entries
         $add = $this->history->add(
             'Test',
             'Something was added from tests'
         );
-        $this->boolean($add)->isTrue();
+        $this->assertTrue($add);
 
         $add = $this->history->add(
             'Test',
             'Something else was added from tests',
             'SELECT * FROM none WHERE non ORDER BY none'
         );
-        $this->boolean($add)->isTrue();
+        $this->assertTrue($add);
 
         $add = $this->history->add(
             'AnotherTest',
             'And something else, again'
         );
-        $this->boolean($add)->isTrue();
+        $this->assertTrue($add);
 
         //check what has been stored
         $list = $this->history->getHistory();
-        $this->array($list)->hasSize(3);
+        $this->assertCount(3, $list);
 
         $actions = $this->history->getActionsList();
-        $this->array($actions)
-            ->hasSize(2)
-            ->string[0]->isIdenticalTo('AnotherTest')
-            ->string[1]->isIdenticalTo('Test');
+        $this->assertSame(
+            $actions,
+            [
+                'AnotherTest',
+                'Test'
+            ]
+        );
 
         //some filtering
         $this->history->filters->action_filter = 'Test';
         $list = $this->history->getHistory();
-        $this->array($list)->hasSize(2);
+        $this->assertCount(2, $list);
 
         $this->history->filters->start_date_filter = date('Y-m-d');
         $this->history->filters->end_date_filter = date('Y-m-d');
         $list = $this->history->getHistory();
-        $this->array($list)->hasSize(2);
+        $this->assertCount(2, $list);
 
         //let's clean now
         $cleaned = $this->history->clean();
-        $this->boolean($cleaned)->isTrue();
+        $this->assertTrue($cleaned);
 
         $list = $this->history->getHistory();
-        $this->array($list)->hasSize(1);
+        $this->assertCount(1, $list);
 
         $this->cleanHistory();
     }
index 039a3e34d8804270b79b9282832aa169d67a7b69..fcf00c6b05f43a125a032a1c2207f42d90105a45 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\Core\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * I18n tests class
@@ -51,7 +51,7 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2013-01-13
  */
-class I18n extends atoum
+class I18n extends TestCase
 {
     private \Galette\Core\Db $zdb;
     private ?\Galette\Core\I18n $i18n = null;
@@ -59,11 +59,9 @@ class I18n extends atoum
     /**
      * Set up tests
      *
-     * @param string $method Tested method name
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $this->zdb = new \Galette\Core\Db();
         $this->i18n = new \Galette\Core\I18n(
@@ -74,14 +72,12 @@ class I18n extends atoum
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
         if (TYPE_DB === 'mysql') {
-            $this->array($this->zdb->getWarnings())->isIdenticalTo([]);
+            $this->assertSame([], $this->zdb->getWarnings());
         }
     }
 
@@ -94,27 +90,25 @@ class I18n extends atoum
     {
         $this->i18n = new \Galette\Core\I18n();
 
-        $this->variable($this->i18n->getID())->isIdenticalTo(\Galette\Core\I18n::DEFAULT_LANG);
+        $this->assertSame(\Galette\Core\I18n::DEFAULT_LANG, $this->i18n->getID());
 
         //simulate fr from browser
         $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'fr_BE';
         $this->i18n = new \Galette\Core\I18n();
 
-        $this->variable($this->i18n->getID())
-            ->isIdenticalTo('fr_FR');
+        $this->assertSame('fr_FR', $this->i18n->getID());
 
         //simulate en from browser
         $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'en_GB';
         $this->i18n = new \Galette\Core\I18n();
 
-        $this->variable($this->i18n->getID())->isIdenticalTo('en_US');
+        $this->assertSame('en_US', $this->i18n->getID());
 
         //simulate unknown lang from browser
         $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'un_KN';
         $this->i18n = new \Galette\Core\I18n();
 
-        $this->variable($this->i18n->getID())
-            ->isIdenticalTo(\Galette\Core\I18n::DEFAULT_LANG);
+        $this->assertSame(\Galette\Core\I18n::DEFAULT_LANG, $this->i18n->getID());
     }
 
     /**
@@ -126,12 +120,10 @@ class I18n extends atoum
     {
         $list = $this->i18n->getList();
 
-        $this->array($list)
-            ->size->isGreaterThan(3);
+        $this->assertGreaterThan(3, count($list));
 
         foreach ($list as $elt) {
-            $this->object($elt)
-                ->isInstanceOf('\Galette\Core\I18n');
+            $this->assertInstanceOf('\Galette\Core\I18n', $elt);
         }
     }
 
@@ -144,8 +136,7 @@ class I18n extends atoum
     {
         $list = $this->i18n->getArrayList();
 
-        $this->array($list)
-            ->size->isGreaterThan(3);
+        $this->assertGreaterThan(3, count($list));
     }
 
     /**
@@ -156,10 +147,10 @@ class I18n extends atoum
     public function testGetNameFromid()
     {
         $lang = $this->i18n->getNameFromId('en_US');
-        $this->variable($lang)->isIdenticalTo('English');
+        $this->assertSame('English', $lang);
 
         $lang = $this->i18n->getNameFromId('fr_FR');
-        $this->variable($lang)->isIdenticalTo('Français');
+        $this->assertSame('Français', $lang);
     }
 
     /**
@@ -174,10 +165,10 @@ class I18n extends atoum
         $name = $this->i18n->getName();
         $abbrev = $this->i18n->getAbbrev();
 
-        $this->variable($id)->isIdenticalTo('en_US');
-        $this->variable($longid)->isIdenticalTo('en_US');
-        $this->variable($name)->isIdenticalTo('English');
-        $this->variable($abbrev)->isIdenticalTo('en');
+        $this->assertSame('en_US', $id);
+        $this->assertSame('en_US', $longid);
+        $this->assertSame('English', $name);
+        $this->assertSame('en', $abbrev);
 
         $this->i18n->changeLanguage('fr_FR');
         $id = $this->i18n->getID();
@@ -185,10 +176,10 @@ class I18n extends atoum
         $name = $this->i18n->getName();
         $abbrev = $this->i18n->getAbbrev();
 
-        $this->variable($id)->isIdenticalTo('fr_FR');
-        $this->variable($longid)->isIdenticalTo('fr_FR.utf8');
-        $this->variable($name)->isIdenticalTo('Français');
-        $this->variable($abbrev)->isIdenticalTo('fr');
+        $this->assertSame('fr_FR', $id);
+        $this->assertSame('fr_FR.utf8', $longid);
+        $this->assertSame('Français', $name);
+        $this->assertSame('fr', $abbrev);
     }
 
     /**
@@ -201,7 +192,7 @@ class I18n extends atoum
         $this->i18n->changeLanguage('un_KN');
         $id = $this->i18n->getID();
 
-        $this->variable($id)->isIdenticalTo(\Galette\Core\I18n::DEFAULT_LANG);
+        $this->assertSame(\Galette\Core\I18n::DEFAULT_LANG, $id);
     }
 
     /**
@@ -214,7 +205,7 @@ class I18n extends atoum
         $is_utf = $this->i18n->seemUtf8('HéhéHÉHÉâ-ô߬- ©»«<ëßßä€êþÿûîœô');
         $is_iso = $this->i18n->seemUtf8(mb_convert_encoding('Héhé', 'ISO-8859-1'));
 
-        $this->boolean($is_utf)->isTrue();
-        $this->boolean($is_iso)->isFalse();
+        $this->assertTrue($is_utf);
+        $this->assertFalse($is_iso);
     }
 }
index 4a5fd08f8b4bf51f9d0308ec046b6f11dc972664..1ebb7c10d0959bf71210ae3fda1119ff06abcca7 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\Core\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Install tests class
@@ -51,18 +51,16 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2014-01-03
  */
-class Install extends atoum
+class Install extends TestCase
 {
     private \Galette\Core\Install $install;
 
     /**
      * Set up tests
      *
-     * @param stgring $method Method tested
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         setlocale(LC_ALL, 'en_US');
         $this->install = new \Galette\Core\Install();
@@ -71,15 +69,13 @@ class Install extends atoum
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
         if (TYPE_DB === 'mysql') {
             $zdb = new \Galette\Core\Db();
-            $this->array($zdb->getWarnings())->isIdenticalTo([]);
+            $this->assertSame([], $zdb->getWarnings());
         }
     }
 
@@ -93,22 +89,22 @@ class Install extends atoum
         $install = new \Galette\Core\Install();
 
         $step = $install->isCheckStep();
-        $this->boolean($step)->isTrue();
+        $this->assertTrue($step);
 
         $mode = $install->getMode();
-        $this->variable($mode)->isNull();
+        $this->assertNull($mode);
 
         $is_install = $install->isInstall();
-        $this->boolean($is_install)->isFalse();
+        $this->assertFalse($is_install);
 
         $is_upgrade = $install->isUpgrade();
-        $this->boolean($is_upgrade)->isFalse();
+        $this->assertFalse($is_upgrade);
 
         $connected = $install->isDbConnected();
-        $this->boolean($connected)->isFalse();
+        $this->assertFalse($connected);
 
         $title = $install->getStepTitle();
-        $this->string($title)->isIdenticalTo('Checks');
+        $this->assertSame('Checks', $title);
     }
 
     /**
@@ -145,9 +141,7 @@ class Install extends atoum
             '0.96'  => 'upgrade-to-0.96-pgsql.sql'
         );
 
-        $this->array($update_scripts)
-            ->hasSize(count($knowns))
-            ->isIdenticalTo($knowns);
+        $this->assertSame($knowns, $update_scripts);
 
         $update_scripts = \Galette\Core\Install::getUpdateScripts(
             GALETTE_BASE_PATH . '/install',
@@ -156,8 +150,7 @@ class Install extends atoum
         );
 
         //if we're from 0.7.0, there are 4 less update scripts
-        $this->array($update_scripts)
-            ->hasSize(count($knowns) - 4);
+        $this->assertCount(count($knowns) - 4, $update_scripts);
 
         $update_scripts = \Galette\Core\Install::getUpdateScripts(
             GALETTE_BASE_PATH . '/install'
@@ -165,9 +158,7 @@ class Install extends atoum
 
         //without specifying database nor version, we got all update scripts
         $all_knowns = ['0.60' => 'upgrade-to-0.60-pgsql.sql'] + $knowns;
-        $this->array(array_values($update_scripts))
-            ->hasSize(count($all_knowns))
-            ->isEqualTo(array_keys($all_knowns));
+        $this->assertEquals(array_values($update_scripts), array_keys($all_knowns));
 
         $this->install->setMode(\Galette\Core\Install::UPDATE);
         $errors = array();
@@ -177,9 +168,7 @@ class Install extends atoum
             GALETTE_BASE_PATH . '/install'
         );
 
-        $this->array($update_scripts)
-            ->hasSize(count($knowns))
-            ->isIdenticalTo($knowns);
+        $this->assertSame($knowns, $update_scripts);
 
         //for installation, only one script is present :)
         $this->install->setMode(\Galette\Core\Install::INSTALL);
@@ -187,10 +176,7 @@ class Install extends atoum
             GALETTE_BASE_PATH . '/install'
         );
 
-        $this->array($update_scripts)
-            ->hasSize(1)
-            ->hasKey('current')
-            ->strictlyContains(\Galette\Core\Db::PGSQL . '.sql');
+        $this->assertSame(['current' => \Galette\Core\Db::PGSQL . '.sql'], $update_scripts);
     }
 
     /**
@@ -203,10 +189,10 @@ class Install extends atoum
         $this->install->atTypeStep();
 
         $step = $this->install->isTypeStep();
-        $this->boolean($step)->isTrue();
+        $this->assertTrue($step);
 
         $title = $this->install->getStepTitle();
-        $this->string($title)->isIdenticalTo('Installation mode');
+        $this->assertSame('Installation mode', $title);
     }
 
     /**
@@ -222,15 +208,15 @@ class Install extends atoum
         $is_install = $this->install->isInstall();
         $is_upgrade = $this->install->isUpgrade();
 
-        $this->boolean($is_install)->isTrue();
-        $this->boolean($is_upgrade)->isFalse();
+        $this->assertTrue($is_install);
+        $this->assertFalse($is_upgrade);
 
         $title = $this->install->getStepTitle();
-        $this->string($title)->isIdenticalTo('Database');
+        $this->assertSame('Database', $title);
 
         $this->install->atPreviousStep();
         $step = $this->install->isTypeStep();
-        $this->boolean($step)->isTrue();
+        $this->assertTrue($step);
     }
 
     /**
@@ -246,16 +232,16 @@ class Install extends atoum
         $is_install = $this->install->isInstall();
         $is_upgrade = $this->install->isUpgrade();
 
-        $this->boolean($is_install)->isFalse();
-        $this->boolean($is_upgrade)->isTrue();
+        $this->assertFalse($is_install);
+        $this->assertTrue($is_upgrade);
 
         $title = $this->install->getStepTitle();
-        $this->string($title)->isIdenticalTo('Database');
+        $this->assertSame('Database', $title);
 
         $this->install->atPreviousStep();
         $step = $this->install->isTypeStep();
 
-        $this->boolean($step)->isTrue();
+        $this->assertTrue($step);
     }
 
     /**
@@ -265,11 +251,9 @@ class Install extends atoum
      */
     public function testUnknownMode()
     {
-        $this->exception(
-            function () {
-                $this->install->setMode('nonsense');
-            }
-        )->hasMessage('Unknown mode "nonsense"');
+        $this->expectException(\UnexpectedValueException::class);
+        $this->expectExceptionMessage('Unknown mode "nonsense"');
+        $this->install->setMode('nonsense');
     }
 
     /**
@@ -290,18 +274,17 @@ class Install extends atoum
             $this->install->setDbType(\Galette\Core\Db::MYSQL, $errors);
             $type = $this->install->getDbType();
 
-            $this->variable($type)->isIdenticalTo(\Galette\Core\Db::MYSQL);
-            $this->array($errors)->hasSize(0);
+            $this->assertSame(\Galette\Core\Db::MYSQL, $type);
+            $this->assertCount(0, $errors);
         }
 
         $errors = array();
         $this->install->setDbType('nonsense', $errors);
 
-        $this->array($errors)->hasSize(1)
-            ->strictlyContains('Database type unknown');
+        $this->assertSame(['Database type unknown'], $errors);
 
         $post_check = $this->install->postCheckDb();
-        $this->boolean($post_check)->isFalse();
+        $this->assertFalse($post_check);
     }
 
     /**
@@ -326,38 +309,38 @@ class Install extends atoum
         $this->install->atDbCheckStep();
 
         $step = $this->install->isDbCheckStep();
-        $this->boolean($step)->isTrue();
+        $this->assertTrue($step);
 
         $title = $this->install->getStepTitle();
-        $this->string($title)->isIdenticalTo('Database access and permissions');
+        $this->assertSame('Database access and permissions', $title);
 
         $connected = $this->install->testDbConnexion();
-        $this->boolean($connected)->isTrue();
+        $this->assertTrue($connected);
 
         $host = $this->install->getDbHost();
-        $this->string($host)->isIdenticalTo(HOST_DB);
+        $this->assertSame(HOST_DB, $host);
 
         $port = $this->install->getDbPort();
-        $this->variable($port)->isIdenticalTo(PORT_DB);
+        $this->assertSame(PORT_DB, $port);
 
         $name = $this->install->getDbName();
-        $this->variable($name)->isIdenticalTo(NAME_DB);
+        $this->assertSame(NAME_DB, $name);
 
         $user = $this->install->getDbUser();
-        $this->variable($user)->isIdenticalTo(USER_DB);
+        $this->assertSame(USER_DB, $user);
 
         $prefix = $this->install->getTablesPrefix();
-        $this->variable($prefix)->isIdenticalTo(PREFIX_DB);
+        $this->assertSame(PREFIX_DB, $prefix);
 
         $pass = $this->install->getDbPass();
-        $this->variable($pass)->isIdenticalTo(PWD_DB);
+        $this->assertSame(PWD_DB, $pass);
 
         $post_check = $this->install->postCheckDb();
-        $this->boolean($post_check)->isFalse();
+        $this->assertFalse($post_check);
 
         $this->install->atPreviousStep();
         $step = $this->install->isDbStep();
-        $this->boolean($step)->isTrue();
+        $this->assertTrue($step);
     }
 
     /**
@@ -382,17 +365,17 @@ class Install extends atoum
         $this->install->atDbInstallStep();
 
         $step = $this->install->isDbinstallStep();
-        $this->boolean($step)->isTrue();
+        $this->assertTrue($step);
 
         $title = $this->install->getStepTitle();
-        $this->string($title)->isIdenticalTo('Tables Creation');
+        $this->assertSame('Tables Creation', $title);
 
         $post_check = $this->install->postCheckDb();
-        $this->boolean($post_check)->isTrue();
+        $this->assertTrue($post_check);
 
         $this->install->atPreviousStep();
         $step = $this->install->isDbCheckStep();
-        $this->boolean($step)->isTrue();
+        $this->assertTrue($step);
     }
 
     /**
@@ -405,18 +388,18 @@ class Install extends atoum
         $this->install->atAdminStep();
 
         $step = $this->install->isAdminStep();
-        $this->boolean($step)->isTrue();
+        $this->assertTrue($step);
 
         $title = $this->install->getStepTitle();
-        $this->string($title)->isIdenticalTo('Admin parameters');
+        $this->assertSame('Admin parameters', $title);
 
         $post_check = $this->install->postCheckDb();
-        $this->boolean($post_check)->isTrue();
+        $this->assertTrue($post_check);
 
         $this->install->atPreviousStep();
         //db install cannot be run twice, step is still Admin
         $step = $this->install->isAdminStep();
-        $this->boolean($step)->isTrue();
+        $this->assertTrue($step);
     }
 
     /**
@@ -429,12 +412,12 @@ class Install extends atoum
         $this->install->atGaletteInitStep();
 
         $step = $this->install->isGaletteInitStep();
-        $this->boolean($step)->isTrue();
+        $this->assertTrue($step);
 
         $title = $this->install->getStepTitle();
-        $this->string($title)->isIdenticalTo('Galette initialization');
+        $this->assertSame('Galette initialization', $title);
 
         $post_check = $this->install->postCheckDb();
-        $this->boolean($post_check)->isTrue();
+        $this->assertTrue($post_check);
     }
 }
index 6addbc3a0e721d932691c7e36d73453508b0cc7c..3a6f0912d50c74243ab091e8d166c5c85c28cf14 100644 (file)
@@ -36,7 +36,7 @@
 
 namespace Galette\Core\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * L10n tests class
@@ -50,7 +50,7 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2020-07-05
  */
-class L10n extends atoum
+class L10n extends TestCase
 {
     private \Galette\Core\Db $zdb;
     private \Galette\Core\I18n $i18n;
@@ -59,11 +59,9 @@ class L10n extends atoum
     /**
      * Set up tests
      *
-     * @param string $method Tested method name
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $this->zdb = new \Galette\Core\Db();
         $this->i18n = new \Galette\Core\I18n(
@@ -78,14 +76,12 @@ class L10n extends atoum
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
         if (TYPE_DB === 'mysql') {
-            $this->array($this->zdb->getWarnings())->isIdenticalTo([]);
+            $this->assertSame([], $this->zdb->getWarnings());
         }
         //cleanup dynamic translations
         $delete = $this->zdb->delete(\Galette\Core\L10n::TABLE);
@@ -111,21 +107,19 @@ class L10n extends atoum
         ]);
         $select->where(['text_orig' => 'A text for test']);
         $results = $this->zdb->execute($select);
-        $this->integer($results->count())->isIdenticalTo(0);
+        $this->assertSame(0, $results->count());
 
-        $this->boolean($this->l10n->addDynamicTranslation('A text for test'))->isTrue();
+        $this->assertTrue($this->l10n->addDynamicTranslation('A text for test'));
 
         $langs = array_keys($this->i18n->getArrayList());
 
         $results = $this->zdb->execute($select);
-        $this->integer($results->count())->isIdenticalTo(count($langs));
+        $this->assertSame(count($langs), $results->count());
 
         foreach ($results as $result) {
-            $this->boolean(in_array(str_replace('.utf8', '', $result['text_locale']), $langs))->isTrue();
-            $this->integer((int)$result['text_nref'])->isIdenticalTo(1);
-            $this->string($result['text_trans'])->isIdenticalTo(
-                ($result['text_locale'] == 'en_US' ? 'A text for test' : '')
-            );
+            $this->assertTrue(in_array(str_replace('.utf8', '', $result['text_locale']), $langs));
+            $this->assertSame(1, (int)$result['text_nref']);
+            $this->assertSame(($result['text_locale'] == 'en_US' ? 'A text for test' : ''), $result['text_trans']);
         }
 
         $this->i18n->changeLanguage('fr_FR');
@@ -138,21 +132,19 @@ class L10n extends atoum
         ]);
         $select->where(['text_orig' => 'Un texte de test']);
         $results = $this->zdb->execute($select);
-        $this->integer($results->count())->isIdenticalTo(0);
+        $this->assertSame(0, $results->count());
 
-        $this->boolean($this->l10n->addDynamicTranslation('Un texte de test'))->isTrue();
+        $this->assertTrue($this->l10n->addDynamicTranslation('Un texte de test'));
 
         $langs = array_keys($this->i18n->getArrayList());
 
         $results = $this->zdb->execute($select);
-        $this->integer($results->count())->isIdenticalTo(count($langs));
+        $this->assertSame(count($langs), $results->count());
 
         foreach ($results as $result) {
-            $this->boolean(in_array(str_replace('.utf8', '', $result['text_locale']), $langs))->isTrue();
-            $this->integer((int)$result['text_nref'])->isIdenticalTo(1);
-            $this->string($result['text_trans'])->isIdenticalTo(
-                ($result['text_locale'] == 'fr_FR.utf8' ? 'Un texte de test' : '')
-            );
+            $this->assertTrue(in_array(str_replace('.utf8', '', $result['text_locale']), $langs));
+            $this->assertSame(1, (int)$result['text_nref']);
+            $this->assertSame(($result['text_locale'] == 'fr_FR.utf8' ? 'Un texte de test' : ''), $result['text_trans']);
         }
     }
 }
index 4cb18bfb43b9c36433583aefbc1e6a093e043d56..87c0e8df892d3f337c78188cbf97ed89d1c3d492 100644 (file)
@@ -61,13 +61,11 @@ class Links extends GaletteTestCase
     /**
      * Set up tests
      *
-     * @param string $method Method name
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
-        parent::beforeTestMethod($method);
+        parent::setUp();
         $this->initStatus();
         $this->initContributionsTypes();
 
@@ -85,14 +83,10 @@ class Links extends GaletteTestCase
     /**
      * Cleanup after testeach test method
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
-        parent::afterTestMethod($method);
-
         $delete = $this->zdb->delete(\Galette\Entity\Contribution::TABLE);
         $delete->where(['info_cotis' => 'FAKER' . $this->seed]);
         $this->zdb->execute($delete);
@@ -105,6 +99,7 @@ class Links extends GaletteTestCase
         $this->zdb->execute($delete);
 
         $this->cleanHistory();
+        parent::tearDown();
     }
 
     /**
@@ -123,19 +118,22 @@ class Links extends GaletteTestCase
             $id
         );
 
-        $this->string($res)->isNotEmpty();
+        $this->assertNotEmpty($res);
 
         $select = $this->zdb->select(\Galette\Core\Links::TABLE);
         $results = $this->zdb->execute($select);
-        $this->integer($results->count())->isIdenticalTo(1);
+        $this->assertSame(1, $results->count());
 
-        $this->array($links->isHashValid($res, 'phoarau@tele2.fr'))->isIdenticalTo([
-            \Galette\Core\Links::TARGET_MEMBERCARD,
-            $id
-        ]);
+        $this->assertSame(
+            $links->isHashValid($res, 'phoarau@tele2.fr'),
+            [
+                \Galette\Core\Links::TARGET_MEMBERCARD,
+                $id
+            ]
+        );
 
-        $this->boolean($links->isHashValid($res, 'any@mail.com'))->isFalse();
-        $this->boolean($links->isHashValid(base64_encode('sthingthatisnotahash'), 'phoarau@tele2.fr'))->isFalse();
+        $this->assertFalse($links->isHashValid($res, 'any@mail.com'));
+        $this->assertFalse($links->isHashValid(base64_encode('sthingthatisnotahash'), 'phoarau@tele2.fr'));
 
         $this->createContribution();
         $cid = $this->contrib->id;
@@ -144,11 +142,14 @@ class Links extends GaletteTestCase
             $cid
         );
 
-        $this->string($res)->isNotEmpty();
-        $this->array($links->isHashValid($res, 'phoarau@tele2.fr'))->isIdenticalTo([
-            \Galette\Core\Links::TARGET_INVOICE,
-            $cid
-        ]);
+        $this->assertNotEmpty($res);
+        $this->assertSame(
+            $links->isHashValid($res, 'phoarau@tele2.fr'),
+            [
+                \Galette\Core\Links::TARGET_INVOICE,
+                $cid
+            ]
+        );
     }
 
     /**
@@ -167,16 +168,19 @@ class Links extends GaletteTestCase
             $id
         );
 
-        $this->string($res)->isNotEmpty();
+        $this->assertNotEmpty($res);
 
-        $this->array($links->isHashValid($res, 'phoarau@tele2.fr'))->isIdenticalTo([
-            \Galette\Core\Links::TARGET_MEMBERCARD,
-            $id
-        ]);
+        $this->assertSame(
+            $links->isHashValid($res, 'phoarau@tele2.fr'),
+            [
+                \Galette\Core\Links::TARGET_MEMBERCARD,
+                $id
+            ]
+        );
 
         $select = $this->zdb->select(\Galette\Core\Links::TABLE);
         $results = $this->zdb->execute($select);
-        $this->integer($results->count())->isIdenticalTo(1);
+        $this->assertSame(1, $results->count());
 
         $update = $this->zdb->update(\Galette\Core\Links::TABLE);
         $old_date = new \DateTime();
@@ -186,7 +190,7 @@ class Links extends GaletteTestCase
             ->where(['hash' => base64_decode($res)]);
         $this->zdb->execute($update);
 
-        $this->boolean($links->isHashValid($res, 'phoarau@tele2.fr'))->isFalse();
+        $this->assertFalse($links->isHashValid($res, 'phoarau@tele2.fr'));
     }
 
     /**
@@ -224,14 +228,14 @@ class Links extends GaletteTestCase
 
         $select = $this->zdb->select(\Galette\Core\Links::TABLE);
         $results = $this->zdb->execute($select);
-        $this->integer($results->count())->isIdenticalTo(2);
+        $this->assertSame(2, $results->count());
 
         $links = new \Galette\Core\Links($this->zdb, true);
 
         $results = $this->zdb->execute($select);
         $result = $results->current();
-        $this->integer($results->count())->isIdenticalTo(1);
-        $this->string($result['hash'])->isIdenticalTo('Not expired link');
+        $this->assertSame(1, $results->count());
+        $this->assertSame('Not expired link', $result['hash']);
     }
 
     /**
@@ -267,12 +271,8 @@ class Links extends GaletteTestCase
             ]
         );
 
-        $this->exception(
-            function () use ($insert) {
-                $this->zdb->execute($insert);
-            }
-        )
-            ->hasMessage('Duplicate entry');
+        $this->expectExceptionMessage('Duplicate entry');
+        $this->zdb->execute($insert);
     }
 
     /**
@@ -326,9 +326,9 @@ class Links extends GaletteTestCase
         $due_date->sub(new \DateInterval('P1D'));
         $due_date->add(new \DateInterval('P1Y'));
 
-        $this->object($contrib->raw_date)->isInstanceOf('DateTime');
-        $this->object($contrib->raw_begin_date)->isInstanceOf('DateTime');
-        $this->object($contrib->raw_end_date)->isInstanceOf('DateTime');
+        $this->assertInstanceOf('DateTime', $contrib->raw_date);
+        $this->assertInstanceOf('DateTime', $contrib->raw_begin_date);
+        $this->assertInstanceOf('DateTime', $contrib->raw_end_date);
 
         $expecteds = [
             'id_adh' => "{$this->adh->id}",
@@ -340,7 +340,7 @@ class Links extends GaletteTestCase
         ];
         $expecteds = array_merge($expecteds, $new_expecteds);
 
-        $this->string($contrib->raw_end_date->format('Y-m-d'))->isIdenticalTo($expecteds['date_fin_cotis']);
+        $this->assertSame($expecteds['date_fin_cotis'], $contrib->raw_end_date->format('Y-m-d'));
 
         foreach ($expecteds as $key => $value) {
             $property = $this->contrib->fields[$key]['propname'];
@@ -348,13 +348,13 @@ class Links extends GaletteTestCase
                 case \Galette\Entity\ContributionsTypes::PK:
                     $ct = $this->contrib->type;
                     if ($ct instanceof \Galette\Entity\ContributionsTypes) {
-                        $this->integer((int)$ct->id)->isIdenticalTo($value);
+                        $this->assertSame($value, (int)$ct->id);
                     } else {
-                        $this->integer($ct)->isIdenticalTo($value);
+                        $this->assertSame($value, $ct);
                     }
                     break;
                 default:
-                    $this->variable($contrib->$property)->isEqualTo($value, $property);
+                    $this->assertEquals($contrib->$property, $value, $property);
                     break;
             }
         }
@@ -362,8 +362,8 @@ class Links extends GaletteTestCase
         //load member from db
         $this->adh = new \Galette\Entity\Adherent($this->zdb, $this->adh->id);
         //member is now up-to-date
-        $this->string($this->adh->getRowClass())->isIdenticalTo('active-account cotis-late');
-        $this->string($this->adh->due_date)->isIdenticalTo($this->contrib->end_date);
-        $this->boolean($this->adh->isUp2Date())->isFalse();
+        $this->assertSame('active-account cotis-late', $this->adh->getRowClass());
+        $this->assertSame($this->contrib->end_date, $this->adh->due_date);
+        $this->assertFalse($this->adh->isUp2Date());
     }
 }
index d64a007a9b715e6a1ef181f04af0caf406b60ea6..371f7a90e60d946640b9ce06d170d7eefc03f460 100644 (file)
@@ -62,12 +62,14 @@ class Login extends GaletteTestCase
      *
      * @return void
      */
-    public function tearDown()
+    public function tearDown(): void
     {
         $this->zdb = new \Galette\Core\Db();
         $delete = $this->zdb->delete(\Galette\Entity\Adherent::TABLE);
         $delete->where(['fingerprint' => 'FAKER' . $this->seed]);
         $this->zdb->execute($delete);
+
+        parent::tearDown();
     }
 
     /**
@@ -77,32 +79,31 @@ class Login extends GaletteTestCase
      */
     public function testDefaults()
     {
-        $this->boolean($this->login->isLogged())->isFalse();
-        $this->boolean($this->login->isStaff())->isFalse();
-        $this->boolean($this->login->isAdmin())->isFalse();
-        $this->boolean($this->login->isSuperAdmin())->isFalse();
-        $this->boolean($this->login->isActive())->isFalse();
-        $this->boolean($this->login->isCron())->isFalse();
-        $this->boolean($this->login->isUp2Date())->isFalse();
-        $this->boolean($this->login->isImpersonated())->isFalse();
+        $this->assertFalse($this->login->isLogged());
+        $this->assertFalse($this->login->isStaff());
+        $this->assertFalse($this->login->isAdmin());
+        $this->assertFalse($this->login->isSuperAdmin());
+        $this->assertFalse($this->login->isActive());
+        $this->assertFalse($this->login->isCron());
+        $this->assertFalse($this->login->isUp2Date());
+        $this->assertFalse($this->login->isImpersonated());
     }
 
     /**
-     * Test not logged in users Impersonating
+     * Test not logged-in users Impersonating
      *
      * @return void
      */
     public function testNotLoggedCantImpersonate()
     {
-        $login = new \mock\Galette\Core\Login($this->zdb, $this->i18n);
-
-        $this->calling($login)->isLogged = false;
-        $this
-            ->exception(
-                function () use ($login) {
-                    $login->impersonate(1);
-                }
-            )->hasMessage('Only superadmin can impersonate!');
+        $login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, $this->i18n))
+            ->onlyMethods(array('isLogged'))
+            ->getMock();
+        $login->method('isLogged')->willReturn(false);
+
+        $this->expectExceptionMessage('Only superadmin can impersonate!');
+        $login->impersonate(1);
     }
 
     /**
@@ -112,18 +113,18 @@ class Login extends GaletteTestCase
      */
     public function testStaffCantImpersonate()
     {
-        $login = new \mock\Galette\Core\Login($this->zdb, $this->i18n);
-
-        $this->calling($login)->isLogged = true;
-        $this->calling($login)->isStaff = true;
-        $this->calling($login)->isAdmin = false;
-        $this->calling($login)->isSuperAdmin = false;
-        $this
-            ->exception(
-                function () use ($login) {
-                    $login->impersonate(1);
-                }
-            )->hasMessage('Only superadmin can impersonate!');
+        $login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, $this->i18n))
+            ->onlyMethods(array('isLogged', 'isStaff', 'isAdmin', 'isSuperAdmin'))
+            ->getMock();
+
+        $login->method('isLogged')->willReturn(true);
+        $login->method('isStaff')->willReturn(true);
+        $login->method('isAdmin')->willReturn(false);
+        $login->method('isSuperAdmin')->willReturn(false);
+
+        $this->expectExceptionMessage('Only superadmin can impersonate!');
+        $login->impersonate(1);
     }
 
     /**
@@ -133,17 +134,18 @@ class Login extends GaletteTestCase
      */
     public function testAdminCantImpersonate()
     {
-        $login = new \mock\Galette\Core\Login($this->zdb, $this->i18n);
-        $this->calling($login)->isLogged = true;
-        $this->calling($login)->isStaff = true;
-        $this->calling($login)->isAdmin = true;
-        $this->calling($login)->isSuperAdmin = false;
-        $this
-            ->exception(
-                function () use ($login) {
-                    $login->impersonate(1);
-                }
-            )->hasMessage('Only superadmin can impersonate!');
+        $login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, $this->i18n))
+            ->onlyMethods(array('isLogged', 'isStaff', 'isAdmin', 'isSuperAdmin'))
+            ->getMock();
+
+        $login->method('isLogged')->willReturn(true);
+        $login->method('isStaff')->willReturn(true);
+        $login->method('isAdmin')->willReturn(true);
+        $login->method('isSuperAdmin')->willReturn(false);
+
+        $this->expectExceptionMessage('Only superadmin can impersonate!');
+        $login->impersonate(1);
     }
 
     /**
@@ -153,16 +155,27 @@ class Login extends GaletteTestCase
      */
     public function testImpersonateExistsWException()
     {
-        $zdb = new \mock\Galette\Core\Db();
-        $this->calling($zdb)->execute = function ($o) {
-            if ($o instanceof \Laminas\Db\Sql\Select) {
-                throw new \LogicException('Error executing query!', 123);
-            }
-        };
+        $zdb = $this->getMockBuilder(\Galette\Core\Db::class)
+            ->onlyMethods(array('execute'))
+            ->getMock();
+
+        $zdb->method('execute')
+            ->will(
+                $this->returnCallback(
+                    function ($o) {
+                        throw new \LogicException('Error executing query!', 123);
+                    }
+                )
+            );
+
+        $login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($zdb, $this->i18n))
+            ->onlyMethods(array('isSuperAdmin'))
+            ->getMock();
+
+        $login->method('isSuperAdmin')->willReturn(true);
 
-        $login = new \mock\Galette\Core\Login($zdb, $this->i18n);
-        $this->calling($login)->isSuperAdmin = true;
-        $this->boolean($login->impersonate(1))->isFalse();
+        $this->assertFalse($login->impersonate(1));
     }
 
     /**
@@ -172,21 +185,25 @@ class Login extends GaletteTestCase
      */
     public function testSuperadminCanImpersonate()
     {
-        $login = new \mock\Galette\Core\Login($this->zdb, $this->i18n);
-        $this->calling($login)->isSuperAdmin = true;
+        $login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, $this->i18n))
+            ->onlyMethods(array('isSuperAdmin'))
+            ->getMock();
+
+        $login->method('isSuperAdmin')->willReturn(true);
 
         ///We're faking, Impersonating won't work but will not throw any exception
-        $this->boolean($login->impersonate(1))->isFalse();
+        $this->assertFalse($login->impersonate(1));
     }
 
     /**
-     * Test return requesting an inexisting property
+     * Test return requesting a non-existing property
      *
      * @return void
      */
     public function testInexistingGetter()
     {
-        $this->boolean($this->login->doesnotexists)->isFalse();
+        $this->assertFalse($this->login->doesnotexists);
     }
 
     /**
@@ -196,8 +213,8 @@ class Login extends GaletteTestCase
      */
     public function testLoginExists()
     {
-        $this->boolean($this->login->loginExists('exists'))->isFalse();
-        $this->boolean($this->login->loginExists('doesnotexists'))->isFalse();
+        $this->assertFalse($this->login->loginExists('exists'));
+        $this->assertFalse($this->login->loginExists('doesnotexists'));
     }
 
     /**
@@ -207,15 +224,23 @@ class Login extends GaletteTestCase
      */
     public function testLoginExistsWException()
     {
-        $zdb = new \mock\Galette\Core\Db();
-        $this->calling($zdb)->execute = function ($o) {
-            if ($o instanceof \Laminas\Db\Sql\Select) {
-                throw new \LogicException('Error executing query!', 123);
-            }
-        };
+        $zdb = $this->getMockBuilder(\Galette\Core\Db::class)
+            ->onlyMethods(array('execute'))
+            ->getMock();
+
+        $zdb->method('execute')
+            ->will(
+                $this->returnCallback(
+                    function ($o) {
+                        if ($o instanceof \Laminas\Db\Sql\Select) {
+                            throw new \LogicException('Error executing query!', 123);
+                        }
+                    }
+                )
+            );
 
         $login = new \Galette\Core\Login($zdb, $this->i18n);
-        $this->boolean($login->loginExists('doesnotexists'))->isTrue();
+        $this->assertTrue($login->loginExists('doesnotexists'));
     }
 
     /**
@@ -226,14 +251,14 @@ class Login extends GaletteTestCase
     public function testLogAdmin()
     {
         $this->login->logAdmin('superadmin', $this->preferences);
-        $this->boolean($this->login->isLogged())->isTrue();
-        $this->boolean($this->login->isStaff())->isFalse();
-        $this->boolean($this->login->isAdmin())->isTrue();
-        $this->boolean($this->login->isSuperAdmin())->isTrue();
-        $this->boolean($this->login->isActive())->isTrue();
-        $this->boolean($this->login->isCron())->isFalse();
-        $this->boolean($this->login->isUp2Date())->isFalse();
-        $this->boolean($this->login->isImpersonated())->isFalse();
+        $this->assertTrue($this->login->isLogged());
+        $this->assertFalse($this->login->isStaff());
+        $this->assertTrue($this->login->isAdmin());
+        $this->assertTrue($this->login->isSuperAdmin());
+        $this->assertTrue($this->login->isActive());
+        $this->assertFalse($this->login->isCron());
+        $this->assertFalse($this->login->isUp2Date());
+        $this->assertFalse($this->login->isImpersonated());
 
         //test logout
         $this->login->logOut();
@@ -261,7 +286,7 @@ class Login extends GaletteTestCase
             $status = new \Galette\Entity\Status($this->zdb);
             if (count($status->getList()) === 0) {
                 $res = $status->installInit();
-                $this->boolean($res)->isTrue();
+                $this->assertTrue($res);
             }
 
             $data = [
@@ -303,24 +328,24 @@ class Login extends GaletteTestCase
             if (is_array($check)) {
                 var_dump($check);
             }
-            $this->boolean($check)->isTrue();
+            $this->assertTrue($check);
 
             $store = $this->adh->store();
-            $this->boolean($store)->isTrue();
+            $this->assertTrue($store);
         } else {
             $this->adh = new \Galette\Entity\Adherent($this->zdb, $results->current());
         }
     }
 
     /**
-     * Look for a login that does exists
+     * Look for a login that does exist
      *
      * @return void
      */
     public function testLoginExistsDb()
     {
         $this->createUser();
-        $this->boolean($this->login->loginExists($this->login))->isTrue();
+        $this->assertTrue($this->login->loginExists($this->login));
     }
 
     /**
@@ -331,8 +356,8 @@ class Login extends GaletteTestCase
     public function testLogin()
     {
         $this->createUser();
-        $this->boolean($this->login->login('doenotexists', 'empty'))->isFalse();
-        $this->boolean($this->login->login($this->login_adh, $this->mdp_adh))->isTrue();
+        $this->assertFalse($this->login->login('doenotexists', 'empty'));
+        $this->assertTrue($this->login->login($this->login_adh, $this->mdp_adh));
     }
 
     /**
@@ -345,7 +370,7 @@ class Login extends GaletteTestCase
         global $translator;
 
         $this->createUser();
-        $this->boolean($this->login->login($this->login_adh, $this->mdp_adh))->isTrue();
+        $this->assertTrue($this->login->login($this->login_adh, $this->mdp_adh));
 
         /** Should get message in the right locale but doesn't... */
         $this->i18n->changeLanguage('en_US');
@@ -354,14 +379,15 @@ class Login extends GaletteTestCase
             'galette',
             $this->login->lang
         );
-        $this->string($this->login->loggedInAs())->isIdenticalTo(
+        $this->assertSame(
             str_replace(
                 '%login',
                 'Barre Olivier (dumas.roger)',
                 $tstring
-            )
+            ),
+            $this->login->loggedInAs()
         );
-        $this->string($this->login->loggedInAs(true))->isIdenticalTo('Barre Olivier (dumas.roger)');
+        $this->assertSame('Barre Olivier (dumas.roger)', $this->login->loggedInAs(true));
     }
 
     /**
@@ -372,23 +398,18 @@ class Login extends GaletteTestCase
     public function testLogCron()
     {
         $this->login->logCron('reminder');
-        $this->boolean($this->login->isLogged())->isTrue();
-        $this->boolean($this->login->isStaff())->isFalse();
-        $this->boolean($this->login->isAdmin())->isFalse();
-        $this->boolean($this->login->isSuperAdmin())->isFalse();
-        $this->boolean($this->login->isActive())->isFalse();
-        $this->boolean($this->login->isCron())->isTrue();
-        $this->boolean($this->login->isUp2Date())->isFalse();
-        $this->boolean($this->login->isImpersonated())->isFalse();
-        $this->string($this->login->login)->isIdenticalTo('cron');
-
-        $this->when(
-            function () {
-                $this->login->logCron('filename');
-            }
-        )->error()
-            ->withMessage('Not authorized!')
-            ->withType(E_USER_ERROR)
-            ->exists();
+        $this->assertTrue($this->login->isLogged());
+        $this->assertFalse($this->login->isStaff());
+        $this->assertFalse($this->login->isAdmin());
+        $this->assertFalse($this->login->isSuperAdmin());
+        $this->assertFalse($this->login->isActive());
+        $this->assertTrue($this->login->isCron());
+        $this->assertFalse($this->login->isUp2Date());
+        $this->assertFalse($this->login->isImpersonated());
+        $this->assertSame('cron', $this->login->login);
+
+        $this->expectException('Exception');
+        $this->expectExceptionMessage('Not authorized!');
+        $this->login->logCron('filename');
     }
 }
index 4d35660d1da2040488ebe014434aede19630afe7..1b682e5d8b8ab63400e637bfb13a6660953cc4b7 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\Core\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Picture tests class
@@ -51,18 +51,16 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2017-07-08
  */
-class Logo extends atoum
+class Logo extends TestCase
 {
     private \Galette\Core\Db $zdb;
 
     /**
      * Set up tests
      *
-     * @param string $method Method name
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         global $zdb;
         $this->zdb = new \Galette\Core\Db();
@@ -72,14 +70,12 @@ class Logo extends atoum
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
         if (TYPE_DB === 'mysql') {
-            $this->array($this->zdb->getWarnings())->isIdenticalTo([]);
+            $this->assertSame($this->zdb->getWarnings(), []);
         }
     }
 
@@ -94,17 +90,16 @@ class Logo extends atoum
         $zdb = $this->zdb;
         $expected_path = realpath(GALETTE_ROOT . 'webroot/themes/default/images/galette.png');
 
-        $this->given($this->newTestedInstance)
-            ->then
-                ->variable($this->testedInstance->getDestDir())->isNull()
-                ->variable($this->testedInstance->getFileName())->isNull()
-                ->string($this->testedInstance->getPath())->isIdenticalTo($expected_path)
-                ->string($this->testedInstance->getMime())->isIdenticalTo('image/png')
-                ->string($this->testedInstance->getFormat())->isIdenticalTo('png')
-                ->boolean($this->testedInstance->isCustom())->isFalse()
-                ->integer($this->testedInstance->getOptimalWidth())->isIdenticalTo(129)
-                ->integer($this->testedInstance->getOptimalHeight())->isIdenticalTo(60)
-                ->integer($this->testedInstance->getWidth())->isIdenticalTo(129)
-                ->integer($this->testedInstance->getHeight())->isIdenticalTo(60);
+        $instance = new \Galette\Core\Logo($this->zdb);
+        $this->assertNull($instance->getDestDir());
+        $this->assertNull($instance->getFileName());
+        $this->assertSame($expected_path, $instance->getPath());
+        $this->assertSame('image/png', $instance->getMime());
+        $this->assertSame('png', $instance->getFormat());
+        $this->assertFalse($instance->isCustom());
+        $this->assertSame(129, $instance->getOptimalWidth());
+        $this->assertSame(60, $instance->getOptimalHeight());
+        $this->assertSame(129, $instance->getWidth());
+        $this->assertSame(60, $instance->getHeight());
     }
 }
index 7ef0655e654326668955f103021b06500842860b..7f96f448ed20dcf71c089704d8cb8740b118614c 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\Core\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Password tests class
@@ -51,7 +51,7 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2013-01-13
  */
-class Password extends atoum
+class Password extends TestCase
 {
     private ?\Galette\Core\Password $pass = null;
     private \Galette\Core\Db $zdb;
@@ -59,11 +59,9 @@ class Password extends atoum
     /**
      * Set up tests
      *
-     * @param string $method Method name
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $this->zdb = new \Galette\Core\Db();
         $this->pass = new \Galette\Core\Password($this->zdb, false);
@@ -72,14 +70,12 @@ class Password extends atoum
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
         if (TYPE_DB === 'mysql') {
-            $this->array($this->zdb->getWarnings())->isIdenticalTo([]);
+            $this->assertSame([], $this->zdb->getWarnings());
         }
     }
 
@@ -94,17 +90,17 @@ class Password extends atoum
 
         for ($i = 0; $i < 200; $i++) {
             $random = $this->pass->makeRandomPassword(15);
-            $this->string($random)->hasLength(15);
+            $this->assertSame(15, strlen($random));
 
             $exists = in_array($random, $results);
-            $this->boolean($exists)->isFalse();
+            $this->assertFalse($exists);
 
             $results[] = $random;
-            $this->array($results)->hasSize($i + 1);
+            $this->assertCount($i + 1, $results);
         }
 
         $random = $this->pass->makeRandomPassword();
-        $this->string($random)->hasLength(\Galette\Core\Password::DEFAULT_SIZE);
+        $this->assertSame(\Galette\Core\Password::DEFAULT_SIZE, strlen($random));
     }
 
     /**
@@ -123,7 +119,7 @@ class Password extends atoum
         $status = new \Galette\Entity\Status($this->zdb);
         if (count($status->getList()) === 0) {
             $res = $status->installInit();
-            $this->boolean($res)->isTrue();
+            $this->assertTrue($res);
         }
         $insert = $this->zdb->insert(\Galette\Entity\Adherent::TABLE);
         $insert->values(
@@ -166,25 +162,24 @@ class Password extends atoum
         $id_adh = $this->createMember();
         $pass = $this->pass;
         $res = $pass->generateNewPassword($id_adh);
-        $this->boolean($res)->isTrue();
+        $this->assertTrue($res);
         $new_pass = $pass->getNewPassword();
-        $this->string($new_pass)
-            ->hasLength($pass::DEFAULT_SIZE);
+        $this->assertSame($pass::DEFAULT_SIZE, strlen($new_pass));
         $hash = $pass->getHash();
-        $this->string($hash)->hasLength(60);
+        $this->assertSame(60, strlen($hash));
 
         $is_valid = $pass->isHashValid($hash);
-        $this->variable($is_valid)->isNotNull();
+        $this->assertNotNull($is_valid);
 
         $select = $this->zdb->select(\Galette\Core\Password::TABLE);
         $results = $this->zdb->execute($select);
-        $this->integer($results->count())->isIdenticalTo(1);
+        $this->assertSame(1, $results->count());
 
         $removed = $pass->removeHash($hash);
-        $this->boolean($removed)->isTrue();
+        $this->assertTrue($removed);
 
         $results = $this->zdb->execute($select);
-        $this->integer($results->count())->isIdenticalTo(0);
+        $this->assertSame(0, $results->count());
 
         $this->deleteMember();
     }
@@ -213,12 +208,12 @@ class Password extends atoum
 
         $select = $this->zdb->select(\Galette\Core\Password::TABLE);
         $results = $this->zdb->execute($select);
-        $this->integer($results->count())->isIdenticalTo(1);
+        $this->assertSame(1, $results->count());
 
         $pass = new \Galette\Core\Password($this->zdb, true);
 
         $results = $this->zdb->execute($select);
-        $this->integer($results->count())->isIdenticalTo(0);
+        $this->assertSame(0, $results->count());
 
         $this->deleteMember();
     }
@@ -230,14 +225,22 @@ class Password extends atoum
      */
     public function testGenerateNewPasswordWException()
     {
-        $this->zdb = new \mock\Galette\Core\Db();
-        $this->calling($this->zdb)->execute = function ($o) {
-            throw new \LogicException('Error executing query!', 123);
-        };
+        $this->zdb = $this->getMockBuilder(\Galette\Core\Db::class)
+            ->onlyMethods(array('execute'))
+            ->getMock();
+
+        $this->zdb->method('execute')
+            ->will(
+                $this->returnCallback(
+                    function ($o) {
+                        throw new \LogicException('Error executing query!', 123);
+                    }
+                )
+            );
 
         $pass = new \Galette\Core\Password($this->zdb, false);
         $res = $pass->generateNewPassword(12);
-        $this->boolean($res)->isFalse();
+        $this->assertFalse($res);
     }
 
     /**
@@ -247,14 +250,22 @@ class Password extends atoum
      */
     public function testGenerateNewPasswordWFalseInsert()
     {
-        $this->zdb = new \mock\Galette\Core\Db();
-        $this->calling($this->zdb)->execute = function ($o) {
-            throw new \Exception('Ba. Da. Boum.');
-        };
+        $this->zdb = $this->getMockBuilder(\Galette\Core\Db::class)
+            ->onlyMethods(array('execute'))
+            ->getMock();
+
+        $this->zdb->method('execute')
+            ->will(
+                $this->returnCallback(
+                    function ($o) {
+                        throw new \LogicException('Error executing query!', 123);
+                    }
+                )
+            );
 
         $pass = new \Galette\Core\Password($this->zdb, false);
         $res = $pass->generateNewPassword(12);
-        $this->boolean($res)->isFalse();
+        $this->assertFalse($res);
     }
 
     /**
@@ -264,13 +275,21 @@ class Password extends atoum
      */
     public function testCleanExpiredWException()
     {
-        $this->zdb = new \mock\Galette\Core\Db();
-        $this->calling($this->zdb)->execute = function ($o) {
-            throw new \LogicException('Error executing query!', 123);
-        };
+        $this->zdb = $this->getMockBuilder(\Galette\Core\Db::class)
+            ->onlyMethods(array('execute'))
+            ->getMock();
+
+        $this->zdb->method('execute')
+            ->will(
+                $this->returnCallback(
+                    function ($o) {
+                        throw new \LogicException('Error executing query!', 123);
+                    }
+                )
+            );
 
         $pass = new \Galette\Core\Password($this->zdb, false);
-        $this->boolean($pass->cleanExpired())->isFalse();
+        $this->assertFalse($pass->cleanExpired());
     }
 
     /**
@@ -280,14 +299,22 @@ class Password extends atoum
      */
     public function testIsHashValidWException()
     {
-        $this->zdb = new \mock\Galette\Core\Db();
-        $this->calling($this->zdb)->execute = function ($o) {
-            throw new \LogicException('Error executing query!', 123);
-        };
+        $this->zdb = $this->getMockBuilder(\Galette\Core\Db::class)
+            ->onlyMethods(array('execute'))
+            ->getMock();
+
+        $this->zdb->method('execute')
+            ->will(
+                $this->returnCallback(
+                    function ($o) {
+                        throw new \LogicException('Error executing query!', 123);
+                    }
+                )
+            );
 
         $pass = new \Galette\Core\Password($this->zdb, false);
         $res = $pass->isHashValid('thehash');
-        $this->boolean($res)->isFalse();
+        $this->assertFalse($res);
     }
 
     /**
@@ -297,13 +324,21 @@ class Password extends atoum
      */
     public function testRemoveHashWException()
     {
-        $this->zdb = new \mock\Galette\Core\Db();
-        $this->calling($this->zdb)->execute = function ($o) {
-            throw new \LogicException('Error executing query!', 123);
-        };
+        $this->zdb = $this->getMockBuilder(\Galette\Core\Db::class)
+            ->onlyMethods(array('execute'))
+            ->getMock();
+
+        $this->zdb->method('execute')
+            ->will(
+                $this->returnCallback(
+                    function ($o) {
+                        throw new \LogicException('Error executing query!', 123);
+                    }
+                )
+            );
 
         $pass = new \Galette\Core\Password($this->zdb, false);
         $res = $pass->removeHash('thehash');
-        $this->boolean($res)->isFalse();
+        $this->assertFalse($res);
     }
 }
index 2ce08b024b36bdf8efc0fef91f769dff99a2ff8c..4354f6b7866e0de967c0f72fbe5241d56e0e116e 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\Core\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Picture tests class
@@ -51,7 +51,7 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2017-05-14
  */
-class Picture extends atoum
+class Picture extends TestCase
 {
     private \Galette\Core\Db $zdb;
     private \Galette\Core\Picture $picture;
@@ -73,11 +73,9 @@ class Picture extends atoum
     /**
      * Set up tests
      *
-     * @param string $method Method name
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $this->zdb = new \Galette\Core\Db();
         $this->picture = new \Galette\Core\Picture();
@@ -86,14 +84,12 @@ class Picture extends atoum
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
         if (TYPE_DB === 'mysql') {
-            $this->array($this->zdb->getWarnings())->isIdenticalTo([]);
+            $this->assertSame([], $this->zdb->getWarnings());
         }
     }
 
@@ -105,21 +101,23 @@ class Picture extends atoum
     public function testDefaults()
     {
         $picture = new \Galette\Core\Picture();
-        $this->variable($picture->getDestDir())->isNull();
-        $this->variable($picture->getFileName())->isNull();
+        $this->assertNull($picture->getDestDir());
+        $this->assertNull($picture->getFileName());
 
         $expected_exts = ['jpeg', 'jpg', 'png', 'gif'];
-        $this->string($picture->getAllowedExts())->isIdenticalTo(implode(', ', $expected_exts));
+        $this->assertSame(implode(', ', $expected_exts), $picture->getAllowedExts());
 
         $expected_mimes = [
             'jpg'    =>    'image/jpeg',
             'png'    =>    'image/png',
             'gif'    =>    'image/gif'
         ];
-        $this->array($picture->getAllowedMimeTypes())->isIdenticalTo($expected_mimes);
+        $this->assertSame($expected_mimes, $picture->getAllowedMimeTypes());
 
-        $this->string($this->picture->getBadChars())
-            ->isIdenticalTo('`' . implode('`, `', $this->expected_badchars) . '`');
+        $this->assertSame(
+            '`' . implode('`, `', $this->expected_badchars) . '`',
+            $this->picture->getBadChars()
+        );
     }
 
     /**
@@ -129,14 +127,14 @@ class Picture extends atoum
      */
     public function testSetters()
     {
-        $this->variable($this->picture->getDestDir())->isNull();
-        $this->variable($this->picture->getFileName())->isNull();
+        $this->assertNull($this->picture->getDestDir());
+        $this->assertNull($this->picture->getFileName());
 
         $this->picture->setDestDir(__DIR__);
-        $this->string($this->picture->getDestDir())->isIdenticalTo(__DIR__);
+        $this->assertSame(__DIR__, $this->picture->getDestDir());
 
         $this->picture->setFileName('myfile.png');
-        $this->string($this->picture->getFileName())->isIdenticalTo('myfile.png');
+        $this->assertSame('myfile.png', $this->picture->getFileName());
     }
 
     /**
@@ -148,18 +146,18 @@ class Picture extends atoum
     public function testFileInfoMimeType()
     {
         $url = realpath(GALETTE_ROOT . '../tests/fake_image.jpg');
-        $this->variable($url)->isNotFalse();
-        $this->variable($this->picture->getMimeType($url))->isIdenticalTo('image/jpeg');
+        $this->assertNotFalse($url);
+        $this->assertSame('image/jpeg', $this->picture->getMimeType($url));
 
         $url = realpath(GALETTE_ROOT . '../galette/webroot/themes/default/images/galette.png');
-        $this->variable($url)->isNotFalse();
-        $this->variable($this->picture->getMimeType($url))->isIdenticalTo('image/png');
+        $this->assertNotFalse($url);
+        $this->assertSame('image/png', $this->picture->getMimeType($url));
 
         $url = realpath(GALETTE_ROOT . '../tests/test.gif');
-        $this->variable($url)->isNotFalse();
-        $this->variable($this->picture->getMimeType($url))->isIdenticalTo('image/gif');
+        $this->assertNotFalse($url);
+        $this->assertSame('image/gif', $this->picture->getMimeType($url));
 
-        $this->variable($this->picture->getMimeType(__DIR__ . '/Picture.php'))->isIdenticalTo('text/x-php');
+        $this->assertSame('text/x-php', $this->picture->getMimeType(__DIR__ . '/Picture.php'));
     }
 
     /**
@@ -173,7 +171,7 @@ class Picture extends atoum
     /*public function testMimeContentTypeMimeType()
     {
         $url = realpath(GALETTE_ROOT . '../tests/fake_image.jpg');
-        $this->variable($url)->isNotFalse();
+        $this->assertNotFalse($url);
 
         $this->assert('FileInfo extension missing')
             ->given($picture = new \Galette\Core\Picture())
@@ -199,7 +197,7 @@ class Picture extends atoum
                 'name'      => 'file-with-' . $badchar . '-char.jpg',
                 'tmp_name'  => 'none'
             ];
-            $this->integer($this->picture->store($file))->isIdenticalTo($expected);
+            $this->assertSame($expected, $this->picture->store($file));
         }
 
         $files = [
@@ -218,7 +216,7 @@ class Picture extends atoum
                 'size'      => \Galette\Core\Picture::MAX_FILE_SIZE * 1024 * 100
             ];
             //Will fail on filesize, but this is OK, filenames and extensions have been checked :)
-            $this->integer($this->picture->store($file))->isIdenticalTo(\Galette\Core\Picture::FILE_TOO_BIG);
+            $this->assertSame(\Galette\Core\Picture::FILE_TOO_BIG, $this->picture->store($file));
         }
     }
 
@@ -229,21 +227,37 @@ class Picture extends atoum
      */
     public function testErrorMessages()
     {
-        $this->string($this->picture->getErrorMessage(\Galette\Core\Picture::INVALID_FILENAME))
-            ->isIdenticalTo('File name is invalid, it should not contain any special character or space.');
-        $this->string($this->picture->getErrorMessage(\Galette\Core\Picture::INVALID_EXTENSION))
-            ->isIdenticalTo('File extension is not allowed, only jpeg, jpg, png, gif files are.');
-        $this->string($this->picture->getErrorMessage(\Galette\Core\Picture::FILE_TOO_BIG))
-            ->isIdenticalTo('File is too big. Maximum allowed size is 1024Ko');
-        $this->string($this->picture->getErrorMessage(\Galette\Core\Picture::MIME_NOT_ALLOWED))
-            ->isIdenticalTo('Mime-Type not allowed');
-        $this->string($this->picture->getErrorMessage(\Galette\Core\Picture::INVALID_FILE))
-            ->isIdenticalTo('File does not comply with requirements.');
-        $this->string($this->picture->getErrorMessage(\Galette\Core\Picture::CANT_WRITE))
-            ->isIdenticalTo('Unable to write file or temporary file');
-        $this->string($this->picture->getErrorMessage(\Galette\Core\Picture::SQL_ERROR))
-            ->isIdenticalTo('An SQL error has occurred.');
-        $this->string($this->picture->getErrorMessage(\Galette\Core\Picture::SQL_BLOB_ERROR))
-            ->isIdenticalTo('An SQL error has occurred.');
+        $this->assertSame(
+            'File name is invalid, it should not contain any special character or space.',
+            $this->picture->getErrorMessage(\Galette\Core\Picture::INVALID_FILENAME)
+        );
+        $this->assertSame(
+            'File extension is not allowed, only jpeg, jpg, png, gif files are.',
+            $this->picture->getErrorMessage(\Galette\Core\Picture::INVALID_EXTENSION)
+        );
+        $this->assertSame(
+            'File is too big. Maximum allowed size is 1024Ko',
+            $this->picture->getErrorMessage(\Galette\Core\Picture::FILE_TOO_BIG)
+        );
+        $this->assertSame(
+            'Mime-Type not allowed',
+            $this->picture->getErrorMessage(\Galette\Core\Picture::MIME_NOT_ALLOWED)
+        );
+        $this->assertSame(
+            'File does not comply with requirements.',
+            $this->picture->getErrorMessage(\Galette\Core\Picture::INVALID_FILE)
+        );
+        $this->assertSame(
+            'Unable to write file or temporary file',
+            $this->picture->getErrorMessage(\Galette\Core\Picture::CANT_WRITE)
+        );
+        $this->assertSame(
+            'An SQL error has occurred.',
+            $this->picture->getErrorMessage(\Galette\Core\Picture::SQL_ERROR)
+        );
+        $this->assertSame(
+            'An SQL error has occurred.',
+            $this->picture->getErrorMessage(\Galette\Core\Picture::SQL_BLOB_ERROR)
+        );
     }
 }
index f315a87b3677f6c2a3676f2b586a283c05f28df9..372a05ef9d9e8b652fbd36bbb3e44f171fcda082 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\Core\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Plugins tests class
@@ -51,7 +51,7 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2013-01-13
  */
-class Plugins extends atoum
+class Plugins extends TestCase
 {
     private \Galette\Core\Db $zdb;
     private \Galette\Core\Preferences $preferences;
@@ -89,11 +89,9 @@ class Plugins extends atoum
     /**
      * Set up tests
      *
-     * @param string $method Method tested
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $this->zdb = new \Galette\Core\Db();
         $this->preferences = new \Galette\Core\Preferences($this->zdb);
@@ -107,14 +105,12 @@ class Plugins extends atoum
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
         if (TYPE_DB === 'mysql') {
-            $this->array($this->zdb->getWarnings())->isIdenticalTo([]);
+            $this->assertSame([], $this->zdb->getWarnings());
         }
     }
 
@@ -126,15 +122,12 @@ class Plugins extends atoum
     public function testLoadModules()
     {
         $plugins = $this->getPlugins();
-
-        $this->array($this->plugins->getModules())
-            ->hasSize(3);
+        $this->assertCount(3, $this->plugins->getModules());
 
         $loaded_plugin = $this->plugins->getModules('plugin-test2');
         $loaded_plugin['date'] = $this->plugin2['date'];
 
-        $this->variable($loaded_plugin)
-            ->isIdenticalTo($this->plugin2);
+        $this->assertSame($this->plugin2, $loaded_plugin);
     }
 
     /**
@@ -144,10 +137,8 @@ class Plugins extends atoum
      */
     public function testModuleExists()
     {
-        $this->boolean($this->plugins->moduleExists('plugin-test2'))
-            ->isTrue();
-        $this->boolean($this->plugins->moduleExists('plugin-disabled'))
-            ->isFalse();
+        $this->assertTrue($this->plugins->moduleExists('plugin-test2'));
+        $this->assertFalse($this->plugins->moduleExists('plugin-disabled'));
     }
 
     /**
@@ -157,14 +148,10 @@ class Plugins extends atoum
      */
     public function testDisabledModules()
     {
-        $this->array($this->plugins->getDisabledModules())
-            ->hasKeys(
-                array(
-                    'plugin-disabled',
-                    'plugin-unversionned',
-                    'plugin-oldversion'
-                )
-            );
+        $disabled_modules = $this->plugins->getDisabledModules();
+        $this->assertTrue(isset($disabled_modules['plugin-disabled']));
+        $this->assertTrue(isset($disabled_modules['plugin-unversionned']));
+        $this->assertTrue(isset($disabled_modules['plugin-oldversion']));
     }
 
     /**
@@ -174,8 +161,7 @@ class Plugins extends atoum
      */
     public function testModuleRoot()
     {
-        $this->variable($this->plugins->moduleRoot('plugin-test2'))
-            ->isIdenticalTo($this->plugin2['root']);
+        $this->assertSame($this->plugin2['root'], $this->plugins->moduleRoot('plugin-test2'));
     }
 
     /**
@@ -201,8 +187,7 @@ class Plugins extends atoum
     {
         $this->plugins->resetModulesList();
 
-        $this->array($this->plugins->getModules())
-            ->isempty();
+        $this->assertEmpty($this->plugins->getModules());
     }
 
     /**
@@ -213,35 +198,29 @@ class Plugins extends atoum
     public function testModuleActivation()
     {
         $plugins = $this->getPlugins();
-        $this->array($plugins->getModules())
-            ->hasSize(3)
-            ->hasKey('plugin-test2');
+        $modules = $plugins->getModules();
+        $this->assertCount(3, $modules);
+        $this->assertTrue(isset($modules['plugin-test2']));
         $plugins->deactivateModule('plugin-test2');
 
         $plugins = $this->getPlugins();
-        $this->array($plugins->getModules())
-            ->hasSize(2)
-            ->notHasKey('plugin-test2');
+        $modules = $plugins->getModules();
+        $this->assertCount(2, $modules);
+        $this->assertFalse(isset($module['plugin-test2']));
         $plugins->activateModule('plugin-test2');
 
         $plugins = $this->getPlugins();
-        $this->array($plugins->getModules())
-            ->hasSize(3)
-            ->hasKey('plugin-test2');
+        $modules = $plugins->getModules();
+        $this->assertCount(3, $modules);
+        $this->assertTrue(isset($modules['plugin-test2']));
 
-        $this->exception(
-            function () {
-                $plugins = $this->getPlugins();
-                $plugins->deactivateModule('nonexistant');
-            }
-        )->hasMessage(_T('No such module.'));
+        $plugins = $this->getPlugins();
+        $this->expectExceptionMessage(_T('No such module.'));
+        $plugins->deactivateModule('nonexistant');
 
-        $this->exception(
-            function () {
-                $plugins = $this->getPlugins();
-                $plugins->activateModule('nonexistant');
-            }
-        )->hasMessage(_T('No such module.'));
+        $plugins = $this->getPlugins();
+        $this->expectExceptionMessage(_T('No such module.'));
+        $plugins->activateModule('nonexistant');
     }
 
     /**
@@ -251,16 +230,11 @@ class Plugins extends atoum
      */
     public function testNeedDatabse()
     {
-        $this->boolean($this->plugins->needsDatabase('plugin-db'))
-            ->isTrue();
-        $this->boolean($this->plugins->needsDatabase('plugin-test2'))
-            ->isFalse();
+        $this->assertTrue($this->plugins->needsDatabase('plugin-db'));
+        $this->assertFalse($this->plugins->needsDatabase('plugin-test2'));
 
-        $this->exception(
-            function () {
-                $plugins = $this->getPlugins();
-                $plugins->needsDatabase('nonexistant');
-            }
-        )->hasMessage(_T('Module does not exists!'));
+        $plugins = $this->getPlugins();
+        $this->expectExceptionMessage(_T('Module does not exists!'));
+        $plugins->needsDatabase('nonexistant');
     }
 }
index e0e1469feae4e98e194898b4ef7bd11fbc13af44..d7eae69a2817fc6764b99416d5f014aeacd0e612 100644 (file)
@@ -37,9 +37,7 @@
 
 namespace Galette\Core\test\units;
 
-use atoum;
-use Galette\Middleware\Authenticate;
-use Slim\Routing\RouteParser;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Preferences tests class
@@ -53,7 +51,7 @@ use Slim\Routing\RouteParser;
  * @link      http://galette.tuxfamily.org
  * @since     2013-01-13
  */
-class Preferences extends atoum
+class Preferences extends TestCase
 {
     private ?\Galette\Core\Preferences $preferences = null;
     private \Galette\Core\Db $zdb;
@@ -62,11 +60,9 @@ class Preferences extends atoum
     /**
      * Set up tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $gapp =  new \Galette\Core\SlimApp();
         $app = $gapp->getApp();
@@ -82,24 +78,22 @@ class Preferences extends atoum
         $this->preferences = $container->get('preferences');
 
         global $routeparser;
-        $routeparser = $container->get(RouteParser::class);
+        $routeparser = $container->get(\Slim\Routing\RouteParser::class);
 
-        $authenticate = new Authenticate($container);
-        require_once GALETTE_ROOT . 'includes/routes/main.routes.php';
-        require_once GALETTE_ROOT . 'includes/routes/authentication.routes.php';
+        $authenticate = new \Galette\Middleware\Authenticate($container);
+        require GALETTE_ROOT . 'includes/routes/main.routes.php';
+        require GALETTE_ROOT . 'includes/routes/authentication.routes.php';
     }
 
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
         if (TYPE_DB === 'mysql') {
-            $this->array($this->zdb->getWarnings())->isIdenticalTo([]);
+            $this->assertSame([], $this->zdb->getWarnings());
         }
 
         $delete = $this->zdb->delete(\Galette\Entity\Social::TABLE);
@@ -118,7 +112,7 @@ class Preferences extends atoum
             'da_admin',
             password_hash('da_secret', PASSWORD_BCRYPT)
         );
-        $this->boolean($result)->isTrue();
+        $this->assertTrue($result);
 
         //new object with values loaded from database to compare
         $prefs = new \Galette\Core\Preferences($this->zdb);
@@ -128,20 +122,20 @@ class Preferences extends atoum
 
             switch ($key) {
                 case 'pref_admin_login':
-                    $this->variable($value)->isIdenticalTo('da_admin');
+                    $this->assertSame('da_admin', $value);
                     break;
                 case 'pref_admin_pass':
                     $pw_checked = password_verify('da_secret', $value);
-                    $this->boolean($pw_checked)->isTrue();
+                    $this->assertTrue($pw_checked);
                     break;
                 case 'pref_lang':
-                    $this->variable($value)->isIdenticalTo('en_US');
+                    $this->assertSame('en_US', $value);
                     break;
                 case 'pref_card_year':
-                    $this->variable($value)->isIdenticalTo(date('Y'));
+                    $this->assertSame(date('Y'), $value);
                     break;
                 default:
-                    $this->variable($value)->isEqualTo($expected);
+                    $this->assertEquals($expected, $value);
                     break;
             }
         }
@@ -149,20 +143,20 @@ class Preferences extends atoum
         //tru to set and get a non existent value
         $prefs->doesnotexists = 'that *does* not exists.';
         $false_result = $prefs->doesnotexists;
-        $this->boolean($false_result)->isFalse();
+        $this->assertFalse($false_result);
 
         //change slogan
         $slogan = 'One Galette to rule them all';
         $prefs->pref_slogan = $slogan;
         $check = $prefs->pref_slogan;
-        $this->string($check)->isIdenticalTo($slogan);
+        $this->assertSame($slogan, $check);
 
         //change password
         $new_pass = 'anoth3er_s3cr3t';
         $prefs->pref_admin_pass = $new_pass;
         $pass = $prefs->pref_admin_pass;
         $pw_checked = password_verify($new_pass, $pass);
-        $this->boolean($pw_checked)->isTrue();
+        $this->assertTrue($pw_checked);
 
         $this->preferences->pref_nom = 'Galette';
         $this->preferences->pref_ville = 'Avignon';
@@ -174,20 +168,20 @@ class Preferences extends atoum
         $expected = "Galette\nPalais des Papes\nAu milieu\n84000 Avignon - France";
         $address = $this->preferences->getPostalAddress();
 
-        $this->variable($address)->isIdenticalTo($expected);
+        $this->assertSame($expected, $address);
 
         $slogan = $this->preferences->pref_slogan;
-        $this->variable($slogan)->isEqualTo('');
+        $this->assertEquals('', $slogan);
 
         $slogan = 'One Galette to rule them all';
         $this->preferences->pref_slogan = $slogan;
         $result = $this->preferences->store();
 
-        $this->boolean($result)->isTrue();
+        $this->assertTrue($result);
 
         $prefs = new \Galette\Core\Preferences($this->zdb);
         $check_slogan = $prefs->pref_slogan;
-        $this->variable($check_slogan)->isEqualTo($slogan);
+        $this->assertEquals($slogan, $check_slogan);
 
         //reset database value...
         $this->preferences->pref_slogan = '';
@@ -208,7 +202,7 @@ class Preferences extends atoum
         sort($fields_names);
         sort($expected);
 
-        $this->array($fields_names)->isIdenticalTo($expected);
+        $this->assertSame($expected, $fields_names);
     }
 
     /**
@@ -238,15 +232,15 @@ class Preferences extends atoum
         $footer = $this->preferences->pref_footer;
         $new_contrib_script = $this->preferences->pref_new_contrib_script;
 
-        $this->boolean($footer)->isFalse();
-        $this->boolean($new_contrib_script)->isFalse();
+        $this->assertFalse($footer);
+        $this->assertFalse($new_contrib_script);
 
         $prefs = new \Galette\Core\Preferences($this->zdb);
         $footer = $prefs->pref_footer;
         $new_contrib_script = $prefs->pref_new_contrib_script;
 
-        $this->variable($footer)->isIdenticalTo('');
-        $this->variable($new_contrib_script)->isIdenticalTo('');
+        $this->assertSame('', $footer);
+        $this->assertSame('', $new_contrib_script);
     }
 
     /**
@@ -259,8 +253,9 @@ class Preferences extends atoum
         $this->preferences->load();
 
         $visibility = $this->preferences->pref_publicpages_visibility;
-        $this->variable($visibility)->isEqualTo(
-            \Galette\Core\Preferences::PUBLIC_PAGES_VISIBILITY_RESTRICTED
+        $this->assertEquals(
+            \Galette\Core\Preferences::PUBLIC_PAGES_VISIBILITY_RESTRICTED,
+            $visibility
         );
 
         $anon_login = new \Galette\Core\Login(
@@ -268,50 +263,50 @@ class Preferences extends atoum
             new \Galette\Core\I18n()
         );
 
-        $admin_login = new \mock\Galette\Core\Login(
-            $this->zdb,
-            new \Galette\Core\I18n()
-        );
-        $this->calling($admin_login)->isAdmin = true;
+        $admin_login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, new \Galette\Core\I18n()))
+            ->onlyMethods(array('isAdmin'))
+            ->getMock();
+        $admin_login->method('isAdmin')->willReturn(true);
 
-        $user_login = new \mock\Galette\Core\Login(
-            $this->zdb,
-            new \Galette\Core\I18n()
-        );
-        $this->calling($user_login)->isUp2Date = true;
+        $user_login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, new \Galette\Core\I18n()))
+            ->onlyMethods(array('isUp2Date'))
+            ->getMock();
+        $user_login->method('isUp2Date')->willReturn(true);
 
         $visible = $this->preferences->showPublicPages($anon_login);
-        $this->boolean($visible)->isFalse();
+        $this->assertFalse($visible);
 
         $visible = $this->preferences->showPublicPages($admin_login);
-        $this->boolean($visible)->isTrue();
+        $this->assertTrue($visible);
 
         $visible = $this->preferences->showPublicPages($user_login);
-        $this->boolean($visible)->isTrue();
+        $this->assertTrue($visible);
 
         $this->preferences->pref_publicpages_visibility
             = \Galette\Core\Preferences::PUBLIC_PAGES_VISIBILITY_PUBLIC;
 
         $visible = $this->preferences->showPublicPages($anon_login);
-        $this->boolean($visible)->isTrue();
+        $this->assertTrue($visible);
 
         $visible = $this->preferences->showPublicPages($admin_login);
-        $this->boolean($visible)->isTrue();
+        $this->assertTrue($visible);
 
         $visible = $this->preferences->showPublicPages($user_login);
-        $this->boolean($visible)->isTrue();
+        $this->assertTrue($visible);
 
         $this->preferences->pref_publicpages_visibility
             = \Galette\Core\Preferences::PUBLIC_PAGES_VISIBILITY_PRIVATE;
 
         $visible = $this->preferences->showPublicPages($anon_login);
-        $this->boolean($visible)->isFalse();
+        $this->assertFalse($visible);
 
         $visible = $this->preferences->showPublicPages($admin_login);
-        $this->boolean($visible)->isTrue();
+        $this->assertTrue($visible);
 
         $visible = $this->preferences->showPublicPages($user_login);
-        $this->boolean($visible)->isFalse();
+        $this->assertFalse($visible);
     }
 
     /**
@@ -319,7 +314,7 @@ class Preferences extends atoum
      *
      * @return array
      */
-    protected function sizesProvider()
+    public static function sizesProvider()
     {
         return [
             [//defaults
@@ -381,7 +376,7 @@ class Preferences extends atoum
         $this->preferences->pref_card_marges_h = $hm;
         $this->preferences->pref_card_vspace = $vs;
         $this->preferences->pref_card_hspace = $hs;
-        $this->array($this->preferences->checkCardsSizes())->hasSize($count);
+        $this->assertCount($count, $this->preferences->checkCardsSizes());
     }
 
     /**
@@ -389,7 +384,7 @@ class Preferences extends atoum
      *
      * @return array
      */
-    protected function colorsProvider(): array
+    public static function colorsProvider(): array
     {
         return [
             [
@@ -428,7 +423,7 @@ class Preferences extends atoum
     {
         $prop = 'pref_card_' . $prop;
         $this->preferences->$prop = $color;
-        $this->string($this->preferences->$prop)->isIdenticalTo($expected);
+        $this->assertSame($expected, $this->preferences->$prop);
     }
 
     /**
@@ -466,16 +461,31 @@ class Preferences extends atoum
 
         $post = array_merge($preferences, $post);
 
-        $this->boolean($this->preferences->check($post, $this->login))->isTrue(print_r($this->preferences->getErrors(), true));
-        $this->boolean($this->preferences->store())->isTrue();
+        $this->assertTrue(
+            $this->preferences->check($post, $this->login),
+            print_r($this->preferences->getErrors(), true)
+        );
+        $this->assertTrue($this->preferences->store());
 
         $socials = \Galette\Entity\Social::getListForMember(null);
-        $this->array($socials)->hasSize(2);
+        $this->assertCount(2, $socials);
 
-        $this->array(\Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::MASTODON))->hasSize(1);
-        $this->array(\Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::JABBER))->hasSize(1);
-        $this->array(\Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::FACEBOOK))->hasSize(0);
-        $this->array(\Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::BLOG))->hasSize(0);
+        $this->assertCount(
+            1,
+            \Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::MASTODON)
+        );
+        $this->assertCount(
+            1,
+            \Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::JABBER)
+        );
+        $this->assertCount(
+            0,
+            \Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::FACEBOOK)
+        );
+        $this->assertCount(
+            0,
+            \Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::BLOG)
+        );
 
         //create one new social network
         $post = [
@@ -490,26 +500,29 @@ class Preferences extends atoum
 
         $post = array_merge($preferences, $post);
 
-        $this->boolean($this->preferences->check($post, $this->login))->isTrue(print_r($this->preferences->getErrors(), true));
-        $this->boolean($this->preferences->store())->isTrue();
+        $this->assertTrue(
+            $this->preferences->check($post, $this->login),
+            print_r($this->preferences->getErrors(), true)
+        );
+        $this->assertTrue($this->preferences->store());
 
         $socials = \Galette\Entity\Social::getListForMember(null);
-        $this->array($socials)->hasSize(3);
+        $this->assertCount(3, $socials);
 
         $search = \Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::MASTODON);
-        $this->array($search)->hasSize(1);
+        $this->assertCount(1, $search);
         $masto = array_pop($search);
-        $this->string($masto->url)->isIdenticalTo('Galette mastodon URL');
+        $this->assertSame('Galette mastodon URL', $masto->url);
 
         $search = \Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::JABBER);
-        $this->array($search)->hasSize(1);
+        $this->assertCount(1, $search);
         $jabber = array_pop($search);
-        $this->string($jabber->url)->isIdenticalTo('Galette jabber ID - modified');
+        $this->assertSame('Galette jabber ID - modified', $jabber->url);
 
         $search = \Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::FACEBOOK);
-        $this->array($search)->hasSize(1);
+        $this->assertCount(1, $search);
         $facebook = array_pop($search);
-        $this->string($facebook->url)->isIdenticalTo('Galette does not have facebook');
+        $this->assertSame('Galette does not have facebook', $facebook->url);
 
         $post = [];
 
@@ -521,15 +534,27 @@ class Preferences extends atoum
         }
 
         $post = array_merge($preferences, $post);
-        $this->boolean($this->preferences->check($post, $this->login))->isTrue(print_r($this->preferences->getErrors(), true));
-        $this->boolean($this->preferences->store())->isTrue();
+        $this->assertTrue(
+            $this->preferences->check($post, $this->login),
+            print_r($this->preferences->getErrors(), true)
+        );
+        $this->assertTrue($this->preferences->store());
 
         $socials = \Galette\Entity\Social::getListForMember(null);
-        $this->array($socials)->hasSize(2);
+        $this->assertCount(2, $socials);
 
-        $this->array(\Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::MASTODON))->hasSize(0);
-        $this->array(\Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::JABBER))->hasSize(1);
-        $this->array(\Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::FACEBOOK))->hasSize(1);
+        $this->assertCount(
+            0,
+            \Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::MASTODON)
+        );
+        $this->assertCount(
+            1,
+            \Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::JABBER)
+        );
+        $this->assertCount(
+            1,
+            \Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::FACEBOOK)
+        );
     }
 
     /**
@@ -539,38 +564,44 @@ class Preferences extends atoum
      */
     public function testGetMailSignature()
     {
-        $this->string($this->preferences->getMailSignature())->isIdenticalTo("\r\n-- \r\nGalette\r\n\r\n");
+        $this->assertSame("\r\n-- \r\nGalette\r\n\r\n", $this->preferences->getMailSignature());
 
         $this->preferences->pref_website = 'https://galette.eu';
-        $this->string($this->preferences->getMailSignature())->isIdenticalTo("\r\n-- \r\nGalette\r\n\r\nhttps://galette.eu");
+        $this->assertSame("\r\n-- \r\nGalette\r\n\r\nhttps://galette.eu", $this->preferences->getMailSignature());
 
         //with legacy values
         $this->preferences->pref_mailsign = "NAME}\r\n\r\n{WEBSITE}\r\n{GOOGLEPLUS}\r\n{FACEBOOK}\r\n{TWITTER}\r\n{LINKEDIN}\r\n{VIADEO}";
-        $this->string($this->preferences->getMailSignature())->isIdenticalTo("\r\n-- \r\nGalette\r\n\r\nhttps://galette.eu");
+        $this->assertSame("\r\n-- \r\nGalette\r\n\r\nhttps://galette.eu", $this->preferences->getMailSignature());
 
         $social = new \Galette\Entity\Social($this->zdb);
-        $this->boolean(
+        $this->assertTrue(
             $social
                 ->setType(\Galette\Entity\Social::MASTODON)
                 ->setUrl('https://framapiaf.org/@galette')
                 ->setLinkedMember(null)
                 ->store()
-        )->isTrue();
-        $this->array(\Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::MASTODON))->hasSize(1);
+        );
+        $this->assertCount(
+            1,
+            \Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::MASTODON)
+        );
 
         $this->preferences->pref_mail_sign = "{ASSO_NAME}\r\n\r\n{ASSO_WEBSITE} - {ASSO_SOCIAL_MASTODON}";
-        $this->string($this->preferences->getMailSignature())->isIdenticalTo("\r\n-- \r\nGalette\r\n\r\nhttps://galette.eu - https://framapiaf.org/@galette");
+        $this->assertSame("\r\n-- \r\nGalette\r\n\r\nhttps://galette.eu - https://framapiaf.org/@galette", $this->preferences->getMailSignature());
 
         $social = new \Galette\Entity\Social($this->zdb);
-        $this->boolean(
+        $this->assertTrue(
             $social
                 ->setType(\Galette\Entity\Social::MASTODON)
                 ->setUrl('Galette mastodon URL - the return')
                 ->setLinkedMember(null)
                 ->store()
-        )->isTrue();
-        $this->array(\Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::MASTODON))->hasSize(2);
-        $this->string($this->preferences->getMailSignature())->isIdenticalTo("\r\n-- \r\nGalette\r\n\r\nhttps://galette.eu - https://framapiaf.org/@galette, Galette mastodon URL - the return");
+        );
+        $this->assertCount(
+            2,
+            \Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::MASTODON)
+        );
+        $this->assertSame("\r\n-- \r\nGalette\r\n\r\nhttps://galette.eu - https://framapiaf.org/@galette, Galette mastodon URL - the return", $this->preferences->getMailSignature());
     }
 
     /**
@@ -581,29 +612,36 @@ class Preferences extends atoum
     public function testGetLegend()
     {
         $legend = $this->preferences->getLegend();
-        $this->array($legend)->hasSize(2);
-        $this->array($legend['main']['patterns'])->hasSize(8);
-        $this->array($legend['socials']['patterns'])->hasSize(9);
-        $this->array($legend['socials']['patterns']['asso_social_mastodon'])->isIdenticalTo([
+        $this->assertCount(2, $legend);
+        $this->assertCount(8, $legend['main']['patterns']);
+        $this->assertCount(9, $legend['socials']['patterns']);
+        $this->assertSame(
+            [
             'title' => __('Mastodon'),
             'pattern' => '/{ASSO_SOCIAL_MASTODON}/'
-        ]);
+            ],
+            $legend['socials']['patterns']['asso_social_mastodon']
+        );
 
         $social = new \Galette\Entity\Social($this->zdb);
-        $this->boolean(
+        $this->assertTrue(
             $social
                 ->setType('mynewtype')
                 ->setUrl('Galette specific social network URL')
                 ->setLinkedMember(null)
                 ->store()
-        )->isTrue();
+        );
 
         $legend = $this->preferences->getLegend();
-        $this->array($legend)->hasSize(2);
-        $this->array($legend['socials']['patterns'])->hasSIze(10)->hasKey('asso_social_mynewtype');
-        $this->array($legend['socials']['patterns']['asso_social_mynewtype'])->isIdenticalTo([
-            'title' => 'mynewtype',
-            'pattern' => '/{ASSO_SOCIAL_MYNEWTYPE}/'
-        ]);
+        $this->assertCount(2, $legend);
+        $this->assertCount(10, $legend['socials']['patterns']);
+        $this->assertTrue(isset($legend['socials']['patterns']['asso_social_mynewtype']));
+        $this->assertSame(
+            [
+                'title' => 'mynewtype',
+                'pattern' => '/{ASSO_SOCIAL_MYNEWTYPE}/'
+            ],
+            $legend['socials']['patterns']['asso_social_mynewtype']
+        );
     }
 }
index 4a3c7e27ff4d44483cd5d119c73a509a49ddc547..b9a377b5d3cade5357a4cb2361abf04b5ca5fd99 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\Core\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Picture tests class
@@ -51,18 +51,16 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2017-07-08
  */
-class PrintLogo extends atoum
+class PrintLogo extends TestCase
 {
     private \Galette\Core\Db $zdb;
 
     /**
      * Set up tests
      *
-     * @param string $method Method name
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         global $zdb;
         $this->zdb = new \Galette\Core\Db();
@@ -72,14 +70,12 @@ class PrintLogo extends atoum
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
         if (TYPE_DB === 'mysql') {
-            $this->array($this->zdb->getWarnings())->isIdenticalTo([]);
+            $this->assertSame([], $this->zdb->getWarnings());
         }
     }
 
@@ -93,14 +89,14 @@ class PrintLogo extends atoum
         global $zdb;
         $zdb = $this->zdb;
         $logo = new \Galette\Core\PrintLogo();
-        $this->variable($logo->getDestDir())->isNull();
-        $this->variable($logo->getFileName())->isNull();
+        $this->assertNull($logo->getDestDir());
+        $this->assertNull($logo->getFileName());
 
         $expected_path = realpath(GALETTE_ROOT . 'webroot/themes/default/images/galette.png');
-        $this->string($logo->getPath())->isIdenticalTo($expected_path);
+        $this->assertSame($expected_path, $logo->getPath());
 
-        $this->string($logo->getMime())->isIdenticalTo('image/png');
-        $this->string($logo->getFormat())->isIdenticalTo('png');
-        $this->boolean($logo->isCustom())->isFalse();
+        $this->assertSame('image/png', $logo->getMime());
+        $this->assertSame('png', $logo->getFormat());
+        $this->assertFalse($logo->isCustom());
     }
 }
index e74e0f709fc80715c44d5d44b23b1e0bf8623b22..12dabf694a1a72692034a7e6a35b135101a29e68 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\DynamicFields\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Dynamic booleans test
@@ -51,7 +51,7 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2013-10-18
  */
-class Boolean extends atoum
+class Boolean extends TestCase
 {
     private \Galette\Core\Db $zdb;
     private \Galette\DynamicFields\Boolean $bool;
@@ -59,11 +59,9 @@ class Boolean extends atoum
     /**
      * Set up tests
      *
-     * @param string $method Current test method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $this->zdb = new \Galette\Core\Db();
         $this->bool = new \Galette\DynamicFields\Boolean($this->zdb);
@@ -77,8 +75,7 @@ class Boolean extends atoum
     public function testConstructor()
     {
         $o = new \Galette\DynamicFields\Boolean($this->zdb, 10);
-        $this->variable($o->getId())
-            ->isNull();
+        $this->assertNull($o->getId());
     }
 
     /**
@@ -88,8 +85,7 @@ class Boolean extends atoum
      */
     public function testGetTypeName()
     {
-        $this->variable($this->bool->getTypeName())
-            ->isIdenticalTo(_T('boolean'));
+        $this->assertSame(_T('boolean'), $this->bool->getTypeName());
     }
 
     /**
@@ -100,50 +96,50 @@ class Boolean extends atoum
     public function testBaseProperties()
     {
         $muliple = $this->bool->isMultiValued();
-        $this->boolean($muliple)->isFalse();
+        $this->assertFalse($muliple);
 
         $required = $this->bool->isRequired();
-        $this->boolean($required)->isFalse();
+        $this->assertFalse($required);
 
         $name = $this->bool->getName();
-        $this->variable($name)->isIdenticalTo('');
+        $this->assertSame('', $name);
 
         $has_fixed_values = $this->bool->hasFixedValues();
-        $this->boolean($has_fixed_values)->isFalse();
+        $this->assertFalse($has_fixed_values);
 
         $has_data = $this->bool->hasData();
-        $this->boolean($has_data)->isTrue();
+        $this->assertTrue($has_data);
 
         $has_w = $this->bool->hasWidth();
-        $this->boolean($has_w)->isFalse();
+        $this->assertFalse($has_w);
 
         $has_h = $this->bool->hasHeight();
-        $this->boolean($has_h)->isFalse();
+        $this->assertFalse($has_h);
 
         $has_s = $this->bool->hasSize();
-        $this->boolean($has_s)->isFalse();
+        $this->assertFalse($has_s);
 
         $perms = $this->bool->getPerm();
-        $this->variable($perms)->isNull();
+        $this->assertNull($perms);
 
         $width = $this->bool->getWidth();
-        $this->variable($width)->isNull();
+        $this->assertNull($width);
 
         $height = $this->bool->getHeight();
-        $this->variable($height)->isNull();
+        $this->assertNull($height);
 
         $repeat = $this->bool->getRepeat();
-        $this->variable($repeat)->isNull();
+        $this->assertNull($repeat);
 
         $repeat = $this->bool->isRepeatable();
-        $this->boolean($repeat)->isFalse();
+        $this->assertFalse($repeat);
 
         $size = $this->bool->getSize();
-        $this->variable($size)->isNull();
+        $this->assertNull($size);
 
         $values = $this->bool->getValues();
-        $this->boolean($values)->isFalse();
+        $this->assertFalse($values);
 
-        $this->boolean($this->bool->hasPermissions())->isTrue();
+        $this->assertTrue($this->bool->hasPermissions());
     }
 }
index 45a8b226738de76cb5eb3dca4da146f79d2e0b44..157e9d8d99a94170cbffc16ad18b1cef2d41accd 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\DynamicFields\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Dynamic choice test
@@ -51,7 +51,7 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2021-11-11
  */
-class Choice extends atoum
+class Choice extends TestCase
 {
     private \Galette\Core\Db $zdb;
     private \Galette\DynamicFields\Choice $choice;
@@ -59,11 +59,9 @@ class Choice extends atoum
     /**
      * Set up tests
      *
-     * @param string $method Current test method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $this->zdb = new \Galette\Core\Db();
         $this->choice = new \Galette\DynamicFields\Choice($this->zdb);
@@ -77,8 +75,7 @@ class Choice extends atoum
     public function testConstructor()
     {
         $o = new \Galette\DynamicFields\Choice($this->zdb, 10);
-        $this->variable($o->getId())
-            ->isNull();
+        $this->assertNull($o->getId());
     }
 
     /**
@@ -88,8 +85,7 @@ class Choice extends atoum
      */
     public function testGetTypeName()
     {
-        $this->variable($this->choice->getTypeName())
-            ->isIdenticalTo(_T('choice'));
+        $this->assertSame(_T('choice'), $this->choice->getTypeName());
     }
 
     /**
@@ -100,50 +96,50 @@ class Choice extends atoum
     public function testBaseProperties()
     {
         $muliple = $this->choice->isMultiValued();
-        $this->boolean($muliple)->isFalse();
+        $this->assertFalse($muliple);
 
         $required = $this->choice->isRequired();
-        $this->boolean($required)->isFalse();
+        $this->assertFalse($required);
 
         $name = $this->choice->getName();
-        $this->variable($name)->isIdenticalTo('');
+        $this->assertSame('', $name);
 
         $has_fixed_values = $this->choice->hasFixedValues();
-        $this->boolean($has_fixed_values)->isTrue();
+        $this->assertTrue($has_fixed_values);
 
         $has_data = $this->choice->hasData();
-        $this->boolean($has_data)->isTrue();
+        $this->assertTrue($has_data);
 
         $has_w = $this->choice->hasWidth();
-        $this->boolean($has_w)->isFalse();
+        $this->assertFalse($has_w);
 
         $has_h = $this->choice->hasHeight();
-        $this->boolean($has_h)->isFalse();
+        $this->assertFalse($has_h);
 
         $has_s = $this->choice->hasSize();
-        $this->boolean($has_s)->isFalse();
+        $this->assertFalse($has_s);
 
         $perms = $this->choice->getPerm();
-        $this->variable($perms)->isNull();
+        $this->assertNull($perms);
 
         $width = $this->choice->getWidth();
-        $this->variable($width)->isNull();
+        $this->assertNull($width);
 
         $height = $this->choice->getHeight();
-        $this->variable($height)->isNull();
+        $this->assertNull($height);
 
         $repeat = $this->choice->getRepeat();
-        $this->variable($repeat)->isNull();
+        $this->assertNull($repeat);
 
         $repeat = $this->choice->isRepeatable();
-        $this->boolean($repeat)->isFalse();
+        $this->assertFalse($repeat);
 
         $size = $this->choice->getSize();
-        $this->variable($size)->isNull();
+        $this->assertNull($size);
 
         $values = $this->choice->getValues();
-        $this->boolean($values)->isFalse();
+        $this->assertFalse($values);
 
-        $this->boolean($this->choice->hasPermissions())->isTrue();
+        $this->assertTrue($this->choice->hasPermissions());
     }
 }
index 7b39074340c94aa980d382c9b69a908f29de2cfb..3a0543c70e35a41d97720162a189c593fb3c093d 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\DynamicFields\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Dynamic date test
@@ -51,7 +51,7 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2021-11-11
  */
-class Date extends atoum
+class Date extends TestCase
 {
     private \Galette\Core\Db $zdb;
     private \Galette\DynamicFields\Date $date;
@@ -59,11 +59,9 @@ class Date extends atoum
     /**
      * Set up tests
      *
-     * @param string $method Current test method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $this->zdb = new \Galette\Core\Db();
         $this->date = new \Galette\DynamicFields\Date($this->zdb);
@@ -77,8 +75,7 @@ class Date extends atoum
     public function testConstructor()
     {
         $o = new \Galette\DynamicFields\Date($this->zdb, 10);
-        $this->variable($o->getId())
-            ->isNull();
+        $this->assertNull($o->getId());
     }
 
     /**
@@ -88,8 +85,7 @@ class Date extends atoum
      */
     public function testGetTypeName()
     {
-        $this->variable($this->date->getTypeName())
-            ->isIdenticalTo(_T('date'));
+        $this->assertSame(_T('date'), $this->date->getTypeName());
     }
 
     /**
@@ -100,50 +96,50 @@ class Date extends atoum
     public function testBaseProperties()
     {
         $muliple = $this->date->isMultiValued();
-        $this->boolean($muliple)->isFalse();
+        $this->assertFalse($muliple);
 
         $required = $this->date->isRequired();
-        $this->boolean($required)->isFalse();
+        $this->assertFalse($required);
 
         $name = $this->date->getName();
-        $this->variable($name)->isIdenticalTo('');
+        $this->assertSame('', $name);
 
         $has_fixed_values = $this->date->hasFixedValues();
-        $this->boolean($has_fixed_values)->isFalse();
+        $this->assertFalse($has_fixed_values);
 
         $has_data = $this->date->hasData();
-        $this->boolean($has_data)->isTrue();
+        $this->assertTrue($has_data);
 
         $has_w = $this->date->hasWidth();
-        $this->boolean($has_w)->isFalse();
+        $this->assertFalse($has_w);
 
         $has_h = $this->date->hasHeight();
-        $this->boolean($has_h)->isFalse();
+        $this->assertFalse($has_h);
 
         $has_s = $this->date->hasSize();
-        $this->boolean($has_s)->isFalse();
+        $this->assertFalse($has_s);
 
         $perms = $this->date->getPerm();
-        $this->variable($perms)->isNull();
+        $this->assertNull($perms);
 
         $width = $this->date->getWidth();
-        $this->variable($width)->isNull();
+        $this->assertNull($width);
 
         $height = $this->date->getHeight();
-        $this->variable($height)->isNull();
+        $this->assertNull($height);
 
         $repeat = $this->date->getRepeat();
-        $this->variable($repeat)->isNull();
+        $this->assertNull($repeat);
 
         $repeat = $this->date->isRepeatable();
-        $this->boolean($repeat)->isFalse();
+        $this->assertFalse($repeat);
 
         $size = $this->date->getSize();
-        $this->variable($size)->isNull();
+        $this->assertNull($size);
 
         $values = $this->date->getValues();
-        $this->boolean($values)->isFalse();
+        $this->assertFalse($values);
 
-        $this->boolean($this->date->hasPermissions())->isTrue();
+        $this->assertTrue($this->date->hasPermissions());
     }
 }
index fe057123b89ac37294c2dd03eb0f3426ed1d9769..915fe007263007cbeb3ba8c0161d68f505ad6882 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\DynamicFields\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Dynamic fields test
@@ -51,18 +51,16 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2021-11-11
  */
-class DynamicField extends atoum
+class DynamicField extends TestCase
 {
     private \Galette\Core\Db $zdb;
 
     /**
      * Set up tests
      *
-     * @param string $method Current test method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $this->zdb = new \Galette\Core\Db();
     }
@@ -70,11 +68,9 @@ class DynamicField extends atoum
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
         $delete = $this->zdb->delete(\Galette\DynamicFields\DynamicField::TABLE);
         $this->zdb->execute($delete);
@@ -100,7 +96,7 @@ class DynamicField extends atoum
      */
     public function testLoadFieldType()
     {
-        $this->boolean(\Galette\DynamicFields\DynamicField::loadFieldType($this->zdb, 10))->isFalse();
+        $this->assertFalse(\Galette\DynamicFields\DynamicField::loadFieldType($this->zdb, 10));
 
         $field_data = [
             'form_name'         => 'adh',
@@ -113,40 +109,49 @@ class DynamicField extends atoum
 
         $df = \Galette\DynamicFields\DynamicField::getFieldType($this->zdb, $field_data['field_type']);
         $stored = $df->store($field_data);
-        $this->boolean($stored)->isTrue(
+        $this->assertTrue(
+            $stored,
             implode(
                 ' ',
                 $df->getErrors() + $df->getWarnings()
             )
         );
-        $this->boolean($stored)->isTrue();
-        $this->object(\Galette\DynamicFields\DynamicField::loadFieldType($this->zdb, $df->getId()))->isEqualTo($df);
-        $this->string($df->getForm())->isIdenticalTo('adh');
-        $this->integer($df->getIndex())->isIdenticalTo(1);
+        $this->assertTrue($stored);
+        $this->assertEquals(
+            $df,
+            \Galette\DynamicFields\DynamicField::loadFieldType($this->zdb, $df->getId())
+        );
+        $this->assertSame('adh', $df->getForm());
+        $this->assertSame(1, $df->getIndex());
 
         $df = \Galette\DynamicFields\DynamicField::getFieldType($this->zdb, $field_data['field_type']);
         $field_data['field_name'] = 'Another one';
         $stored = $df->store($field_data);
-        $this->boolean($stored)->isTrue(
+        $this->assertTrue(
+            $stored,
             implode(
                 ' ',
                 $df->getErrors() + $df->getWarnings()
             )
         );
-        $this->boolean($stored)->isTrue();
-        $this->object(\Galette\DynamicFields\DynamicField::loadFieldType($this->zdb, $df->getId()))->isEqualTo($df);
-        $this->integer($df->getIndex())->isIdenticalTo(2);
+        $this->assertTrue($stored);
+        $this->assertEquals(
+            $df,
+            \Galette\DynamicFields\DynamicField::loadFieldType($this->zdb, $df->getId())
+        );
+        $this->assertSame(2, $df->getIndex());
 
         $field_data['field_name'] = 'Another one - modified';
         $stored = $df->store($field_data);
-        $this->boolean($stored)->isTrue(
+        $this->assertTrue(
+            $stored,
             implode(
                 ' ',
                 $df->getErrors() + $df->getWarnings()
             )
         );
-        $this->boolean($stored)->isTrue();
-        $this->string($df->getName())->isIdenticalTo($field_data['field_name']);
+        $this->assertTrue($stored);
+        $this->assertSame($field_data['field_name'], $df->getName());
     }
 
     /**
@@ -154,7 +159,7 @@ class DynamicField extends atoum
      *
      * @return array
      */
-    protected function permsProvider(): array
+    public static function permsProvider(): array
     {
         return [
             [
@@ -188,11 +193,11 @@ class DynamicField extends atoum
     public function testGetPermsNames()
     {
         $expected = [];
-        foreach ($this->permsProvider() as $perm) {
+        foreach (self::permsProvider() as $perm) {
             $expected[$perm['perm']] = $perm['name'];
         }
 
-        $this->array(\Galette\DynamicFields\DynamicField::getPermsNames())->isIdenticalTo($expected);
+        $this->assertSame($expected, \Galette\DynamicFields\DynamicField::getPermsNames());
     }
 
     /**
@@ -218,14 +223,15 @@ class DynamicField extends atoum
 
         $df = \Galette\DynamicFields\DynamicField::getFieldType($this->zdb, $field_data['field_type']);
         $stored = $df->store($field_data);
-        $this->boolean($stored)->isTrue(
+        $this->assertTrue(
+            $stored,
             implode(
                 ' ',
                 $df->getErrors() + $df->getWarnings()
             )
         );
-        $this->boolean($stored)->isTrue();
-        $this->string($df->getPermName())->isIdenticalTo($name);
+        $this->assertTrue($stored);
+        $this->assertSame($name, $df->getPermName());
     }
 
     /**
@@ -239,7 +245,7 @@ class DynamicField extends atoum
         foreach ($this->formNamesProvider() as $form) {
             $expected[$form['form']] = $form['expected'];
         }
-        $this->array(\Galette\DynamicFields\DynamicField::getFormsNames())->isIdenticalTo($expected);
+        $this->assertSame($expected, \Galette\DynamicFields\DynamicField::getFormsNames());
     }
 
     /**
@@ -247,7 +253,7 @@ class DynamicField extends atoum
      *
      * @return \string[][]
      */
-    protected function formNamesProvider(): array
+    public static function formNamesProvider(): array
     {
         return [
             [
@@ -277,7 +283,7 @@ class DynamicField extends atoum
      */
     public function testGetFormTitle(string $form, string $expected)
     {
-        $this->string(\Galette\DynamicFields\DynamicField::getFormTitle($form))->isIdenticalTo($expected);
+        $this->assertSame($expected, \Galette\DynamicFields\DynamicField::getFormTitle($form));
     }
 
     /**
@@ -287,9 +293,9 @@ class DynamicField extends atoum
      */
     public function testGetFixedValuesTableName()
     {
-        $this->string(\Galette\DynamicFields\DynamicField::getFixedValuesTableName(10))->isIdenticalTo('field_contents_10');
-        $this->string(\Galette\DynamicFields\DynamicField::getFixedValuesTableName(10, false))->isIdenticalTo('field_contents_10');
-        $this->string(\Galette\DynamicFields\DynamicField::getFixedValuesTableName(10, true))->isIdenticalTo('galette_field_contents_10');
+        $this->assertSame('field_contents_10', \Galette\DynamicFields\DynamicField::getFixedValuesTableName(10));
+        $this->assertSame('field_contents_10', \Galette\DynamicFields\DynamicField::getFixedValuesTableName(10, false));
+        $this->assertSame('galette_field_contents_10', \Galette\DynamicFields\DynamicField::getFixedValuesTableName(10, true));
     }
 
     /**
@@ -315,18 +321,19 @@ class DynamicField extends atoum
 
         $df = \Galette\DynamicFields\DynamicField::getFieldType($this->zdb, $field_data['field_type']);
         $stored = $df->store($field_data);
-        $this->boolean($stored)->isTrue(
+        $this->assertTrue(
+            $stored,
             implode(
                 ' ',
                 $df->getErrors() + $df->getWarnings()
             )
         );
-        $this->boolean($stored)->isTrue();
+        $this->assertTrue($stored);
 
         $stored = $df->load($df->getId());
-        $this->array($df->getValues())->isIdenticalTo(['One', 'Two', 'Three']);
-        $this->string($df->getValues(true))->isIdenticalTo("One\nTwo\nThree");
-        $this->integer($df->getIndex())->isIdenticalTo(1);
+        $this->assertSame(['One', 'Two', 'Three'], $df->getValues());
+        $this->assertSame("One\nTwo\nThree", $df->getValues(true));
+        $this->assertSame(1, $df->getIndex());
     }
 
     /**
@@ -352,44 +359,44 @@ class DynamicField extends atoum
         $orig_values = $values;
         $df = \Galette\DynamicFields\DynamicField::getFieldType($this->zdb, $values['field_type']);
 
-        $this->boolean($df->check($values))->isTrue();
-        $this->array($df->getErrors())->isIdenticalTo([]);
+        $this->assertTrue($df->check($values));
+        $this->assertSame([], $df->getErrors());
 
         $values['form_name'] = 'unk';
-        $this->boolean($df->check($values))->isFalse();
-        $this->array($df->getErrors())->isIdenticalTo(['Unknown form!']);
+        $this->assertFalse($df->check($values));
+        $this->assertSame(['Unknown form!'], $df->getErrors());
 
         $values['field_perm'] = 42;
-        $this->boolean($df->check($values))->isFalse();
-        $this->array($df->getErrors())->isIdenticalTo(['Unknown permission!', 'Unknown form!']);
+        $this->assertFalse($df->check($values));
+        $this->assertSame(['Unknown permission!', 'Unknown form!'], $df->getErrors());
 
         $values = $orig_values;
         $values['field_perm'] = '';
-        $this->boolean($df->check($values))->isFalse();
-        $this->array($df->getErrors())->isIdenticalTo(['Missing required field permissions!']);
+        $this->assertFalse($df->check($values));
+        $this->assertSame(['Missing required field permissions!'], $df->getErrors());
 
         unset($values['field_perm']);
-        $this->boolean($df->check($values))->isFalse();
-        $this->array($df->getErrors())->isIdenticalTo(['Missing required field permissions!']);
+        $this->assertFalse($df->check($values));
+        $this->assertSame(['Missing required field permissions!'], $df->getErrors());
 
         $values = $orig_values;
         $values['form_name'] = '';
-        $this->boolean($df->check($values))->isFalse();
-        $this->array($df->getErrors())->isIdenticalTo(['Missing required form!']);
+        $this->assertFalse($df->check($values));
+        $this->assertSame(['Missing required form!'], $df->getErrors());
         $values = $orig_values;
         unset($values['form_name']);
-        $this->boolean($df->check($values))->isFalse();
-        $this->array($df->getErrors())->isIdenticalTo(['Missing required form!']);
+        $this->assertFalse($df->check($values));
+        $this->assertSame(['Missing required form!'], $df->getErrors());
 
         $values = $orig_values;
         $values['field_name'] = '';
-        $this->boolean($df->check($values))->isFalse();
-        $this->array($df->getErrors())->isIdenticalTo(['Missing required field name!']);
+        $this->assertFalse($df->check($values));
+        $this->assertSame(['Missing required field name!'], $df->getErrors());
         $values = $orig_values;
         unset($values['field_name']);
-        $this->boolean($df->check($values))->isFalse();
-        $this->array($df->getErrors())->isIdenticalTo(['Missing required field name!']);
-        $this->boolean($df->store($values))->isFalse();
+        $this->assertFalse($df->check($values));
+        $this->assertSame(['Missing required field name!'], $df->getErrors());
+        $this->assertFalse($df->store($values));
     }
 
     /**
@@ -410,65 +417,77 @@ class DynamicField extends atoum
 
         $df = \Galette\DynamicFields\DynamicField::getFieldType($this->zdb, $field_data['field_type']);
         $stored = $df->store($field_data);
-        $this->boolean($stored)->isTrue(
+        $this->assertTrue(
+            $stored,
             implode(
                 ' ',
                 $df->getErrors() + $df->getWarnings()
             )
         );
-        $this->boolean($stored)->isTrue();
-        $this->object(\Galette\DynamicFields\DynamicField::loadFieldType($this->zdb, $df->getId()))->isEqualTo($df);
-        $this->integer($df->getIndex())->isIdenticalTo(1);
+        $this->assertTrue($stored);
+        $this->assertEquals(
+            $df,
+            \Galette\DynamicFields\DynamicField::loadFieldType($this->zdb, $df->getId())
+        );
+        $this->assertSame(1, $df->getIndex());
         $df_id_1 = $df->getId();
 
         $df = \Galette\DynamicFields\DynamicField::getFieldType($this->zdb, $field_data['field_type']);
         $field_data['field_name'] = 'A second text field';
         $stored = $df->store($field_data);
-        $this->boolean($stored)->isTrue(
+        $this->assertTrue(
+            $stored,
             implode(
                 ' ',
                 $df->getErrors() + $df->getWarnings()
             )
         );
-        $this->boolean($stored)->isTrue();
-        $this->object(\Galette\DynamicFields\DynamicField::loadFieldType($this->zdb, $df->getId()))->isEqualTo($df);
-        $this->integer($df->getIndex())->isIdenticalTo(2);
+        $this->assertTrue($stored);
+        $this->assertEquals(
+            $df,
+            \Galette\DynamicFields\DynamicField::loadFieldType($this->zdb, $df->getId())
+        );
+        $this->assertSame(2, $df->getIndex());
         $df_id_2 = $df->getId();
 
         $df = \Galette\DynamicFields\DynamicField::getFieldType($this->zdb, $field_data['field_type']);
         $field_data['field_name'] = 'A third text field';
         $stored = $df->store($field_data);
-        $this->boolean($stored)->isTrue(
+        $this->assertTrue(
+            $stored,
             implode(
                 ' ',
                 $df->getErrors() + $df->getWarnings()
             )
         );
-        $this->boolean($stored)->isTrue();
-        $this->object(\Galette\DynamicFields\DynamicField::loadFieldType($this->zdb, $df->getId()))->isEqualTo($df);
-        $this->integer($df->getIndex())->isIdenticalTo(3);
+        $this->assertTrue($stored);
+        $this->assertEquals(
+            $df,
+            \Galette\DynamicFields\DynamicField::loadFieldType($this->zdb, $df->getId())
+        );
+        $this->assertSame(3, $df->getIndex());
         $df_id_3 = $df->getId();
 
-        $this->boolean($df->move(\Galette\DynamicFields\DynamicField::MOVE_UP))->isTrue();
+        $this->assertTrue($df->move(\Galette\DynamicFields\DynamicField::MOVE_UP));
         $df->load($df_id_1);
-        $this->integer($df->getIndex())->isIdenticalTo(1);
+        $this->assertSame(1, $df->getIndex());
 
         $df->load($df_id_2);
-        $this->integer($df->getIndex())->isIdenticalTo(3);
+        $this->assertSame(3, $df->getIndex());
 
         $df->load($df_id_3);
-        $this->integer($df->getIndex())->isIdenticalTo(2);
+        $this->assertSame(2, $df->getIndex());
 
         $df->load($df_id_1);
-        $this->boolean($df->move(\Galette\DynamicFields\DynamicField::MOVE_DOWN))->isTrue();
+        $this->assertTrue($df->move(\Galette\DynamicFields\DynamicField::MOVE_DOWN));
         $df->load($df_id_1);
-        $this->integer($df->getIndex())->isIdenticalTo(2);
+        $this->assertSame(2, $df->getIndex());
 
         $df->load($df_id_2);
-        $this->integer($df->getIndex())->isIdenticalTo(3);
+        $this->assertSame(3, $df->getIndex());
 
         $df->load($df_id_3);
-        $this->integer($df->getIndex())->isIdenticalTo(1);
+        $this->assertSame(1, $df->getIndex());
     }
 
     /**
@@ -493,28 +512,27 @@ class DynamicField extends atoum
         ];
         $df = \Galette\DynamicFields\DynamicField::getFieldType($this->zdb, $field_data['field_type']);
         $stored = $df->store($field_data);
-        $this->boolean($stored)->isTrue(
+        $this->assertTrue(
+            $stored,
             implode(
                 ' ',
                 $df->getErrors() + $df->getWarnings()
             )
         );
-        $this->boolean($stored)->isTrue();
+        $this->assertTrue($stored);
         $df_id = $df->getId();
 
         //check if table has been created
         $select = $this->zdb->select($df::getFixedValuesTableName($df->getId()));
         $results = $this->zdb->execute($select);
-        $this->integer($results->count())->isIdenticalTo(3);
+        $this->assertSame(3, $results->count());
 
-        $this->boolean($df->remove())->isTrue();
+        $this->assertTrue($df->remove());
 
-        $this->exception(
-            function () use ($select) {
-                $results = $this->zdb->execute($select);
-            }
-        )->isInstanceOf('\PDOException');
-        $this->boolean(\Galette\DynamicFields\DynamicField::loadFieldType($this->zdb, $df_id))->isFalse();
+        $this->expectException('\PDOException');
+        $results = $this->zdb->execute($select);
+
+        $this->assertFalse(\Galette\DynamicFields\DynamicField::loadFieldType($this->zdb, $df_id));
     }
 
     /**
@@ -534,15 +552,19 @@ class DynamicField extends atoum
 
         $df = \Galette\DynamicFields\DynamicField::getFieldType($this->zdb, $field_data['field_type']);
         $stored = $df->store($field_data);
-        $this->boolean($stored)->isTrue(
+        $this->assertTrue(
+            $stored,
             implode(
                 ' ',
                 $df->getErrors() + $df->getWarnings()
             )
         );
-        $this->boolean($stored)->isTrue();
-        $this->object(\Galette\DynamicFields\DynamicField::loadFieldType($this->zdb, $df->getId()))->isEqualTo($df);
+        $this->assertTrue($stored);
+        $this->assertEquals(
+            $df,
+            \Galette\DynamicFields\DynamicField::loadFieldType($this->zdb, $df->getId())
+        );
 
-        $this->string($df->getInformation())->isIdenticalTo('<p>This is an important information.</p><p>And here an xss...  <img src="img.png" alt="img.png" /></p>');
+        $this->assertSame('<p>This is an important information.</p><p>And here an xss...  <img src="img.png" alt="img.png" /></p>', $df->getInformation());
     }
 }
index bfab96cb518e57d86cf4ac1be0511f368a382d1e..7632f86abbe75a0c3d18585e522983201f4da65c 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\DynamicFields\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Dynamic file test
@@ -51,7 +51,7 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2021-11-11
  */
-class File extends atoum
+class File extends TestCase
 {
     private \Galette\Core\Db $zdb;
     private \Galette\DynamicFields\File $file;
@@ -59,11 +59,9 @@ class File extends atoum
     /**
      * Set up tests
      *
-     * @param string $method Current test method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $this->zdb = new \Galette\Core\Db();
         $this->file = new \Galette\DynamicFields\File($this->zdb);
@@ -77,8 +75,7 @@ class File extends atoum
     public function testConstructor()
     {
         $o = new \Galette\DynamicFields\File($this->zdb, 10);
-        $this->variable($o->getId())
-            ->isNull();
+        $this->assertNull($o->getId());
     }
 
     /**
@@ -88,8 +85,7 @@ class File extends atoum
      */
     public function testGetTypeName()
     {
-        $this->variable($this->file->getTypeName())
-            ->isIdenticalTo(_T('file'));
+        $this->assertSame(_T('file'), $this->file->getTypeName());
     }
 
     /**
@@ -100,50 +96,50 @@ class File extends atoum
     public function testBaseProperties()
     {
         $muliple = $this->file->isMultiValued();
-        $this->boolean($muliple)->isFalse();
+        $this->assertFalse($muliple);
 
         $required = $this->file->isRequired();
-        $this->boolean($required)->isFalse();
+        $this->assertFalse($required);
 
         $name = $this->file->getName();
-        $this->variable($name)->isIdenticalTo('');
+        $this->assertSame('', $name);
 
         $has_fixed_values = $this->file->hasFixedValues();
-        $this->boolean($has_fixed_values)->isFalse();
+        $this->assertFalse($has_fixed_values);
 
         $has_data = $this->file->hasData();
-        $this->boolean($has_data)->isTrue();
+        $this->assertTrue($has_data);
 
         $has_w = $this->file->hasWidth();
-        $this->boolean($has_w)->isFalse();
+        $this->assertFalse($has_w);
 
         $has_h = $this->file->hasHeight();
-        $this->boolean($has_h)->isFalse();
+        $this->assertFalse($has_h);
 
         $has_s = $this->file->hasSize();
-        $this->boolean($has_s)->isTrue();
+        $this->assertTrue($has_s);
 
         $perms = $this->file->getPerm();
-        $this->variable($perms)->isNull();
+        $this->assertNull($perms);
 
         $width = $this->file->getWidth();
-        $this->variable($width)->isNull();
+        $this->assertNull($width);
 
         $height = $this->file->getHeight();
-        $this->variable($height)->isNull();
+        $this->assertNull($height);
 
         $repeat = $this->file->getRepeat();
-        $this->variable($repeat)->isNull();
+        $this->assertNull($repeat);
 
         $repeat = $this->file->isRepeatable();
-        $this->boolean($repeat)->isFalse();
+        $this->assertFalse($repeat);
 
         $size = $this->file->getSize();
-        $this->variable($size)->isNull();
+        $this->assertNull($size);
 
         $values = $this->file->getValues();
-        $this->boolean($values)->isFalse();
+        $this->assertFalse($values);
 
-        $this->boolean($this->file->hasPermissions())->isTrue();
+        $this->assertTrue($this->file->hasPermissions());
     }
 }
index c2e4748078db6685eb2735cc1ff7277eac5a4271..22336d7feb9efb54d4fda3a81d811792181e6052 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\DynamicFields\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Dynamic single line test
@@ -51,7 +51,7 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2021-11-11
  */
-class Line extends atoum
+class Line extends TestCase
 {
     private \Galette\Core\Db $zdb;
     private \Galette\DynamicFields\Line $line;
@@ -59,11 +59,9 @@ class Line extends atoum
     /**
      * Set up tests
      *
-     * @param string $method Current test method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $this->zdb = new \Galette\Core\Db();
         $this->line = new \Galette\DynamicFields\Line($this->zdb);
@@ -77,8 +75,7 @@ class Line extends atoum
     public function testConstructor()
     {
         $o = new \Galette\DynamicFields\Line($this->zdb, 10);
-        $this->variable($o->getId())
-            ->isNull();
+        $this->assertNull($o->getId());
     }
 
     /**
@@ -88,8 +85,7 @@ class Line extends atoum
      */
     public function testGetTypeName()
     {
-        $this->variable($this->line->getTypeName())
-            ->isIdenticalTo(_T('single line'));
+        $this->assertSame(_T('single line'), $this->line->getTypeName());
     }
 
     /**
@@ -100,50 +96,50 @@ class Line extends atoum
     public function testBaseProperties()
     {
         $muliple = $this->line->isMultiValued();
-        $this->boolean($muliple)->isTrue();
+        $this->assertTrue($muliple);
 
         $required = $this->line->isRequired();
-        $this->boolean($required)->isFalse();
+        $this->assertFalse($required);
 
         $name = $this->line->getName();
-        $this->variable($name)->isIdenticalTo('');
+        $this->assertSame('', $name);
 
         $has_fixed_values = $this->line->hasFixedValues();
-        $this->boolean($has_fixed_values)->isFalse();
+        $this->assertFalse($has_fixed_values);
 
         $has_data = $this->line->hasData();
-        $this->boolean($has_data)->isTrue();
+        $this->assertTrue($has_data);
 
         $has_w = $this->line->hasWidth();
-        $this->boolean($has_w)->isTrue();
+        $this->assertTrue($has_w);
 
         $has_h = $this->line->hasHeight();
-        $this->boolean($has_h)->isFalse();
+        $this->assertFalse($has_h);
 
         $has_s = $this->line->hasSize();
-        $this->boolean($has_s)->isTrue();
+        $this->assertTrue($has_s);
 
         $perms = $this->line->getPerm();
-        $this->variable($perms)->isNull();
+        $this->assertNull($perms);
 
         $width = $this->line->getWidth();
-        $this->variable($width)->isNull();
+        $this->assertNull($width);
 
         $height = $this->line->getHeight();
-        $this->variable($height)->isNull();
+        $this->assertNull($height);
 
         $repeat = $this->line->getRepeat();
-        $this->variable($repeat)->isNull();
+        $this->assertNull($repeat);
 
         $repeat = $this->line->isRepeatable();
-        $this->boolean($repeat)->isFalse();
+        $this->assertFalse($repeat);
 
         $size = $this->line->getSize();
-        $this->variable($size)->isNull();
+        $this->assertNull($size);
 
         $values = $this->line->getValues();
-        $this->boolean($values)->isFalse();
+        $this->assertFalse($values);
 
-        $this->boolean($this->line->hasPermissions())->isTrue();
+        $this->assertTrue($this->line->hasPermissions());
     }
 }
index 3d2856808c700b78db729c1b75871dae7a942447..9e638af9f81d5f8f7513cc94cb48bd13d7c9628c 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\DynamicFields\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Dynamic separator test
@@ -51,7 +51,7 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2013-01-14
  */
-class Separator extends atoum
+class Separator extends TestCase
 {
     private \Galette\Core\Db $zdb;
     private \Galette\DynamicFields\Separator $separator;
@@ -59,11 +59,9 @@ class Separator extends atoum
     /**
      * Set up tests
      *
-     * @param string $method Current test method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $this->zdb = new \Galette\Core\Db();
         $this->separator = new \Galette\DynamicFields\Separator($this->zdb);
@@ -77,8 +75,7 @@ class Separator extends atoum
     public function testConstructor()
     {
         $o = new \Galette\DynamicFields\Separator($this->zdb, 10);
-        $this->variable($o->getId())
-            ->isIdenticalTo(null);
+        $this->assertNull($o->getId());
     }
 
     /**
@@ -88,8 +85,7 @@ class Separator extends atoum
      */
     public function testGetTypeName()
     {
-        $this->variable($this->separator->getTypeName())
-            ->isIdenticalTo(_T('separator'));
+        $this->assertSame(_T('separator'), $this->separator->getTypeName());
     }
 
     /**
@@ -100,50 +96,50 @@ class Separator extends atoum
     public function testBaseProperties()
     {
         $muliple = $this->separator->isMultiValued();
-        $this->boolean($muliple)->isFalse();
+        $this->assertFalse($muliple);
 
         $required = $this->separator->isRequired();
-        $this->boolean($required)->isFalse();
+        $this->assertFalse($required);
 
         $name = $this->separator->getName();
-        $this->variable($name)->isIdenticalTo('');
+        $this->assertSame('', $name);
 
         $has_fixed_values = $this->separator->hasFixedValues();
-        $this->boolean($has_fixed_values)->isFalse();
+        $this->assertFalse($has_fixed_values);
 
         $has_data = $this->separator->hasData();
-        $this->boolean($has_data)->isFalse();
+        $this->assertFalse($has_data);
 
         $has_w = $this->separator->hasWidth();
-        $this->boolean($has_w)->isFalse();
+        $this->assertFalse($has_w);
 
         $has_h = $this->separator->hasHeight();
-        $this->boolean($has_h)->isFalse();
+        $this->assertFalse($has_h);
 
         $has_s = $this->separator->hasSize();
-        $this->boolean($has_s)->isFalse();
+        $this->assertFalse($has_s);
 
         $perms = $this->separator->getPerm();
-        $this->variable($perms)->isNull();
+        $this->assertNull($perms);
 
         $width = $this->separator->getWidth();
-        $this->variable($width)->isNull();
+        $this->assertNull($width);
 
         $height = $this->separator->getHeight();
-        $this->variable($height)->isNull();
+        $this->assertNull($height);
 
         $repeat = $this->separator->getRepeat();
-        $this->variable($repeat)->isNull();
+        $this->assertNull($repeat);
 
         $repeat = $this->separator->isRepeatable();
-        $this->boolean($repeat)->isFalse();
+        $this->assertFalse($repeat);
 
         $size = $this->separator->getSize();
-        $this->variable($size)->isNull();
+        $this->assertNull($size);
 
         $values = $this->separator->getValues();
-        $this->boolean($values)->isFalse();
+        $this->assertFalse($values);
 
-        $this->boolean($this->separator->hasPermissions())->isFalse();
+        $this->assertFalse($this->separator->hasPermissions());
     }
 }
index 96a889c0f0af2e614d1c7c8d19f178bcb3a92890..dac1a8ed0121392b9d2e645f04706960ea3b6c25 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\DynamicFields\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Dynamic texts test
@@ -51,7 +51,7 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2021-11-11
  */
-class Text extends atoum
+class Text extends TestCase
 {
     private \Galette\Core\Db $zdb;
     private \Galette\DynamicFields\Text $text;
@@ -59,11 +59,9 @@ class Text extends atoum
     /**
      * Set up tests
      *
-     * @param string $method Current test method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $this->zdb = new \Galette\Core\Db();
         $this->text = new \Galette\DynamicFields\Text($this->zdb);
@@ -77,8 +75,7 @@ class Text extends atoum
     public function testConstructor()
     {
         $o = new \Galette\DynamicFields\Text($this->zdb, 10);
-        $this->variable($o->getId())
-            ->isNull();
+        $this->assertNull($o->getId());
     }
 
     /**
@@ -88,8 +85,7 @@ class Text extends atoum
      */
     public function testGetTypeName()
     {
-        $this->variable($this->text->getTypeName())
-            ->isIdenticalTo(_T('free text'));
+        $this->assertSame(_T('free text'), $this->text->getTypeName());
     }
 
     /**
@@ -100,50 +96,50 @@ class Text extends atoum
     public function testBaseProperties()
     {
         $muliple = $this->text->isMultiValued();
-        $this->boolean($muliple)->isFalse();
+        $this->assertFalse($muliple);
 
         $required = $this->text->isRequired();
-        $this->boolean($required)->isFalse();
+        $this->assertFalse($required);
 
         $name = $this->text->getName();
-        $this->variable($name)->isIdenticalTo('');
+        $this->assertSame('', $name);
 
         $has_fixed_values = $this->text->hasFixedValues();
-        $this->boolean($has_fixed_values)->isFalse();
+        $this->assertFalse($has_fixed_values);
 
         $has_data = $this->text->hasData();
-        $this->boolean($has_data)->isTrue();
+        $this->assertTrue($has_data);
 
         $has_w = $this->text->hasWidth();
-        $this->boolean($has_w)->isTrue();
+        $this->assertTrue($has_w);
 
         $has_h = $this->text->hasHeight();
-        $this->boolean($has_h)->isTrue();
+        $this->assertTrue($has_h);
 
         $has_s = $this->text->hasSize();
-        $this->boolean($has_s)->isFalse();
+        $this->assertFalse($has_s);
 
         $perms = $this->text->getPerm();
-        $this->variable($perms)->isNull();
+        $this->assertNull($perms);
 
         $width = $this->text->getWidth();
-        $this->variable($width)->isNull();
+        $this->assertNull($width);
 
         $height = $this->text->getHeight();
-        $this->variable($height)->isNull();
+        $this->assertNull($height);
 
         $repeat = $this->text->getRepeat();
-        $this->integer($repeat)->isIdenticalTo(1);
+        $this->assertSame(1, $repeat);
 
         $repeat = $this->text->isRepeatable();
-        $this->boolean($repeat)->isTrue();
+        $this->assertTrue($repeat);
 
         $size = $this->text->getSize();
-        $this->variable($size)->isNull();
+        $this->assertNull($size);
 
         $values = $this->text->getValues();
-        $this->boolean($values)->isFalse();
+        $this->assertFalse($values);
 
-        $this->boolean($this->text->hasPermissions())->isTrue();
+        $this->assertTrue($this->text->hasPermissions());
     }
 }
index f985ab6a509f705ab99e173988aeb9ff3df06f06..90708df8c8f3b434b75dba5ba935191690ae793d 100644 (file)
@@ -61,7 +61,7 @@ class Adherent extends GaletteTestCase
      *
      * @return void
      */
-    public function tearDown()
+    public function tearDown(): void
     {
         $this->zdb = new \Galette\Core\Db();
 
@@ -80,13 +80,11 @@ class Adherent extends GaletteTestCase
     /**
      * Set up tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
-        parent::beforeTestMethod($method);
+        parent::setUp();
         $this->initStatus();
         $this->initTitles();
 
@@ -116,26 +114,26 @@ class Adherent extends GaletteTestCase
     public function testEmpty()
     {
         $adh = $this->adh;
-        $this->boolean($adh->isAdmin())->isFalse();
-        $this->boolean($adh->admin)->isFalse();
-        $this->boolean($adh->isStaff())->isFalse();
-        $this->boolean($adh->staff)->isFalse();
-        $this->boolean($adh->isDueFree())->isFalse();
-        $this->boolean($adh->due_free)->isFalse();
-        $this->boolean($adh->isGroupMember('any'))->isFalse();
-        $this->boolean($adh->isGroupManager('any'))->isFalse();
-        $this->boolean($adh->isCompany())->isFalse();
-        $this->boolean($adh->isMan())->isFalse();
-        $this->boolean($adh->isWoman())->isFalse();
-        $this->boolean($adh->isActive())->isTrue();
-        $this->boolean($adh->active)->isTrue();
-        $this->boolean($adh->isUp2Date())->isFalse();
-        $this->boolean($adh->appearsInMembersList())->isFalse();
-        $this->boolean($adh->appears_in_list)->isFalse();
-
-        $this->variable($adh->fake_prop)->isNull();
-
-        $this->array($adh->deps)->isIdenticalTo($this->default_deps);
+        $this->assertFalse($adh->isAdmin());
+        $this->assertFalse($adh->admin);
+        $this->assertFalse($adh->isStaff());
+        $this->assertFalse($adh->staff);
+        $this->assertFalse($adh->isDueFree());
+        $this->assertFalse($adh->due_free);
+        $this->assertFalse($adh->isGroupMember('any'));
+        $this->assertFalse($adh->isGroupManager('any'));
+        $this->assertFalse($adh->isCompany());
+        $this->assertFalse($adh->isMan());
+        $this->assertFalse($adh->isWoman());
+        $this->assertTrue($adh->isActive());
+        $this->assertTrue($adh->active);
+        $this->assertFalse($adh->isUp2Date());
+        $this->assertFalse($adh->appearsInMembersList());
+        $this->assertFalse($adh->appears_in_list);
+
+        $this->assertNull($adh->fake_prop);
+
+        $this->assertSame($this->default_deps, $adh->deps);
     }
 
     /**
@@ -146,7 +144,7 @@ class Adherent extends GaletteTestCase
     public function testDependencies()
     {
         $adh = $this->adh;
-        $this->array($adh->deps)->isIdenticalTo($this->default_deps);
+        $this->assertSame($this->default_deps, $adh->deps);
 
         $adh = clone $this->adh;
         $adh->disableAllDeps();
@@ -159,7 +157,7 @@ class Adherent extends GaletteTestCase
             'dynamics'  => false,
             'socials'   => false
         ];
-        $this->array($adh->deps)->isIdenticalTo($expected);
+        $this->assertSame($expected, $adh->deps);
 
         $expected = [
             'picture'   => false,
@@ -174,7 +172,7 @@ class Adherent extends GaletteTestCase
             ->enableDep('dues')
             ->enableDep('dynamics')
             ->enableDep('children');
-        $this->array($adh->deps)->isIdenticalTo($expected);
+        $this->assertSame($expected, $adh->deps);
 
         $expected = [
             'picture'   => false,
@@ -186,10 +184,10 @@ class Adherent extends GaletteTestCase
             'socials'   => false
         ];
         $adh->disableDep('children');
-        $this->array($adh->deps)->isIdenticalTo($expected);
+        $this->assertSame($expected, $adh->deps);
 
         $adh->disableDep('none')->enableDep('anothernone');
-        $this->array($adh->deps)->isIdenticalTo($expected);
+        $this->assertSame($expected, $adh->deps);
 
         $expected = [
             'picture'   => true,
@@ -201,7 +199,7 @@ class Adherent extends GaletteTestCase
             'socials'   => true
         ];
         $adh->enableAllDeps('children');
-        $this->array($adh->deps)->isIdenticalTo($expected);
+        $this->assertSame($expected, $adh->deps);
     }
 
     /**
@@ -213,11 +211,8 @@ class Adherent extends GaletteTestCase
     {
         $adh = $this->adh;
 
-        $this->exception(
-            function () use ($adh) {
-                $adh->row_classes;
-            }
-        )->isInstanceOf('RuntimeException');
+        $this->expectException('RuntimeException');
+        $adh->row_classes;
     }
 
     /**
@@ -242,14 +237,14 @@ class Adherent extends GaletteTestCase
             $deps
         );
 
-        $this->array($adh->deps)->isIdenticalTo($deps);
+        $this->assertSame($deps, $adh->deps);
 
         $adh = new \Galette\Entity\Adherent(
             $this->zdb,
             null,
             'not an array'
         );
-        $this->array($adh->deps)->isIdenticalTo($this->default_deps);
+        $this->assertSame($this->default_deps, $adh->deps);
     }
 
     /**
@@ -279,7 +274,7 @@ class Adherent extends GaletteTestCase
         $login = $this->adh->login;
         $email = $this->adh->email;
 
-        $this->variable($this->adh->email)->isIdenticalTo($this->adh->getEmail());
+        $this->assertSame($this->adh->getEmail(), $this->adh->email);
 
         $adh = new \Galette\Entity\Adherent($this->zdb, $login);
         $this->checkMemberOneExpected($adh);
@@ -303,7 +298,7 @@ class Adherent extends GaletteTestCase
         \Galette\Entity\Adherent::updatePassword($this->zdb, $this->adh->id, $newpass);
         $adh = new \Galette\Entity\Adherent($this->zdb, $this->adh->id);
         $pw_checked = password_verify($newpass, $adh->password);
-        $this->boolean($pw_checked)->isTrue();
+        $this->assertTrue($pw_checked);
 
         //reset original password
         \Galette\Entity\Adherent::updatePassword($this->zdb, $this->adh->id, 'J^B-()f');
@@ -321,7 +316,7 @@ class Adherent extends GaletteTestCase
         $data = ['ddn_adh' => 'not a date'];
         $expected = ['- Wrong date format (Y-m-d) for Birth date!'];
         $check = $adh->check($data, [], []);
-        $this->array($check)->isIdenticalTo($expected);
+        $this->assertSame($expected, $check);
 
         $data = [
             'ddn_adh'       => '',
@@ -329,27 +324,27 @@ class Adherent extends GaletteTestCase
         ];
         $expected = ['- Wrong date format (Y-m-d) for Creation date!'];
         $check = $adh->check($data, [], []);
-        $this->array($check)->isIdenticalTo($expected);
+        $this->assertSame($expected, $check);
 
         //reste creation date to its default value
         $data = ['date_crea_adh' => date('Y-m-d')];
         $check = $adh->check($data, [], []);
-        $this->boolean($check)->isTrue();
+        $this->assertTrue($check);
 
         $data = ['email_adh' => 'not an email'];
         $expected = ['- Non-valid E-Mail address! (E-Mail)'];
         $check = $adh->check($data, [], []);
-        $this->array($check)->isIdenticalTo($expected);
+        $this->assertSame($expected, $check);
 
         $data = ['login_adh' => 'a'];
         $expected = ['- The username must be composed of at least 2 characters!'];
         $check = $adh->check($data, [], []);
-        $this->array($check)->isIdenticalTo($expected);
+        $this->assertSame($expected, $check);
 
         $data = ['login_adh' => 'login@galette'];
         $expected = ['- The username cannot contain the @ character'];
         $check = $adh->check($data, [], []);
-        $this->array($check)->isIdenticalTo($expected);
+        $this->assertSame($expected, $check);
 
         $data = [
             'login_adh' => '',
@@ -358,12 +353,12 @@ class Adherent extends GaletteTestCase
         ];
         $expected = ['Too short (6 characters minimum, 5 found)'];
         $check = $adh->check($data, [], []);
-        $this->array($check)->isIdenticalTo($expected);
+        $this->assertSame($expected, $check);
 
         $data = ['mdp_adh' => 'mypassword'];
         $expected = ['- The passwords don\'t match!'];
         $check = $adh->check($data, [], []);
-        $this->array($check)->isIdenticalTo($expected);
+        $this->assertSame($expected, $check);
 
         $data = [
             'mdp_adh'   => 'mypassword',
@@ -371,40 +366,50 @@ class Adherent extends GaletteTestCase
         ];
         $expected = ['- The passwords don\'t match!'];
         $check = $adh->check($data, [], []);
-        $this->array($check)->isIdenticalTo($expected);
+        $this->assertSame($expected, $check);
 
         $data = ['id_statut' => 256];
         $expected = ['Status #256 does not exists in database.'];
         $check = $adh->check($data, [], []);
-        $this->array($check)->isIdenticalTo($expected);
+        $this->assertSame($expected, $check);
 
         //tests for group managers
-        $g1 = new \mock\Galette\Entity\Group();
-        $this->calling($g1)->getId = 1;
-        $g2 = new \mock\Galette\Entity\Group();
-        $this->calling($g2)->getId = 2;
+        //test insert failing
+        $g1 = $this->getMockBuilder(\Galette\Entity\Group::class)
+            ->onlyMethods(array('getId'))
+            ->getMock();
+        $g1->method('getId')->willReturn(1);
+
+        $g2 = $this->getMockBuilder(\Galette\Entity\Group::class)
+            ->onlyMethods(array('getId'))
+            ->getMock();
+        $g2->method('getId')->willReturn(2);
 
         //groups managers must specify a group they manage
         global $login;
-        $login = new \mock\Galette\Core\Login($this->zdb, $this->i18n);
-
-        $this->calling($login)->isGroupManager = function ($gid) use ($g1) {
-            return $gid === null || $gid == $g1->getId();
-        };
+        $login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, $this->i18n))
+            ->onlyMethods(array('isGroupManager'))
+            ->getMock();
+        $login->method('isGroupManager')->willReturnCallback(
+            function ($gid) use ($g1) {
+                return $gid === null || $gid == $g1->getId();
+            }
+        );
 
         $data = ['id_statut' => ''];
         $check = $adh->check($data, [], []);
         $expected = ['You have to select a group you own!'];
-        $this->array($check)->isIdenticalTo($expected);
+        $this->assertSame($expected, $check);
 
         $data = ['groups_adh' => [$g2->getId()]];
         $check = $adh->check($data, [], []);
         $expected = ['You have to select a group you own!'];
-        $this->array($check)->isIdenticalTo($expected);
+        $this->assertSame($expected, $check);
 
         $data = ['groups_adh' => [$g1->getId()]];
         $check = $adh->check($data, [], []);
-        $this->boolean($check)->isTrue();
+        $this->assertTrue($check);
     }
 
     /**
@@ -417,12 +422,12 @@ class Adherent extends GaletteTestCase
         $this->getMemberOne();
 
         $fakedata = new \Galette\Util\FakeData($this->zdb, $this->i18n);
-        $this->boolean($fakedata->addPhoto($this->adh))->isTrue();
+        $this->assertTrue($fakedata->addPhoto($this->adh));
 
-        $this->boolean($this->adh->hasPicture())->isTrue();
+        $this->assertTrue($this->adh->hasPicture());
 
         //remove photo
-        $this->boolean($this->adh->picture->delete())->isTrue();
+        $this->assertTrue($this->adh->picture->delete());
     }
 
     /**
@@ -435,44 +440,68 @@ class Adherent extends GaletteTestCase
         $adh = new \Galette\Entity\Adherent($this->zdb);
 
         //non authorized
-        $login = new \mock\Galette\Core\Login($this->zdb, $this->i18n);
-        $this->boolean($adh->canEdit($login))->isFalse();
+        $login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, $this->i18n))
+            ->onlyMethods(array('isGroupManager'))
+            ->getMock();
+        $this->assertFalse($adh->canEdit($login));
 
         //admin => authorized
-        $login = new \mock\Galette\Core\Login($this->zdb, $this->i18n);
-        $this->calling($login)->isAdmin = true;
-        $this->boolean($adh->canEdit($login))->isTrue();
+        $login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, $this->i18n))
+            ->onlyMethods(array('isAdmin'))
+            ->getMock();
+        $login->method('isAdmin')->willReturn(true);
+        $this->assertTrue($adh->canEdit($login));
 
         //staff => authorized
-        $login = new \mock\Galette\Core\Login($this->zdb, $this->i18n);
-        $this->calling($login)->isStaff = true;
-        $this->boolean($adh->canEdit($login))->isTrue();
+        $login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, $this->i18n))
+            ->onlyMethods(array('isStaff'))
+            ->getMock();
+        $login->method('isStaff')->willReturn(true);
+        $this->assertTrue($adh->canEdit($login));
 
         //group managers
-        $adh = new \mock\Galette\Entity\Adherent($this->zdb);
+        $adh = $this->getMockBuilder(\Galette\Entity\Adherent::class)
+            ->setConstructorArgs(array($this->zdb))
+            ->onlyMethods(array('getGroups'))
+            ->getMock();
 
-        $g1 = new \mock\Galette\Entity\Group();
-        $this->calling($g1)->getId = 1;
-        $g2 = new \mock\Galette\Entity\Group();
-        $this->calling($g2)->getId = 2;
+        $g1 = $this->getMockBuilder(\Galette\Entity\Group::class)
+            ->onlyMethods(array('getId'))
+            ->getMock();
+        $g1->method('getId')->willReturn(1);
 
-        $this->calling($adh)->getGroups = [$g1, $g2];
-        $login = new \mock\Galette\Core\Login($this->zdb, $this->i18n);
-        $this->boolean($adh->canEdit($login))->isFalse();
+        $g2 = $this->getMockBuilder(\Galette\Entity\Group::class)
+            ->onlyMethods(array('getId'))
+            ->getMock();
+        $g2->method('getId')->willReturn(2);
 
-        $this->calling($login)->isGroupManager = function ($gid) use ($g1) {
-            return $gid === null || $gid == $g1->getId();
-        };
-        $this->boolean($adh->canEdit($login))->isFalse();
+        $adh->method('getGroups')->willReturn([$g1, $g2]);
+
+        $login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, $this->i18n))
+            ->onlyMethods(array('isGroupManager'))
+            ->getMock();
+
+        $this->assertFalse($adh->canEdit($login));
+
+        $login->method('isGroupManager')->willReturnCallback(
+            function ($gid) use ($g1) {
+                return $gid === null || $gid == $g1->getId();
+            }
+        );
+        $this->assertFalse($adh->canEdit($login));
 
         $this->preferences->pref_bool_groupsmanagers_edit_member = true;
         $canEdit = $adh->canEdit($login);
         $this->preferences->pref_bool_groupsmanagers_edit_member = false; //reset
-        $this->boolean($canEdit)->isTrue();
+        $this->assertTrue($canEdit);
 
         //groups managers cannot edit members of the groups they do not own
-        $this->calling($adh)->getGroups = [$g2];
-        $this->boolean($adh->canEdit($login))->isFalse();
+        $adh->method('getGroups')->willReturn([$g2]);
+        $this->assertFalse($adh->canEdit($login));
     }
 
     /**
@@ -492,12 +521,12 @@ class Adherent extends GaletteTestCase
 
         $adh->setDuplicate();
 
-        $this->string($adh->others_infos_admin)->contains('Duplicated from');
-        $this->variable($adh->email)->isNull();
-        $this->variable($adh->id)->isNull();
-        $this->variable($adh->login)->isNull();
-        $this->variable($adh->birthdate)->isNull();
-        $this->variable($adh->surname)->isNull();
+        $this->assertStringContainsString('Duplicated from', $adh->others_infos_admin);
+        $this->assertNull($adh->email);
+        $this->assertNull($adh->id);
+        $this->assertNull($adh->login);
+        $this->assertNull($adh->birthdate);
+        $this->assertNull($adh->surname);
     }
 
     /**
@@ -521,21 +550,22 @@ class Adherent extends GaletteTestCase
             'nom_adh'       => 'Doe',
             'prenom_adh'    => 'Johny',
             'parent_id'     => $parent->id,
-            'attach'        => true
+            'attach'        => true,
+            'fingerprint'   => 'FAKER' . $this->seed
         ];
         $child = $this->createMember($child_data);
 
-        $this->string($child->name)->isIdenticalTo($child_data['nom_adh']);
-        $this->object($child->parent)->isInstanceOf('\Galette\Entity\Adherent');
-        $this->integer($child->parent->id)->isIdenticalTo($parent->id);
+        $this->assertSame($child_data['nom_adh'], $child->name);
+        $this->assertInstanceOf('\Galette\Entity\Adherent', $child->parent);
+        $this->assertSame($parent->id, $child->parent->id);
 
         $check = $child->check(['detach_parent' => true], [], []);
         if (is_array($check)) {
             var_dump($check);
         }
-        $this->boolean($check)->isTrue();
-        $this->boolean($child->store())->isTrue();
-        $this->variable($child->parent)->isNull();
+        $this->assertTrue($check);
+        $this->assertTrue($child->store());
+        $this->assertNull($child->parent);
     }
 
     /**
@@ -550,12 +580,13 @@ class Adherent extends GaletteTestCase
             'prenom_adh'        => 'Johny <script>console.log("anything");</script>',
             'email_adh'         => 'jdoe@doe.com',
             'login_adh'         => 'jdoe',
-            'info_public_adh'   => 'Any <script>console.log("useful");</script> information'
+            'info_public_adh'   => 'Any <script>console.log("useful");</script> information',
+            'fingerprint'       => 'FAKER' . $this->seed
         ] + $this->dataAdherentOne();
         $member = $this->createMember($data);
 
-        $this->string($member->sfullname)->isIdenticalTo('DOE Johny Console.log("anything");');
-        $this->string($member->others_infos)->isIdenticalTo('Any console.log("useful"); information');
+        $this->assertSame('DOE Johny Console.log("anything");', $member->sfullname);
+        $this->assertSame('Any console.log("useful"); information', $member->others_infos);
     }
 
     /**
@@ -569,47 +600,47 @@ class Adherent extends GaletteTestCase
         //load member from db
         $member = new \Galette\Entity\Adherent($this->zdb, $this->adh->id);
 
-        $this->boolean($member->canShow($this->login))->isFalse();
-        $this->boolean($member->canCreate($this->login))->isFalse();
-        $this->boolean($member->canEdit($this->login))->isFalse();
+        $this->assertFalse($member->canShow($this->login));
+        $this->assertFalse($member->canCreate($this->login));
+        $this->assertFalse($member->canEdit($this->login));
 
         //Superadmin can fully change members
         $this->logSuperAdmin();
 
-        $this->boolean($member->canShow($this->login))->isTrue();
-        $this->boolean($member->canCreate($this->login))->isTrue();
-        $this->boolean($member->canEdit($this->login))->isTrue();
+        $this->assertTrue($member->canShow($this->login));
+        $this->assertTrue($member->canCreate($this->login));
+        $this->assertTrue($member->canEdit($this->login));
 
         //logout
         $this->login->logOut();
-        $this->boolean($this->login->isLogged())->isFalse();
+        $this->assertFalse($this->login->isLogged());
 
         //Member can fully change its own information
         $mdata = $this->dataAdherentOne();
-        $this->boolean($this->login->login($mdata['login_adh'], $mdata['mdp_adh']))->isTrue();
-        $this->boolean($this->login->isLogged())->isTrue();
-        $this->boolean($this->login->isAdmin())->isFalse();
-        $this->boolean($this->login->isStaff())->isFalse();
+        $this->assertTrue($this->login->login($mdata['login_adh'], $mdata['mdp_adh']));
+        $this->assertTrue($this->login->isLogged());
+        $this->assertFalse($this->login->isAdmin());
+        $this->assertFalse($this->login->isStaff());
 
-        $this->boolean($member->canShow($this->login))->isTrue();
-        $this->boolean($member->canCreate($this->login))->isTrue();
-        $this->boolean($member->canEdit($this->login))->isTrue();
+        $this->assertTrue($member->canShow($this->login));
+        $this->assertTrue($member->canCreate($this->login));
+        $this->assertTrue($member->canEdit($this->login));
 
         //logout
         $this->login->logOut();
-        $this->boolean($this->login->isLogged())->isFalse();
+        $this->assertFalse($this->login->isLogged());
 
         //Another member has no access
         $this->getMemberTwo();
         $mdata = $this->dataAdherentTwo();
-        $this->boolean($this->login->login($mdata['login_adh'], $mdata['mdp_adh']))->isTrue();
-        $this->boolean($this->login->isLogged())->isTrue();
-        $this->boolean($this->login->isAdmin())->isFalse();
-        $this->boolean($this->login->isStaff())->isFalse();
+        $this->assertTrue($this->login->login($mdata['login_adh'], $mdata['mdp_adh']));
+        $this->assertTrue($this->login->isLogged());
+        $this->assertFalse($this->login->isAdmin());
+        $this->assertFalse($this->login->isStaff());
 
-        $this->boolean($member->canShow($this->login))->isFalse();
-        $this->boolean($member->canCreate($this->login))->isFalse();
-        $this->boolean($member->canEdit($this->login))->isFalse();
+        $this->assertFalse($member->canShow($this->login));
+        $this->assertFalse($member->canCreate($this->login));
+        $this->assertFalse($member->canEdit($this->login));
 
         //parents can fully change children information
         $this->getMemberOne();
@@ -633,48 +664,64 @@ class Adherent extends GaletteTestCase
         //load child from db
         $child = new \Galette\Entity\Adherent($this->zdb);
         $child->enableDep('parent');
-        $this->boolean($child->load($cid))->isTrue();
+        $this->assertTrue($child->load($cid));
 
-        $this->string($child->name)->isIdenticalTo($child_data['nom_adh']);
-            $this->object($child->parent)->isInstanceOf('\Galette\Entity\Adherent');
-        $this->integer($child->parent->id)->isIdenticalTo($member->id);
-        $this->boolean($this->login->login($mdata['login_adh'], $mdata['mdp_adh']))->isTrue();
+        $this->assertSame($child_data['nom_adh'], $child->name);
+        $this->assertInstanceOf('\Galette\Entity\Adherent', $child->parent);
+        $this->assertSame($member->id, $child->parent->id);
+        $this->assertTrue($this->login->login($mdata['login_adh'], $mdata['mdp_adh']));
 
         $mdata = $this->dataAdherentOne();
-        $this->boolean($this->login->login($mdata['login_adh'], $mdata['mdp_adh']))->isTrue();
-        $this->boolean($this->login->isLogged())->isTrue();
-        $this->boolean($this->login->isAdmin())->isFalse();
-        $this->boolean($this->login->isStaff())->isFalse();
+        $this->assertTrue($this->login->login($mdata['login_adh'], $mdata['mdp_adh']));
+        $this->assertTrue($this->login->isLogged());
+        $this->assertFalse($this->login->isAdmin());
+        $this->assertFalse($this->login->isStaff());
 
-        $this->boolean($child->canShow($this->login))->isTrue();
-        $this->boolean($child->canCreate($this->login))->isFalse();
-        $this->boolean($child->canEdit($this->login))->isTrue();
+        $this->assertTrue($child->canShow($this->login));
+        $this->assertFalse($child->canCreate($this->login));
+        $this->assertTrue($child->canEdit($this->login));
 
         //logout
         $this->login->logOut();
-        $this->boolean($this->login->isLogged())->isFalse();
+        $this->assertFalse($this->login->isLogged());
 
         //tests for group managers
-        $adh = new \mock\Galette\Entity\Adherent($this->zdb);
+        $adh = $this->getMockBuilder('\Galette\Entity\Adherent')
+            ->setConstructorArgs([$this->zdb])
+            ->onlyMethods(['getGroups'])
+            ->getMock();
+
+        $g1 = $this->getMockBuilder('\Galette\Entity\Group')
+            ->onlyMethods(['getId'])
+            ->getMock();
+        $g1->method('getId')->willReturn(1);
 
-        $g1 = new \mock\Galette\Entity\Group();
-        $this->calling($g1)->getId = 1;
-        $g2 = new \mock\Galette\Entity\Group();
-        $this->calling($g2)->getId = 2;
+        $g2 = $this->getMockBuilder('\Galette\Entity\Group')
+            ->onlyMethods(['getId'])
+            ->getMock();
+        $g2->method('getId')->willReturn(2);
 
         //groups managers can show members of the groups they own
-        $this->calling($adh)->getGroups = [$g1, $g2];
-        $login = new \mock\Galette\Core\Login($this->zdb, $this->i18n);
-        $this->boolean($adh->canShow($login))->isFalse();
+        $adh->method('getGroups')->willReturn([$g1, $g2]);
 
-        $this->calling($login)->isGroupManager = function ($gid) use ($g1) {
+        $login = $this->getMockBuilder('\Galette\Core\Login')
+            ->setConstructorArgs([$this->zdb, $this->i18n])
+            ->onlyMethods(['isGroupManager'])
+            ->getMock();
+        $this->assertFalse($adh->canShow($login));
+
+        $login->method('isGroupManager')->willReturnCallback(function ($gid) use ($g1) {
             return $gid === null || $gid == $g1->getId();
-        };
-        $this->boolean($adh->canShow($login))->isTrue();
+        });
+        $this->assertTrue($adh->canShow($login));
 
         //groups managers cannot show members of the groups they do not own
-        $this->calling($adh)->getGroups = [$g2];
-        $this->boolean($adh->canShow($login))->isFalse();
+        $adh = $this->getMockBuilder('\Galette\Entity\Adherent')
+            ->setConstructorArgs([$this->zdb])
+            ->onlyMethods(['getGroups'])
+            ->getMock();
+        $adh->method('getGroups')->willReturn([$g2]);
+        $this->assertFalse($adh->canShow($login));
     }
 
     /**
@@ -682,7 +729,7 @@ class Adherent extends GaletteTestCase
      *
      * @return array[]
      */
-    protected function nameCaseProvider(): array
+    public static function nameCaseProvider(): array
     {
         return [
             [
@@ -752,7 +799,8 @@ class Adherent extends GaletteTestCase
      */
     public function testsGetNameWithCase(string $name, string $surname, $title, $id, $nick, string $expected)
     {
-        $this->string(
+        $this->assertSame(
+            $expected,
             \Galette\Entity\Adherent::getNameWithCase(
                 $name,
                 $surname,
@@ -760,6 +808,6 @@ class Adherent extends GaletteTestCase
                 $id,
                 $nick,
             )
-        )->isIdenticalTo($expected);
+        );
     }
 }
index 0f78273237b9888bc44859cf03e0197f22f4710d..c8a0045bd86b692fa5823dd4f15bbfb98dcefda1 100644 (file)
@@ -58,13 +58,11 @@ class Contribution extends GaletteTestCase
     /**
      * Cleanup after each test method
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
-        parent::afterTestMethod($method);
+        parent::tearDown();
 
         $this->zdb = new \Galette\Core\Db();
         $delete = $this->zdb->delete(\Galette\Entity\Contribution::TABLE);
@@ -86,13 +84,11 @@ class Contribution extends GaletteTestCase
     /**
      * Set up tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
-        parent::beforeTestMethod($method);
+        parent::setUp();
         $this->initContributionsTypes();
 
         $this->contrib = new \Galette\Entity\Contribution($this->zdb, $this->login);
@@ -113,45 +109,42 @@ class Contribution extends GaletteTestCase
     public function testEmpty()
     {
         $contrib = $this->contrib;
-        $this->variable($contrib->id)->isNull();
-        $this->variable($contrib->isFee())->isNull();
-        $this->variable($contrib->is_cotis)->isNull();
-        $this->variable($contrib->date)->isNull();
-        $this->variable($contrib->begin_date)->isNull();
-        $this->variable($contrib->end_date)->isNull();
-        $this->variable($contrib->raw_date)->isNull();
-        $this->variable($contrib->raw_begin_date)->isNull();
-        $this->variable($contrib->raw_end_date)->isNull();
-        $this->string($contrib->duration)->isEmpty();
-        $this->variable($contrib->payment_type)->isIdenticalTo((int)$this->preferences->pref_default_paymenttype);
-        $this->string($contrib->spayment_type)->isIdenticalTo('Check');
-        $this->variable($contrib->model)->isNull();
-        $this->variable($contrib->member)->isNull();
-        $this->variable($contrib->type)->isNull();
-        $this->variable($contrib->amount)->isNull();
-        $this->variable($contrib->orig_amount)->isNull();
-        $this->variable($contrib->info)->isNull();
-        $this->variable($contrib->transaction)->isNull();
-        $this->array($contrib->fields)
-            ->hasSize(11)
-            ->hasKeys([
-                \Galette\Entity\Contribution::PK,
-                \Galette\Entity\Adherent::PK,
-                \Galette\Entity\ContributionsTypes::PK,
-                'montant_cotis',
-                'type_paiement_cotis',
-                'info_cotis',
-                'date_debut_cotis'
-            ]);
-
-        $this->string($contrib->getRowClass())->isIdenticalTo('cotis-give');
-        $this->variable($contrib::getDueDate($this->zdb, 1))->isNull();
-        $this->boolean($contrib->isTransactionPart())->isFalse();
-        $this->boolean($contrib->isTransactionPartOf(1))->isFalse();
-        $this->string($contrib->getRawType())->isIdenticalTo('donation');
-        $this->string($contrib->getTypeLabel())->isIdenticalTo('Donation');
-        $this->string($contrib->getPaymentType())->isIdenticalTo('Check');
-        $this->variable($contrib->unknown_property)->isNull();
+        $this->assertNull($contrib->id);
+        $this->assertNull($contrib->isFee());
+        $this->assertNull($contrib->is_cotis);
+        $this->assertNull($contrib->date);
+        $this->assertNull($contrib->begin_date);
+        $this->assertNull($contrib->end_date);
+        $this->assertNull($contrib->raw_date);
+        $this->assertNull($contrib->raw_begin_date);
+        $this->assertNull($contrib->raw_end_date);
+        $this->assertEmpty($contrib->duration);
+        $this->assertSame((int)$this->preferences->pref_default_paymenttype, $contrib->payment_type);
+        $this->assertSame('Check', $contrib->spayment_type);
+        $this->assertNull($contrib->model);
+        $this->assertNull($contrib->member);
+        $this->assertNull($contrib->type);
+        $this->assertNull($contrib->amount);
+        $this->assertNull($contrib->orig_amount);
+        $this->assertNull($contrib->info);
+        $this->assertNull($contrib->transaction);
+        $this->assertCount(11, $contrib->fields);
+        $this->assertTrue(isset($contrib->fields[\Galette\Entity\Contribution::PK]));
+        $this->assertTrue(isset($contrib->fields[\Galette\Entity\Adherent::PK]));
+        $this->assertTrue(isset($contrib->fields[\Galette\Entity\ContributionsTypes::PK]));
+        $this->assertTrue(isset($contrib->fields['montant_cotis']));
+        $this->assertTrue(isset($contrib->fields['type_paiement_cotis']));
+        $this->assertTrue(isset($contrib->fields['info_cotis']));
+        $this->assertTrue(isset($contrib->fields['date_debut_cotis']));
+
+        $this->assertSame('cotis-give', $contrib->getRowClass());
+        $this->assertNull($contrib::getDueDate($this->zdb, 1));
+        $this->assertFalse($contrib->isTransactionPart());
+        $this->assertFalse($contrib->isTransactionPartOf(1));
+        $this->assertSame('donation', $contrib->getRawType());
+        $this->assertSame('Donation', $contrib->getTypeLabel());
+        $this->assertSame('Check', $contrib->getPaymentType());
+        $this->assertNull($contrib->unknown_property);
     }
 
     /**
@@ -165,68 +158,68 @@ class Contribution extends GaletteTestCase
 
         //set a bad date
         $contrib->begin_date = 'not a date';
-        $this->variable($contrib->raw_begin_date)->isNull();
-        $this->variable($contrib->begin_date)->isNull();
+        $this->assertNull($contrib->raw_begin_date);
+        $this->assertNull($contrib->begin_date);
 
         $contrib->begin_date = '2017-06-17';
-        $this->object($contrib->raw_begin_date)->isInstanceOf('DateTime');
-        $this->string($contrib->begin_date)->isIdenticalTo('2017-06-17');
+        $this->assertInstanceOf('DateTime', $contrib->raw_begin_date);
+        $this->assertSame('2017-06-17', $contrib->begin_date);
 
         $contrib->amount = 'not an amount';
-        $this->variable($contrib->amount)->isNull();
+        $this->assertNull($contrib->amount);
         $contrib->amount = 0;
-        $this->variable($contrib->amount)->isNull();
+        $this->assertNull($contrib->amount);
         $contrib->amount = 42;
-        $this->integer($contrib->amount)->isIdenticalTo(42);
+        $this->assertSame(42, $contrib->amount);
         $contrib->amount = '42';
-        $this->string($contrib->amount)->isIdenticalTo('42');
+        $this->assertSame('42', $contrib->amount);
 
         $contrib->type = 'not a type';
-        $this->variable($contrib->type)->isNull();
+        $this->assertNull($contrib->type);
         $contrib->type = 156;
-        $this->object($contrib->type)->isInstanceOf('\Galette\Entity\ContributionsTypes');
-        $this->boolean($contrib->type->id)->isFalse();
+        $this->assertInstanceOf('\Galette\Entity\ContributionsTypes', $contrib->type);
+        $this->assertFalse($contrib->type->id);
         $contrib->type = 1;
-        $this->object($contrib->type)->isInstanceOf('\Galette\Entity\ContributionsTypes');
-        $this->variable($contrib->type->id)->isEqualTo(1);
+        $this->assertInstanceOf('\Galette\Entity\ContributionsTypes', $contrib->type);
+        $this->assertEquals(1, $contrib->type->id);
 
         $contrib->transaction = 'not a transaction id';
-        $this->variable($contrib->transaction)->isNull();
+        $this->assertNull($contrib->transaction);
         $contrib->transaction = 46;
-        $this->object($contrib->transaction)->isInstanceOf('\Galette\Entity\Transaction');
-        $this->variable($contrib->transaction->id)->isNull();
+        $this->assertInstanceOf('\Galette\Entity\Transaction', $contrib->transaction);
+        $this->assertNull($contrib->transaction->id);
 
         $contrib->member = 'not a member';
-        $this->variable($contrib->member)->isNull();
+        $this->assertNull($contrib->member);
         $contrib->member = 118218;
-        $this->integer($contrib->member)->isIdenticalTo(118218);
+        $this->assertSame(118218, $contrib->member);
 
         $contrib->not_a_property = 'abcde';
-        $this->boolean(property_exists($contrib, 'not_a_property'))->isFalse();
+        $this->assertFalse(property_exists($contrib, 'not_a_property'));
 
         $contrib->payment_type = \Galette\Entity\PaymentType::CASH;
-        $this->string($contrib->getPaymentType())->isIdenticalTo('Cash');
-        $this->string($contrib->spayment_type)->isIdenticalTo('Cash');
+        $this->assertSame('Cash', $contrib->getPaymentType());
+        $this->assertSame('Cash', $contrib->spayment_type);
 
         $contrib->payment_type = \Galette\Entity\PaymentType::CHECK;
-        $this->string($contrib->getPaymentType())->isIdenticalTo('Check');
-        $this->string($contrib->spayment_type)->isIdenticalTo('Check');
+        $this->assertSame('Check', $contrib->getPaymentType());
+        $this->assertSame('Check', $contrib->spayment_type);
 
         $contrib->payment_type = \Galette\Entity\PaymentType::OTHER;
-        $this->string($contrib->getPaymentType())->isIdenticalTo('Other');
-        $this->string($contrib->spayment_type)->isIdenticalTo('Other');
+        $this->assertSame('Other', $contrib->getPaymentType());
+        $this->assertSame('Other', $contrib->spayment_type);
 
         $contrib->payment_type = \Galette\Entity\PaymentType::CREDITCARD;
-        $this->string($contrib->getPaymentType())->isIdenticalTo('Credit card');
-        $this->string($contrib->spayment_type)->isIdenticalTo('Credit card');
+        $this->assertSame('Credit card', $contrib->getPaymentType());
+        $this->assertSame('Credit card', $contrib->spayment_type);
 
         $contrib->payment_type = \Galette\Entity\PaymentType::TRANSFER;
-        $this->string($contrib->getPaymentType())->isIdenticalTo('Transfer');
-        $this->string($contrib->spayment_type)->isIdenticalTo('Transfer');
+        $this->assertSame('Transfer', $contrib->getPaymentType());
+        $this->assertSame('Transfer', $contrib->spayment_type);
 
         $contrib->payment_type = \Galette\Entity\PaymentType::PAYPAL;
-        $this->string($contrib->getPaymentType())->isIdenticalTo('Paypal');
-        $this->string($contrib->spayment_type)->isIdenticalTo('Paypal');
+        $this->assertSame('Paypal', $contrib->getPaymentType());
+        $this->assertSame('Paypal', $contrib->spayment_type);
     }
 
     /**
@@ -269,14 +262,17 @@ class Contribution extends GaletteTestCase
             'date_fin_cotis' => $due_date->format('Y-m-d'),
         ];
         $this->createContrib($data);
-        $this->array($this->contrib->getRequired())->isIdenticalTo([
-            'id_type_cotis'     => 1,
-            'id_adh'            => 1,
-            'date_enreg'        => 1,
-            'date_debut_cotis'  => 1,
-            'date_fin_cotis'    => 0,
-            'montant_cotis'     => 0
-        ]);
+        $this->assertSame(
+            [
+                'id_type_cotis'     => 1,
+                'id_adh'            => 1,
+                'date_enreg'        => 1,
+                'date_debut_cotis'  => 1,
+                'date_fin_cotis'    => 0,
+                'montant_cotis'     => 0
+            ],
+            $this->contrib->getRequired()
+        );
 
         $this->logSuperAdmin();
         $data = [
@@ -292,7 +288,7 @@ class Contribution extends GaletteTestCase
         $this->createContrib($data);
 
         $contrib = new \Galette\Entity\Contribution($this->zdb, $this->login, $this->contrib->id);
-        $this->variable($contrib->amount)->isIdenticalTo(1280.00);
+        $this->assertSame(1280.00, $contrib->amount);
 
         //empty amount
         $data = [
@@ -308,7 +304,7 @@ class Contribution extends GaletteTestCase
         $this->createContrib($data);
 
         $contrib = new \Galette\Entity\Contribution($this->zdb, $this->login, $this->contrib->id);
-        $this->variable($contrib->amount)->isIdenticalTo(0.00);
+        $this->assertSame(0.00, $contrib->amount);
     }
 
     /**
@@ -334,23 +330,19 @@ class Contribution extends GaletteTestCase
         $due_date = new \DateTime();
         $due_date->add(new \DateInterval('P1Y'));
         $due_date->sub(new \DateInterval('P1D'));
-        $this->string($contrib->end_date)->isIdenticalTo($due_date->format('Y-m-d'));
+        $this->assertSame($due_date->format('Y-m-d'), $contrib->end_date);
 
         //unset pref_beg_membership and pref_membership_ext
         $preferences->pref_beg_membership = '';
         $preferences->pref_membership_ext = '';
 
-        $this->exception(
-            function () {
-                $contrib = new \Galette\Entity\Contribution(
-                    $this->zdb,
-                    $this->login,
-                    ['type' => 1] //annual fee
-                );
-            }
-        )
-            ->isInstanceOf('RuntimeException')
-            ->hasMessage('Unable to define end date; none of pref_beg_membership nor pref_membership_ext are defined!');
+        $this->expectException('RuntimeException');
+        $this->expectExceptionMessage('Unable to define end date; none of pref_beg_membership nor pref_membership_ext are defined!');
+        $contrib = new \Galette\Entity\Contribution(
+            $this->zdb,
+            $this->login,
+            ['type' => 1] //annual fee
+        );
 
         // Second, test with beginning of membership date
         $preferences->pref_beg_membership = '29/05';
@@ -365,7 +357,7 @@ class Contribution extends GaletteTestCase
             $this->login,
             ['type' => 1] // annual fee
         );
-        $this->string($contrib->end_date)->isIdenticalTo($due_date->format('Y-m-d'));
+        $this->assertSame($due_date->format('Y-m-d'), $contrib->end_date);
 
         // Third, test with beginning of membership date and 2 last months offered
         $begin_date = new \DateTime();
@@ -381,7 +373,7 @@ class Contribution extends GaletteTestCase
             $this->login,
             ['type' => 1] // annual fee
         );
-        $this->string($contrib->end_date)->isIdenticalTo($due_date->format('Y-m-d'));
+        $this->assertSame($due_date->format('Y-m-d'), $contrib->end_date);
 
         //reset
         $preferences->pref_beg_membership = $orig_pref_beg_membership;
@@ -416,10 +408,10 @@ class Contribution extends GaletteTestCase
         if (is_array($check)) {
             var_dump($check);
         }
-        $this->boolean($check)->isTrue();
+        $this->assertTrue($check);
 
         $store = $adh->store();
-        $this->boolean($store)->isTrue();
+        $this->assertTrue($store);
 
         //create first contribution for member
         $contrib = new \Galette\Entity\Contribution($this->zdb, $this->login);
@@ -443,11 +435,11 @@ class Contribution extends GaletteTestCase
         if (is_array($check)) {
             var_dump($check);
         }
-        $this->boolean($check)->isTrue();
-        $this->boolean($contrib->checkOverlap())->isTrue();
+        $this->assertTrue($check);
+        $this->assertTrue($contrib->checkOverlap());
 
         $store = $contrib->store();
-        $this->boolean($store)->isTrue();
+        $this->assertTrue($store);
 
         //load member from db
         $adh = new \Galette\Entity\Adherent($this->zdb, $adh->id);
@@ -471,17 +463,16 @@ class Contribution extends GaletteTestCase
         ];
 
         $check = $contrib->check($data, [], []);
-        $this->array($check)->isIdenticalTo([
-            '- Membership period overlaps period starting at ' . $now->format('Y-m-d')
-        ]);
-
-        $this->exception(
-            function () use ($contrib) {
-                $store = $contrib->store();
-            }
-        )
-            ->isInstanceOf('RuntimeException')
-            ->message->startWith('Existing errors prevents storing contribution');
+        $this->assertSame(
+            [
+                '- Membership period overlaps period starting at ' . $now->format('Y-m-d')
+            ],
+            $check
+        );
+
+        $this->expectException('RuntimeException');
+        $this->expectExceptionMessage('Existing errors prevents storing contribution');
+        $store = $contrib->store();
     }
 
     /**
@@ -491,18 +482,26 @@ class Contribution extends GaletteTestCase
      */
     public function testGetFieldLabel()
     {
-        $this->string($this->contrib->getFieldLabel('montant_cotis'))
-            ->isIdenticalTo('Amount');
+        $this->assertSame(
+            'Amount',
+            $this->contrib->getFieldLabel('montant_cotis')
+        );
 
-        $this->string($this->contrib->getFieldLabel('date_debut_cotis'))
-            ->isIdenticalTo('Date of contribution');
+        $this->assertSame(
+            'Date of contribution',
+            $this->contrib->getFieldLabel('date_debut_cotis')
+        );
 
         $this->contrib->type = 1;
-        $this->string($this->contrib->getFieldLabel('date_debut_cotis'))
-            ->isIdenticalTo('Start date of membership');
+        $this->assertSame(
+            'Start date of membership',
+            $this->contrib->getFieldLabel('date_debut_cotis')
+        );
 
-        $this->string($this->contrib->getFieldLabel('info_cotis'))
-            ->isIdenticalTo('Comments');
+        $this->assertSame(
+            'Comments',
+            $this->contrib->getFieldLabel('info_cotis')
+        );
     }
 
     /**
@@ -512,10 +511,13 @@ class Contribution extends GaletteTestCase
      */
     public function testLoad()
     {
-        $this->login = new \mock\Galette\Core\Login($this->zdb, $this->i18n);
-        $this->calling($this->login)->isLogged = true;
-        $this->calling($this->login)->isStaff = true;
-        $this->calling($this->login)->isAdmin = true;
+        $this->login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, $this->i18n))
+            ->onlyMethods(array('isLogged', 'isStaff', 'isAdmin'))
+            ->getMock();
+        $this->login->method('isLogged')->willReturn(true);
+        $this->login->method('isStaff')->willReturn(true);
+        $this->login->method('isAdmin')->willReturn(true);
 
         $this->getMemberOne();
 
@@ -525,10 +527,10 @@ class Contribution extends GaletteTestCase
         $id = $this->contrib->id;
         $contrib = new \Galette\Entity\Contribution($this->zdb, $this->login);
 
-        $this->boolean($contrib->load((int)$id))->isTrue();
+        $this->assertTrue($contrib->load((int)$id));
         $this->checkContribExpected($contrib);
 
-        $this->boolean($contrib->load(1355522012))->isFalse();
+        $this->assertFalse($contrib->load(1355522012));
     }
 
     /**
@@ -541,8 +543,8 @@ class Contribution extends GaletteTestCase
         $this->getMemberOne();
         $this->createContribution();
 
-        $this->boolean($this->contrib->remove())->isTrue();
-        $this->boolean($this->contrib->remove())->isFalse();
+        $this->assertTrue($this->contrib->remove());
+        $this->assertFalse($this->contrib->remove());
     }
 
     /**
@@ -557,39 +559,39 @@ class Contribution extends GaletteTestCase
         $this->createContribution();
         $contrib = $this->contrib;
 
-        $this->boolean($contrib->canShow($this->login))->isFalse();
+        $this->assertFalse($contrib->canShow($this->login));
 
         //Superadmin can fully change contributions
         $this->logSuperAdmin();
 
-        $this->boolean($contrib->canShow($this->login))->isTrue();
+        $this->assertTrue($contrib->canShow($this->login));
 
         //logout
         $this->login->logOut();
-        $this->boolean($this->login->isLogged())->isFalse();
+        $this->assertFalse($this->login->isLogged());
 
         //Member can fully change its own contributions
         $mdata = $this->dataAdherentOne();
-        $this->boolean($this->login->login($mdata['login_adh'], $mdata['mdp_adh']))->isTrue();
-        $this->boolean($this->login->isLogged())->isTrue();
-        $this->boolean($this->login->isAdmin())->isFalse();
-        $this->boolean($this->login->isStaff())->isFalse();
+        $this->assertTrue($this->login->login($mdata['login_adh'], $mdata['mdp_adh']));
+        $this->assertTrue($this->login->isLogged());
+        $this->assertFalse($this->login->isAdmin());
+        $this->assertFalse($this->login->isStaff());
 
-        $this->boolean($contrib->canShow($this->login))->isTrue();
+        $this->assertTrue($contrib->canShow($this->login));
 
         //logout
         $this->login->logOut();
-        $this->boolean($this->login->isLogged())->isFalse();
+        $this->assertFalse($this->login->isLogged());
 
         //Another member has no access
         $this->getMemberTwo();
         $mdata = $this->dataAdherentTwo();
-        $this->boolean($this->login->login($mdata['login_adh'], $mdata['mdp_adh']))->isTrue();
-        $this->boolean($this->login->isLogged())->isTrue();
-        $this->boolean($this->login->isAdmin())->isFalse();
-        $this->boolean($this->login->isStaff())->isFalse();
+        $this->assertTrue($this->login->login($mdata['login_adh'], $mdata['mdp_adh']));
+        $this->assertTrue($this->login->isLogged());
+        $this->assertFalse($this->login->isAdmin());
+        $this->assertFalse($this->login->isStaff());
 
-        $this->boolean($contrib->canShow($this->login))->isFalse();
+        $this->assertFalse($contrib->canShow($this->login));
 
         //parents can chow change children contributions
         $this->getMemberOne();
@@ -636,23 +638,23 @@ class Contribution extends GaletteTestCase
         //load child from db
         $child = new \Galette\Entity\Adherent($this->zdb);
         $child->enableDep('parent');
-        $this->boolean($child->load($cid))->isTrue();
+        $this->assertTrue($child->load($cid));
 
-        $this->string($child->name)->isIdenticalTo($child_data['nom_adh']);
-        $this->object($child->parent)->isInstanceOf('\Galette\Entity\Adherent');
-        $this->integer($child->parent->id)->isIdenticalTo($member->id);
-        $this->boolean($this->login->login($mdata['login_adh'], $mdata['mdp_adh']))->isTrue();
+        $this->assertSame($child_data['nom_adh'], $child->name);
+        $this->assertInstanceOf('\Galette\Entity\Adherent', $child->parent);
+        $this->assertSame($member->id, $child->parent->id);
+        $this->assertTrue($this->login->login($mdata['login_adh'], $mdata['mdp_adh']));
 
         $mdata = $this->dataAdherentOne();
-        $this->boolean($this->login->login($mdata['login_adh'], $mdata['mdp_adh']))->isTrue();
-        $this->boolean($this->login->isLogged())->isTrue();
-        $this->boolean($this->login->isAdmin())->isFalse();
-        $this->boolean($this->login->isStaff())->isFalse();
+        $this->assertTrue($this->login->login($mdata['login_adh'], $mdata['mdp_adh']));
+        $this->assertTrue($this->login->isLogged());
+        $this->assertFalse($this->login->isAdmin());
+        $this->assertFalse($this->login->isStaff());
 
-        $this->boolean($ccontrib->canShow($this->login))->isTrue();
+        $this->assertTrue($ccontrib->canShow($this->login));
 
         //logout
         $this->login->logOut();
-        $this->boolean($this->login->isLogged())->isFalse();
+        $this->assertFalse($this->login->isLogged());
     }
 }
index e7c1011ff82adecc034bad2e9957058057e3effb..c3daf0e1cb8f1320bf78b926b7c2026e7a93c5ea 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\Entity\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Preferences tests class
@@ -51,7 +51,7 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2016-09-24
  */
-class FieldsConfig extends atoum
+class FieldsConfig extends TestCase
 {
     private ?\Galette\Entity\FieldsConfig $fields_config = null;
     private \Galette\Core\Db $zdb;
@@ -61,11 +61,9 @@ class FieldsConfig extends atoum
     /**
      * Set up tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $this->zdb = new \Galette\Core\Db();
 
@@ -106,7 +104,7 @@ class FieldsConfig extends atoum
             'sexe_adh',
             'parent_id'
         ];
-        $this->array($nrequired)->isIdenticalTo($expected);
+        $this->assertSame($expected, $nrequired);
     }
 
     /**
@@ -116,10 +114,8 @@ class FieldsConfig extends atoum
      */
     public function testInstallInit()
     {
-        $result = $this->fields_config->installInit(
-            $this->zdb
-        );
-        $this->boolean($result)->isTrue();
+        $result = $this->fields_config->installInit();
+        $this->assertTrue($result);
 
         //new object with values loaded from database to compare
         $fields_config = new \Galette\Entity\FieldsConfig(
@@ -141,13 +137,13 @@ class FieldsConfig extends atoum
             'cp_adh'        => 1,
             'ville_adh'     => 1
         ];
-        $this->array($required)->isEqualTo($expected);
+        $this->assertEquals($expected, $required);
 
         $isrequired = $fields_config->isRequired('login_adh');
-        $this->boolean($isrequired)->isTrue();
+        $this->assertTrue($isrequired);
 
         $isrequired = $fields_config->isRequired('info_adh');
-        $this->boolean($isrequired)->isFalse();
+        $this->assertFalse($isrequired);
 
         $lists_config = new \Galette\Entity\ListsConfig(
             $this->zdb,
@@ -156,18 +152,19 @@ class FieldsConfig extends atoum
             $this->members_fields_cats,
             true
         );
-        $this->boolean($lists_config->load())->isTrue();
+        $this->assertTrue($lists_config->load());
 
         $visibles = $fields_config->getVisibilities();
-        $this->array($visibles)
-             ->hasSize(
-                 count($categorized[\Galette\Entity\FieldsCategories::ADH_CATEGORY_IDENTITY]) +
-                 count($categorized[\Galette\Entity\FieldsCategories::ADH_CATEGORY_GALETTE]) +
-                 count($categorized[\Galette\Entity\FieldsCategories::ADH_CATEGORY_CONTACT]) +
-                 count($lists_config->getAclMapping())
-             )
-            ->integer['id_adh']->isIdenticalTo(0)
-            ->integer['nom_adh']->isIdenticalTo(1);
+        $this->assertCount(
+            count($categorized[\Galette\Entity\FieldsCategories::ADH_CATEGORY_IDENTITY]) +
+            count($categorized[\Galette\Entity\FieldsCategories::ADH_CATEGORY_GALETTE]) +
+            count($categorized[\Galette\Entity\FieldsCategories::ADH_CATEGORY_CONTACT]) +
+            count($lists_config->getAclMapping()),
+            $visibles
+        );
+
+        $this->assertSame(0, $visibles['id_adh']);
+        $this->assertSame(1, $visibles['nom_adh']);
     }
 
     /**
@@ -179,14 +176,10 @@ class FieldsConfig extends atoum
      */
     private function countCategorizedFields($categorized)
     {
-        $this->array($categorized)
-            ->hasSize(3);
-        $this->array($categorized[\Galette\Entity\FieldsCategories::ADH_CATEGORY_IDENTITY])
-            ->hasSize(13);
-        $this->array($categorized[\Galette\Entity\FieldsCategories::ADH_CATEGORY_GALETTE])
-            ->hasSize(11);
-        $this->array($categorized[\Galette\Entity\FieldsCategories::ADH_CATEGORY_CONTACT])
-            ->hasSize(10);
+        $this->assertCount(3, $categorized);
+        $this->assertCount(13, $categorized[\Galette\Entity\FieldsCategories::ADH_CATEGORY_IDENTITY]);
+        $this->assertCount(11, $categorized[\Galette\Entity\FieldsCategories::ADH_CATEGORY_GALETTE]);
+        $this->assertCount(10, $categorized[\Galette\Entity\FieldsCategories::ADH_CATEGORY_CONTACT]);
     }
 
     /**
@@ -200,19 +193,19 @@ class FieldsConfig extends atoum
         $fields_config->load();
 
         $required_mdp = $fields_config->getRequired()['mdp_adh'];
-        $this->boolean($required_mdp)->isTrue();
+        $this->assertTrue($required_mdp);
 
         $cat = \Galette\Entity\FieldsCategories::ADH_CATEGORY_GALETTE;
         $required_mdp = $fields_config->getCategorizedFields()[$cat][6]['required'];
-        $this->boolean($required_mdp)->isTrue();
+        $this->assertTrue($required_mdp);
 
         $fields_config->setNotRequired('mdp_adh');
 
         $required_mdp = $fields_config->getRequired();
-        $this->array($required_mdp)->notHasKey('mdp_adh');
+        $this->assertFalse(isset($required_mdp['mdp_adh']));
 
         $required_mdp = $fields_config->getCategorizedFields()[$cat][6]['required'];
-        $this->boolean($required_mdp)->isFalse();
+        $this->assertFalse($required_mdp);
     }
 
     /**
@@ -225,13 +218,13 @@ class FieldsConfig extends atoum
         $this->fields_config->load();
 
         $visible = $this->fields_config->getVisibility('nom_adh');
-        $this->integer($visible)->isIdenticalTo(\Galette\Entity\FieldsConfig::USER_WRITE);
+        $this->assertSame(\Galette\Entity\FieldsConfig::USER_WRITE, $visible);
 
         $visible = $this->fields_config->getVisibility('id_adh');
-        $this->integer($visible)->isIdenticalTo(\Galette\Entity\FieldsConfig::NOBODY);
+        $this->assertSame(\Galette\Entity\FieldsConfig::NOBODY, $visible);
 
         $visible = $this->fields_config->getVisibility('info_adh');
-        $this->integer($visible)->isIdenticalTo(\Galette\Entity\FieldsConfig::STAFF);
+        $this->assertSame(\Galette\Entity\FieldsConfig::STAFF, $visible);
     }
 
     /**
@@ -249,8 +242,8 @@ class FieldsConfig extends atoum
 
         //town
         $town = &$fields[\Galette\Entity\FieldsCategories::ADH_CATEGORY_CONTACT][2];
-        $this->boolean($town['required'])->isTrue();
-        $this->integer($town['visible'])->isIdenticalTo(\Galette\Entity\FieldsConfig::USER_WRITE);
+        $this->assertTrue($town['required']);
+        $this->assertSame(\Galette\Entity\FieldsConfig::USER_WRITE, $town['visible']);
 
         $town['required'] = false;
         $town['visible'] = \Galette\Entity\FieldsConfig::NOBODY;
@@ -262,17 +255,17 @@ class FieldsConfig extends atoum
         $gsm['category'] = \Galette\Entity\FieldsCategories::ADH_CATEGORY_IDENTITY;
         $fields[\Galette\Entity\FieldsCategories::ADH_CATEGORY_IDENTITY][] = $gsm;
 
-        $this->boolean($fields_config->setFields($fields))->isTrue();
+        $this->assertTrue($fields_config->setFields($fields));
 
         $fields_config->load();
         $fields = $fields_config->getCategorizedFields();
 
         $town = $fields[\Galette\Entity\FieldsCategories::ADH_CATEGORY_CONTACT][2];
-        $this->boolean($town['required'])->isFalse();
-        $this->integer($town['visible'])->isIdenticalTo(\Galette\Entity\FieldsConfig::NOBODY);
+        $this->assertFalse($town['required']);
+        $this->assertSame(\Galette\Entity\FieldsConfig::NOBODY, $town['visible']);
 
         $gsm2 = $fields[\Galette\Entity\FieldsCategories::ADH_CATEGORY_IDENTITY][13];
-        $this->array($gsm2)->isIdenticalTo($gsm);
+        $this->assertSame($gsm, $gsm2);
     }
 
     /**
@@ -282,9 +275,9 @@ class FieldsConfig extends atoum
      */
     public function testIsSelfExcluded()
     {
-        $this->boolean($this->fields_config->isSelfExcluded('bool_admin_adh'))->isTrue();
-        $this->boolean($this->fields_config->isSelfExcluded('info_adh'))->isTrue();
-        $this->boolean($this->fields_config->isSelfExcluded('nom_adh'))->isFalse();
+        $this->assertTrue($this->fields_config->isSelfExcluded('bool_admin_adh'));
+        $this->assertTrue($this->fields_config->isSelfExcluded('info_adh'));
+        $this->assertFalse($this->fields_config->isSelfExcluded('nom_adh'));
     }
 
     /**
@@ -306,7 +299,7 @@ class FieldsConfig extends atoum
                 break;
             }
         }
-        $this->boolean($exists)->isTrue();
+        $this->assertTrue($exists);
 
         $delete = $this->zdb->delete(\Galette\Entity\FieldsConfig::TABLE);
         $delete->where(
@@ -316,14 +309,15 @@ class FieldsConfig extends atoum
             ]
         );
         $res = $this->zdb->execute($delete);
-        $this->integer($res->count())->isIdenticalTo(1);
+        $this->assertSame(1, $res->count());
 
         $fields_config->load();
 
         $categorized = $fields_config->getCategorizedFields();
-        $this->integer(
+        $this->assertSame(
+            13,
             count($categorized[\Galette\Entity\FieldsCategories::ADH_CATEGORY_IDENTITY])
-        )->isIdenticalTo(13);
+        );
 
         //new object instanciation should add missing field back
         $fields_config = new \Galette\Entity\FieldsConfig(
@@ -334,7 +328,7 @@ class FieldsConfig extends atoum
         );
 
         $categorized = $fields_config->getCategorizedFields();
-        $this->array($categorized)->isIdenticalTo($categorized_init);
+        $this->assertSame($categorized_init, $categorized);
     }
 
     /**
@@ -375,53 +369,50 @@ class FieldsConfig extends atoum
         $fields_config = $this->fields_config;
         $fields_config->load();
 
-        $admin_login = new \mock\Galette\Core\Login(
-            $this->zdb,
-            new \Galette\Core\I18n()
-        );
-        $this->calling($admin_login)->isAdmin = true;
+        $admin_login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, new \Galette\Core\I18n()))
+            ->onlyMethods(array('isAdmin'))
+            ->getMock();
+        $admin_login->method('isAdmin')->willReturn(true);
 
         $elements = $fields_config->getDisplayElements($admin_login);
-        $this->array($elements)
-            ->hasSize(3);
+        $this->assertCount(3, $elements);
 
-        $this->object($elements[0])->isInstanceOf('\stdClass');
-        $this->integer($elements[0]->id)->isIdenticalTo(1);
-        $this->array($elements[0]->elements)->hasSize(8);
+        $this->assertInstanceOf('\stdClass', $elements[0]);
+        $this->assertSame(1, $elements[0]->id);
+        $this->assertCount(8, $elements[0]->elements);
 
-        $this->object($elements[1])->isInstanceOf('\stdClass');
-        $this->integer($elements[1]->id)->isIdenticalTo(3);
-        $this->array($elements[1]->elements)->hasSize(8);
+        $this->assertInstanceOf('\stdClass', $elements[1]);
+        $this->assertSame(3, $elements[1]->id);
+        $this->assertCount(8, $elements[1]->elements);
 
-        $this->object($elements[2])->isInstanceOf('\stdClass');
-        $this->integer($elements[2]->id)->isIdenticalTo(2);
-        $this->array($elements[2]->elements)
-            ->hasSize(10)
-            ->hasKey('info_adh');
+        $this->assertInstanceOf('\stdClass', $elements[2]);
+        $this->assertSame(2, $elements[2]->id);
+        $this->assertCount(10, $elements[2]->elements);
+        $this->assertTrue(isset($elements[2]->elements['info_adh']));
+
+        $user_login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, new \Galette\Core\I18n()))
+            ->onlyMethods(array('isUp2Date'))
+            ->getMock();
+        $user_login->method('isUp2Date')->willReturn(true);
 
-        $user_login = new \mock\Galette\Core\Login(
-            $this->zdb,
-            new \Galette\Core\I18n()
-        );
-        $this->calling($user_login)->isUp2Date = true;
 
         $elements = $fields_config->getDisplayElements($user_login);
-        $this->array($elements)
-            ->hasSize(3);
-
-        $this->object($elements[0])->isInstanceOf('\stdClass');
-        $this->integer($elements[0]->id)->isIdenticalTo(1);
-        $this->array($elements[0]->elements)->hasSize(7);
-
-        $this->object($elements[1])->isInstanceOf('\stdClass');
-        $this->integer($elements[1]->id)->isIdenticalTo(3);
-        $this->array($elements[1]->elements)->hasSize(8);
-
-        $this->object($elements[2])->isInstanceOf('\stdClass');
-        $this->integer($elements[2]->id)->isIdenticalTo(2);
-        $this->array($elements[2]->elements)
-            ->hasSize(4)
-            ->notHasKey('info_adh');
+        $this->assertCount(3, $elements);
+
+        $this->assertInstanceOf('\stdClass', $elements[0]);
+        $this->assertSame(1, $elements[0]->id);
+        $this->assertCount(7, $elements[0]->elements);
+
+        $this->assertInstanceOf('\stdClass', $elements[1]);
+        $this->assertSame(3, $elements[1]->id);
+        $this->assertCount(8, $elements[1]->elements);
+
+        $this->assertInstanceOf('\stdClass', $elements[2]);
+        $this->assertSame(2, $elements[2]->id);
+        $this->assertCount(4, $elements[2]->elements);
+        $this->assertFalse(isset($elements[2]->elements['info_adh']));
     }
 
     /**
@@ -434,107 +425,98 @@ class FieldsConfig extends atoum
         $fields_config = $this->fields_config;
         $fields_config->load();
 
-        $admin_login = new \mock\Galette\Core\Login(
-            $this->zdb,
-            new \Galette\Core\I18n()
-        );
-        $this->calling($admin_login)->isAdmin = true;
+        $admin_login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, new \Galette\Core\I18n()))
+            ->onlyMethods(array('isAdmin'))
+            ->getMock();
+        $admin_login->method('isAdmin')->willReturn(true);
 
         $elements = $fields_config->getFormElements($admin_login, false);
-        $this->array($elements)
-            ->hasSize(2)
-            ->hasKeys(['fieldsets', 'hiddens']);
+        $this->assertCount(2, $elements);
+        $this->assertTrue(isset($elements['fieldsets']));
+        $this->assertTrue(isset($elements['hiddens']));
 
-        $this->array($elements['fieldsets'])
-            ->hasSize(3);
+        $this->assertCount(3, $elements['fieldsets']);
 
-        $this->object($elements['fieldsets'][0])->isInstanceOf('\stdClass');
-        $this->integer($elements['fieldsets'][0]->id)->isIdenticalTo(1);
-        $this->array($elements['fieldsets'][0]->elements)->hasSize(11);
+        $this->assertInstanceOf('\stdClass', $elements['fieldsets'][0]);
+        $this->assertSame(1, $elements['fieldsets'][0]->id);
+        $this->assertCount(11, $elements['fieldsets'][0]->elements);
 
-        $this->object($elements['fieldsets'][1])->isInstanceOf('\stdClass');
-        $this->integer($elements['fieldsets'][1]->id)->isIdenticalTo(3);
-        $this->array($elements['fieldsets'][1]->elements)->hasSize(8);
+        $this->assertInstanceOf('\stdClass', $elements['fieldsets'][1]);
+        $this->assertSame(3, $elements['fieldsets'][1]->id);
+        $this->assertCount(8, $elements['fieldsets'][1]->elements);
 
-        $this->object($elements['fieldsets'][2])->isInstanceOf('\stdClass');
-        $this->integer($elements['fieldsets'][2]->id)->isIdenticalTo(2);
-        $this->array($elements['fieldsets'][2]->elements)
-            ->hasSize(10)
-            ->hasKey('info_adh');
+        $this->assertInstanceOf('\stdClass', $elements['fieldsets'][2]);
+        $this->assertSame(2, $elements['fieldsets'][2]->id);
+        $this->assertCount(10, $elements['fieldsets'][2]->elements);
+        $this->assertTrue(isset($elements['fieldsets'][2]->elements['info_adh']));
 
-        $this->array($elements['hiddens'])
-            ->hasSize(2);
+        $this->assertCount(2, $elements['hiddens']);
 
-        $user_login = new \mock\Galette\Core\Login(
-            $this->zdb,
-            new \Galette\Core\I18n()
-        );
-        $this->calling($user_login)->isUp2Date = true;
+        $user_login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, new \Galette\Core\I18n()))
+            ->onlyMethods(array('isUp2Date'))
+            ->getMock();
+        $user_login->method('isUp2Date')->willReturn(true);
 
         $elements = $fields_config->getFormElements($user_login, false);
-        $this->array($elements)
-            ->hasSize(2)
-            ->hasKeys(['fieldsets', 'hiddens']);
+        $this->assertCount(2, $elements);
+        $this->assertTrue(isset($elements['fieldsets']));
+        $this->assertTrue(isset($elements['hiddens']));
 
-        $this->array($elements['fieldsets'])
-            ->hasSize(3);
+        $this->assertCount(3, $elements['fieldsets']);
 
-        $this->object($elements['fieldsets'][0])->isInstanceOf('\stdClass');
-        $this->integer($elements['fieldsets'][0]->id)->isIdenticalTo(1);
-        $this->array($elements['fieldsets'][0]->elements)->hasSize(10);
+        $this->assertInstanceOf('\stdClass', $elements['fieldsets'][0]);
+        $this->assertSame(1, $elements['fieldsets'][0]->id);
+        $this->assertCount(10, $elements['fieldsets'][0]->elements);
 
-        $this->object($elements['fieldsets'][1])->isInstanceOf('\stdClass');
-        $this->integer($elements['fieldsets'][1]->id)->isIdenticalTo(3);
-        $this->array($elements['fieldsets'][1]->elements)->hasSize(8);
+        $this->assertInstanceOf('\stdClass', $elements['fieldsets'][1]);
+        $this->assertSame(3, $elements['fieldsets'][1]->id);
+        $this->assertCount(8, $elements['fieldsets'][1]->elements);
 
         $mail = $elements['fieldsets'][1]->elements['email_adh'];
-        $this->boolean($mail->required)->isFalse(); //email is not required per default
+        $this->assertFalse($mail->required); //email is not required per default
 
-        $this->object($elements['fieldsets'][2])->isInstanceOf('\stdClass');
-        $this->integer($elements['fieldsets'][2]->id)->isIdenticalTo(2);
-        $this->array($elements['fieldsets'][2]->elements)
-            ->hasSize(4)
-            ->notHasKey('info_adh');
+        $this->assertInstanceOf('\stdClass', $elements['fieldsets'][2]);
+        $this->assertSame(2, $elements['fieldsets'][2]->id);
+        $this->assertCount(4, $elements['fieldsets'][2]->elements);
+        $this->assertFalse(isset($elements['fieldsets'][2]->elements['info_adh']));
 
         $login = $elements['fieldsets'][2]->elements['login_adh'];
-        $this->boolean($login->required)->isTrue();
+        $this->assertTrue($login->required);
         $pass  = $elements['fieldsets'][2]->elements['mdp_adh'];
-        $this->boolean($pass->required)->isTrue();
+        $this->assertTrue($pass->required);
 
-        $this->array($elements['hiddens'])
-            ->hasSize(2);
+        $this->assertCount(2, $elements['hiddens']);
 
         //form elements for self subscription
-        $no_login = new \mock\Galette\Core\Login(
-            $this->zdb,
-            new \Galette\Core\I18n()
-        );
+        $no_login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, new \Galette\Core\I18n()))
+            ->getMock();
+
         $elements = $fields_config->getFormElements($no_login, false, true);
-        $this->array($elements)
-            ->hasSize(2)
-            ->hasKeys(['fieldsets', 'hiddens']);
+        $this->assertCount(2, $elements);
+        $this->assertTrue(isset($elements['fieldsets']));
+        $this->assertTrue(isset($elements['hiddens']));
 
-        $this->array($elements['fieldsets'])
-            ->hasSize(3);
+        $this->assertCount(3, $elements['fieldsets']);
 
-        $this->object($elements['fieldsets'][0])->isInstanceOf('\stdClass');
-        $this->integer($elements['fieldsets'][0]->id)->isIdenticalTo(1);
-        $this->array($elements['fieldsets'][0]->elements)->hasSize(10);
+        $this->assertInstanceOf('\stdClass', $elements['fieldsets'][0]);
+        $this->assertSame(1, $elements['fieldsets'][0]->id);
+        $this->assertCount(10, $elements['fieldsets'][0]->elements);
 
-        $this->object($elements['fieldsets'][1])->isInstanceOf('\stdClass');
-        $this->integer($elements['fieldsets'][1]->id)->isIdenticalTo(3);
-        $this->array($elements['fieldsets'][1]->elements)->hasSize(8);
+        $this->assertInstanceOf('\stdClass', $elements['fieldsets'][1]);
+        $this->assertSame(3, $elements['fieldsets'][1]->id);
+        $this->assertCount(8, $elements['fieldsets'][1]->elements);
 
         $mail = $elements['fieldsets'][1]->elements['email_adh'];
-        $this->boolean($mail->required)->isTrue(); //email is required for self subscription
+        $this->assertTrue($mail->required); //email is required for self subscription
 
-        $this->object($elements['fieldsets'][2])->isInstanceOf('\stdClass');
-        $this->integer($elements['fieldsets'][2]->id)->isIdenticalTo(2);
-        $this->array($elements['fieldsets'][2]->elements)
-            ->hasSize(4)
-            ->notHasKey('info_adh');
+        $this->assertInstanceOf('\stdClass', $elements['fieldsets'][2]);
+        $this->assertSame(2, $elements['fieldsets'][2]->id);
+        $this->assertCount(4, $elements['fieldsets'][2]->elements);
+        $this->assertFalse(isset($elements['fieldsets'][2]->elements['info_adh']));
 
-        $this->array($elements['hiddens'])
-             ->hasSize(2);
+        $this->assertCount(2, $elements['hiddens']);
     }
 }
index 9699708a36d29b20eef248ec6a6ff4cb07b8c430..cb58a8519003e75757903f12e53516a57c1c2cb8 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\Entity\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 use Galette\GaletteTestCase;
 use Laminas\Db\Adapter\Adapter;
 
@@ -60,14 +60,12 @@ class Group extends GaletteTestCase
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
         $this->deleteGroups();
-        parent::afterTestMethod($method);
+        parent::tearDown();
     }
 
     /**
@@ -104,16 +102,16 @@ class Group extends GaletteTestCase
         $group = new \Galette\Entity\Group();
         $this->logSuperAdmin();
         $group->setLogin($this->login);
-        //$this->boolean($group->isManager($this->login))->isFalse();
-        $this->variable($group->getId())->isNull();
-        $this->integer($group->getLevel())->isIdenticalTo(0);
-        $this->variable($group->getName())->isNull();
-        $this->variable($group->getFullName())->isNull();
-        $this->variable($group->getIndentName())->isNull();
-        $this->variable($group->getMembers())->isNull();
-        $this->variable($group->getMembers())->isNull();
-        $this->array($group->getGroups())->isEmpty();
-        $this->variable($group->getParentGroup())->isNull();
+        //$this->assertFalse($group->isManager($this->login));
+        $this->assertNull($group->getId());
+        $this->assertSame(0, $group->getLevel());
+        $this->assertNull($group->getName());
+        $this->assertNull($group->getFullName());
+        $this->assertNull($group->getIndentName());
+        $this->assertNull($group->getMembers());
+        $this->assertNull($group->getMembers());
+        $this->assertEmpty($group->getGroups());
+        $this->assertNull($group->getParentGroup());
     }
 
     /**
@@ -130,31 +128,31 @@ class Group extends GaletteTestCase
         $group->setLogin($this->login);
 
         $group->setName('A group');
-        $this->boolean($group->store())->isTrue();
+        $this->assertTrue($group->store());
 
-        $this->boolean($group->isManager($this->login))->isFalse();
+        $this->assertFalse($group->isManager($this->login));
         $group_id = $group->getId();
-        $this->integer($group_id)->isGreaterThan(0);
-        $this->integer($group->getLevel())->isIdenticalTo(0);
-        $this->string($group->getName())->isIdenticalTo('A group');
-        $this->string($group->getFullName())->isIdenticalTo('A group');
-        $this->string($group->getIndentName())->isIdenticalTo('A group');
-        $this->array($group->getMembers())->isEmpty();
-        $this->integer($group->getMemberCount())->isIdenticalTo(0);
-        $this->array($group->getManagers())->isEmpty();
-        $this->array($group->getGroups())->isEmpty();
-        $this->variable($group->getParentGroup())->isNull();
+        $this->assertGreaterThan(0, $group_id);
+        $this->assertSame(0, $group->getLevel());
+        $this->assertSame('A group', $group->getName());
+        $this->assertSame('A group', $group->getFullName());
+        $this->assertSame('A group', $group->getIndentName());
+        $this->assertEmpty($group->getMembers());
+        $this->assertSame(0, $group->getMemberCount());
+        $this->assertEmpty($group->getManagers());
+        $this->assertEmpty($group->getGroups());
+        $this->assertNull($group->getParentGroup());
 
         //edit group
         $group = new \Galette\Entity\Group();
-        $this->boolean($group->load($group_id))->isTrue();
-        $this->string($group->getName())->isIdenticalTo('A group');
+        $this->assertTrue($group->load($group_id));
+        $this->assertSame('A group', $group->getName());
 
         $group->setName('A group - edited');
-        $this->boolean($group->store())->isTrue();
+        $this->assertTrue($group->store());
 
         $group = new \Galette\Entity\Group($group_id);
-        $this->string($group->getName())->isIdenticalTo('A group - edited');
+        $this->assertSame('A group - edited', $group->getName());
     }
 
     /**
@@ -171,42 +169,34 @@ class Group extends GaletteTestCase
         $group->setLogin($this->login);
 
         $group->setName('A group');
-        $this->boolean($group->store())->isTrue();
+        $this->assertTrue($group->store());
         $group_id = $group->getId();
 
         //update without changes should be ok
         $group = new \Galette\Entity\Group($group_id);
-        $this->boolean($group->store())->isTrue();
+        $this->assertTrue($group->store());
 
         //Adding another group with same name throws an exception
         $group = new \Galette\Entity\Group();
         $group->setLogin($this->login);
 
-        $this
-            ->exception(
-                function () use ($group) {
-                    $group->setName('A group');
-                    $this->boolean($group->store())->isFalse();
-                }
-            )->hasMessage('The group name you have requested already exists in the database.');
+        $this->expectExceptionMessage('The group name you have requested already exists in the database.');
+        $group->setName('A group');
+        $this->assertFalse($group->store());
 
         //update with changes should be ok
         $group = new \Galette\Entity\Group($group_id);
         $group->setName('A group - edited');
-        $this->boolean($group->store())->isTrue();
+        $this->assertTrue($group->store());
 
-        //
         $group = new \Galette\Entity\Group();
         $group->setName('Unique one');
-        $this->boolean($group->store())->isTrue();
+        $this->assertTrue($group->store());
+
         //editing using an existing name is not ok
-        $this
-            ->exception(
-                function () use ($group) {
-                    $group->setName('A group - edited');
-                    $this->boolean($group->store())->isFalse();
-                }
-            )->hasMessage('The group name you have requested already exists in the database.');
+        $this->expectExceptionMessage('The group name you have requested already exists in the database.');
+        $group->setName('A group - edited');
+        $this->assertFalse($group->store());
     }
 
     /**
@@ -221,47 +211,47 @@ class Group extends GaletteTestCase
 
         $group = new \Galette\Entity\Group();
         $group->setName('A parent group');
-        $this->boolean($group->store())->isTrue();
+        $this->assertTrue($group->store());
         $parent_id = $group->getId();
 
         $group = new \Galette\Entity\Group();
         $group->setName('A child group');
         $group->setParentGroup($parent_id);
-        $this->boolean($group->store())->isTrue();
+        $this->assertTrue($group->store());
         $child_id_1 = $group->getId();
-        $this->integer($group->getParentGroup()->getId())->isIdenticalTo($parent_id);
+        $this->assertSame($parent_id, $group->getParentGroup()->getId());
 
         $group = new \Galette\Entity\Group();
         $group->setName('Another child group');
-        $this->boolean($group->store())->isTrue();
+        $this->assertTrue($group->store());
         $child_id_2 = $group->getId();
 
         $group->setParentGroup($parent_id);
-        $this->boolean($group->store())->isTrue();
-        $this->integer($group->getParentGroup()->getId())->isIdenticalTo($parent_id);
+        $this->assertTrue($group->store());
+        $this->assertSame($parent_id, $group->getParentGroup()->getId());
 
         //non-logged-in will not see children groups
         $group = new \Galette\Entity\Group($parent_id);
         $group->setLogin($this->login);
         $children = $group->getGroups();
-        $this->array($children)->hasSize(0);
+        $this->assertCount(0, $children);
 
         //admin will not see children groups
         $group = new \Galette\Entity\Group($parent_id);
         $this->logSuperAdmin();
         $group->setLogin($this->login);
         $children = $group->getGroups();
-        $this->array($children)->hasSize(2);
+        $this->assertCount(2, $children);
 
         $group = new \Galette\Entity\Group($child_id_1);
-        $this->boolean($group->detach())->isTrue();
+        $this->assertTrue($group->detach());
 
         $group = new \Galette\Entity\Group($parent_id);
         $this->logSuperAdmin();
         $group->setLogin($this->login);
         $children = $group->getGroups();
-        $this->array($children)->hasSize(1);
-        $this->string($children[0]->getName())->isIdenticalTo('Another child group');
+        $this->assertCount(1, $children);
+        $this->assertSame('Another child group', $children[0]->getName());
     }
 
     /**
@@ -276,22 +266,22 @@ class Group extends GaletteTestCase
 
         $group = new \Galette\Entity\Group();
         $group->setName('A parent group');
-        $this->boolean($group->store())->isTrue();
+        $this->assertTrue($group->store());
         $parent_id = $group->getId();
 
         $group = new \Galette\Entity\Group();
         $group->setName('A child group');
         $group->setParentGroup($parent_id);
-        $this->boolean($group->store())->isTrue();
+        $this->assertTrue($group->store());
         $child_id_1 = $group->getId();
-        $this->integer($group->getParentGroup()->getId())->isIdenticalTo($parent_id);
+        $this->assertSame($parent_id, $group->getParentGroup()->getId());
 
         $group = new \Galette\Entity\Group($parent_id);
         $this->logSuperAdmin();
         $group->setLogin($this->login);
-        $this->boolean($group->remove())->isFalse(); //still have children, not removed
-        $this->boolean($group->load($parent_id))->isTrue();
-        $this->boolean($group->remove(true))->isTrue(); //cascade removal, all will be removed
-        $this->boolean($group->load($parent_id))->isFalse();
+        $this->assertFalse($group->remove()); //still have children, not removed
+        $this->assertTrue($group->load($parent_id));
+        $this->assertTrue($group->remove(true)); //cascade removal, all will be removed
+        $this->assertFalse($group->load($parent_id));
     }
 }
index 1ccb3143606f6ca9320379236d1809e56e19ecb2..b5e7f2934781ddd4bb4a6d5583101736e7865795 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\Entity\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * ListsConfig tests class
@@ -51,7 +51,7 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2020-05-16
  */
-class ListsConfig extends atoum
+class ListsConfig extends TestCase
 {
     private ?\Galette\Entity\ListsConfig $lists_config = null;
     private \Galette\Core\Db $zdb;
@@ -69,11 +69,9 @@ class ListsConfig extends atoum
     /**
      * Set up tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $this->zdb = new \Galette\Core\Db();
 
@@ -94,14 +92,12 @@ class ListsConfig extends atoum
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
         if (TYPE_DB === 'mysql') {
-            $this->array($this->zdb->getWarnings())->isIdenticalTo([]);
+            $this->assertSame([], $this->zdb->getWarnings());
         }
         $this->resetListsConfig();
     }
@@ -118,7 +114,7 @@ class ListsConfig extends atoum
             $new_list[] = $this->lists_config->getField($key);
         }
 
-        $this->boolean($this->lists_config->setListFields($new_list))->isTrue();
+        $this->assertTrue($this->lists_config->setListFields($new_list));
     }
 
     /**
@@ -131,18 +127,18 @@ class ListsConfig extends atoum
         $this->lists_config->load();
 
         $visible = $this->lists_config->getVisibility('nom_adh');
-        $this->integer($visible)->isIdenticalTo(\Galette\Entity\FieldsConfig::NOBODY);
+        $this->assertSame(\Galette\Entity\FieldsConfig::NOBODY, $visible);
 
         //must be the same than nom_adh
         $visible = $this->lists_config->getVisibility('list_adh_name');
-        $this->integer($visible)->isIdenticalTo(\Galette\Entity\FieldsConfig::USER_WRITE);
+        $this->assertSame(\Galette\Entity\FieldsConfig::USER_WRITE, $visible);
 
         $visible = $this->lists_config->getVisibility('id_statut');
-        $this->integer($visible)->isIdenticalTo(\Galette\Entity\FieldsConfig::STAFF);
+        $this->assertSame(\Galette\Entity\FieldsConfig::STAFF, $visible);
 
         //must be the same than id_statut
         $visible = $this->lists_config->getVisibility('list_adh_contribstatus');
-        $this->integer($visible)->isIdenticalTo(\Galette\Entity\FieldsConfig::STAFF);
+        $this->assertSame(\Galette\Entity\FieldsConfig::STAFF, $visible);
     }
 
     /**
@@ -159,12 +155,12 @@ class ListsConfig extends atoum
         $fields = $lists_config->getCategorizedFields();
 
         $list = $lists_config->getListedFields();
-        $this->array($list)->hasSize(6);
+        $this->assertCount(6, $list);
 
         $expecteds = $this->default_lists;
         foreach ($expecteds as $k => $expected) {
-            $this->string($list[$k]['field_id'])->isIdenticalTo($expected);
-            $this->integer($list[$k]['list_position'])->isIdenticalTo($k);
+            $this->assertSame($expected, $list[$k]['field_id']);
+            $this->assertSame($k, $list[$k]['list_position']);
         }
 
         $expecteds = [
@@ -181,30 +177,30 @@ class ListsConfig extends atoum
         foreach ($expecteds as $key) {
             $new_list[] = $lists_config->getField($key);
         }
-        $this->boolean($lists_config->setListFields($new_list))->isTrue();
+        $this->assertTrue($lists_config->setListFields($new_list));
 
         $list = $lists_config->getListedFields();
-        $this->array($list)->hasSize(7);
+        $this->assertCount(7, $list);
 
         foreach ($expecteds as $k => $expected) {
-            $this->string($list[$k]['field_id'])->isIdenticalTo($expected);
-            $this->integer($list[$k]['list_position'])->isIdenticalTo($k);
+            $this->assertSame($expected, $list[$k]['field_id']);
+            $this->assertSame($k, $list[$k]['list_position']);
         }
 
         $field = $lists_config->getField('pseudo_adh');
-        $this->integer($field['list_position'])->isIdenticalTo(-1);
-        $this->boolean($field['list_visible'])->isFalse();
+        $this->assertSame(-1, $field['list_position']);
+        $this->assertFalse($field['list_visible']);
 
         $field = $lists_config->getField('date_modif_adh');
-        $this->integer($field['list_position'])->isIdenticalTo(-1);
-        $this->boolean($field['list_visible'])->isFalse();
+        $this->assertSame(-1, $field['list_position']);
+        $this->assertFalse($field['list_visible']);
 
         // copied from FieldsConfig::testSetFields to ensure it works as excpeted from here.
         //town
         $town = &$fields[\Galette\Entity\FieldsCategories::ADH_CATEGORY_CONTACT][2]; //3 in FieldsConfig but 2 here.
-        $this->string($town['field_id'])->isIdenticalTo('ville_adh');
-        $this->boolean($town['required'])->isTrue();
-        $this->integer($town['visible'])->isIdenticalTo(\Galette\Entity\FieldsConfig::USER_WRITE);
+        $this->assertSame('ville_adh', $town['field_id']);
+        $this->assertTrue($town['required']);
+        $this->assertSame(\Galette\Entity\FieldsConfig::USER_WRITE, $town['visible']);
 
         $town['required'] = false;
         $town['visible'] = \Galette\Entity\FieldsConfig::NOBODY;
@@ -216,17 +212,17 @@ class ListsConfig extends atoum
         $gsm['category'] = \Galette\Entity\FieldsCategories::ADH_CATEGORY_IDENTITY;
         $fields[\Galette\Entity\FieldsCategories::ADH_CATEGORY_IDENTITY][] = $gsm;
 
-        $this->boolean($lists_config->setFields($fields))->isTrue();
+        $this->assertTrue($lists_config->setFields($fields));
 
         $lists_config->load();
         $fields = $lists_config->getCategorizedFields();
 
         $town = $fields[\Galette\Entity\FieldsCategories::ADH_CATEGORY_CONTACT][2]; //3 in FieldsConfig but 2 here.
-        $this->boolean($town['required'])->isFalse();
-        $this->integer($town['visible'])->isIdenticalTo(\Galette\Entity\FieldsConfig::NOBODY);
+        $this->assertFalse($town['required']);
+        $this->assertSame(\Galette\Entity\FieldsConfig::NOBODY, $town['visible']);
 
         $gsm2 = $fields[\Galette\Entity\FieldsCategories::ADH_CATEGORY_IDENTITY][11]; //13 in FieldsConfig but 11 here
-        $this->array($gsm2)->isIdenticalTo($gsm);
+        $this->assertSame($gsm, $gsm2);
         // /copied from FieldsConfig::testSetFields to ensure it works as expected from here.
     }
 
@@ -241,40 +237,35 @@ class ListsConfig extends atoum
         $lists_config->load();
 
         //admin
-        $superadmin_login = new \mock\Galette\Core\Login(
-            $this->zdb,
-            new \Galette\Core\I18n()
-        );
-        $this->calling($superadmin_login)->isSuperAdmin = true;
+        $superadmin_login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, new \Galette\Core\I18n()))
+            ->onlyMethods(array('isSuperAdmin'))
+            ->getMock();
+        $superadmin_login->method('isSuperAdmin')->willReturn(true);
 
         $expecteds = $this->default_lists;
         $elements = $lists_config->getDisplayElements($superadmin_login);
-        $this->array($elements)
-            ->hasSize(count($this->default_lists));
+        $this->assertCount(count($this->default_lists), $elements);
 
         //admin
-        $admin_login = new \mock\Galette\Core\Login(
-            $this->zdb,
-            new \Galette\Core\I18n()
-        );
-        $this->calling($admin_login)->isAdmin = true;
+        $admin_login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, new \Galette\Core\I18n()))
+            ->onlyMethods(array('isAdmin'))
+            ->getMock();
+        $admin_login->method('isAdmin')->willReturn(true);
 
-        $expecteds = $this->default_lists;
         $elements = $lists_config->getDisplayElements($admin_login);
-        $this->array($elements)
-            ->hasSize(count($this->default_lists));
+        $this->assertCount(count($this->default_lists), $elements);
 
         //staff
-        $staff_login = new \mock\Galette\Core\Login(
-            $this->zdb,
-            new \Galette\Core\I18n()
-        );
-        $this->calling($staff_login)->isStaff = true;
+        $staff_login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, new \Galette\Core\I18n()))
+            ->onlyMethods(array('isStaff'))
+            ->getMock();
+        $staff_login->method('isStaff')->willReturn(true);
 
-        $expecteds = $this->default_lists;
         $elements = $lists_config->getDisplayElements($staff_login);
-        $this->array($elements)
-             ->hasSize(count($this->default_lists));
+        $this->assertCount(count($this->default_lists), $elements);
 
         //following tests will have lower ACLS (cannot see status)
         $expecteds = [
@@ -288,50 +279,47 @@ class ListsConfig extends atoum
             $new_list[] = $lists_config->getField($key);
         }
 
-
         //group manager
-        $manager_login = new \mock\Galette\Core\Login(
-            $this->zdb,
-            new \Galette\Core\I18n()
-        );
-        $this->calling($manager_login)->isGroupManager = true;
+        $manager_login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, new \Galette\Core\I18n()))
+            ->onlyMethods(array('isGroupManager'))
+            ->getMock();
+        $manager_login->method('isGroupManager')->willReturn(true);
 
         $elements = $lists_config->getDisplayElements($manager_login);
-        $this->array($elements)
-            ->hasSize(count($new_list));
+        $this->assertCount(count($new_list), $elements);
 
-        //to keep last know rank. May switch from 2 to 6 because of bield visibility.
+        //to keep last know rank. May switch from 2 to 6 because of field visibility.
         $last_ok = -1;
         foreach ($expecteds as $k => $expected) {
-            $this->string($new_list[$k]['field_id'])->isIdenticalTo($expected);
+            $this->assertSame($expected, $new_list[$k]['field_id']);
             if ($new_list[$k]['list_position'] != $k - 1) {
-                $this->integer($new_list[$k]['list_position'])->isGreaterThan($last_ok);
+                $this->assertGreaterThan($last_ok, $new_list[$k]['list_position']);
                 $last_ok = $new_list[$k]['list_position'];
             } else {
-                $this->integer($new_list[$k]['list_position'])->isIdenticalTo($k);
+                $this->assertSame($k, $new_list[$k]['list_position']);
             }
         }
 
         //simplemember
-        $user_login = new \mock\Galette\Core\Login(
-            $this->zdb,
-            new \Galette\Core\I18n()
-        );
-        $this->calling($user_login)->isUp2Date = true;
+        $user_login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, new \Galette\Core\I18n()))
+            ->onlyMethods(array('isUp2Date'))
+            ->getMock();
+        $user_login->method('isUp2Date')->willReturn(true);
 
         $elements = $lists_config->getDisplayElements($user_login);
-        $this->array($elements)
-            ->hasSize(count($new_list));
+        $this->assertCount(count($new_list), $elements);
 
-        //to keep last know rank. May switch from 2 to 6 because of bield visibility.
+        //to keep last know rank. May switch from 2 to 6 because of field visibility.
         $last_ok = -1;
         foreach ($expecteds as $k => $expected) {
-            $this->string($new_list[$k]['field_id'])->isIdenticalTo($expected);
+            $this->assertSame($expected, $new_list[$k]['field_id']);
             if ($new_list[$k]['list_position'] != $k - 1) {
-                $this->integer($new_list[$k]['list_position'])->isGreaterThan($last_ok);
+                $this->assertGreaterThan($last_ok, $new_list[$k]['list_position']);
                 $last_ok = $new_list[$k]['list_position'];
             } else {
-                $this->integer($new_list[$k]['list_position'])->isIdenticalTo($k);
+                $this->assertSame($k, $new_list[$k]['list_position']);
             }
         }
     }
index 1f2ef78421462736430a7b885bf112113f3a03e4..359f44a02d7e5a7316227308348e69d98678c985 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\Entity\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Payment type tests
@@ -51,7 +51,7 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2019-12-15
  */
-class PaymentType extends atoum
+class PaymentType extends TestCase
 {
     private \Galette\Core\Db $zdb;
     private \Galette\Core\Preferences $preferences;
@@ -62,11 +62,9 @@ class PaymentType extends atoum
     /**
      * Set up tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $this->zdb = new \Galette\Core\Db();
         $this->preferences = new \Galette\Core\Preferences($this->zdb);
@@ -77,20 +75,18 @@ class PaymentType extends atoum
 
         $types = new \Galette\Repository\PaymentTypes($this->zdb, $this->preferences, $this->login);
         $res = $types->installInit(false);
-        $this->boolean($res)->isTrue();
+        $this->assertTrue($res);
     }
 
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
         if (TYPE_DB === 'mysql') {
-            $this->array($this->zdb->getWarnings())->isIdenticalTo([]);
+            $this->assertSame([], $this->zdb->getWarnings());
         }
         $this->deletePaymentType();
     }
@@ -128,7 +124,7 @@ class PaymentType extends atoum
         $type = new \Galette\Entity\PaymentType($this->zdb);
 
         $type->name = 'Test payment type';
-        $this->boolean($type->store())->isTrue();
+        $this->assertTrue($type->store());
 
         $select = $this->zdb->select(\Galette\Core\L10n::TABLE);
         $select->where(
@@ -137,20 +133,19 @@ class PaymentType extends atoum
             )
         );
         $results = $this->zdb->execute($select);
-        $result = $results->current();
+        $result = (array)$results->current();
 
-        $this->array((array)$result)
-            ->string['text_orig']->isIdenticalTo('Test payment type');
+        $this->assertSame('Test payment type', $result['text_orig']);
 
         $id = $type->id;
         $this->remove[] = $id;
 
         $type = new \Galette\Entity\PaymentType($this->zdb, $id);
         $type->name = 'Changed test payment type';
-        $this->boolean($type->store())->isTrue();
+        $this->assertTrue($type->store());
 
         $type = new \Galette\Entity\PaymentType($this->zdb, $id);
-        $this->string($type->getName())->isIdenticalTo('Changed test payment type');
+        $this->assertSame('Changed test payment type', $type->getName());
 
         $select = $this->zdb->select(\Galette\Core\L10n::TABLE);
         $select->where(
@@ -159,19 +154,15 @@ class PaymentType extends atoum
             )
         );
         $results = $this->zdb->execute($select);
-        $this->integer(count($results))->isIdenticalTo(count($this->i18n->getArrayList()));
+        $this->assertSame(count($this->i18n->getArrayList()), count($results));
 
         $type = new \Galette\Entity\PaymentType($this->zdb, \Galette\Entity\PaymentType::CASH);
-        $this->exception(
-            function () use ($type) {
-                $type->remove();
-            }
-        )
-            ->hasMessage('You cannot delete system payment types!')
-            ->isInstanceOf('\RuntimeException');
+        $this->expectException(\RuntimeException::class);
+        $this->expectExceptionMessage('You cannot delete system payment types!');
+        $type->remove();
 
         $type = new \Galette\Entity\PaymentType($this->zdb, $id);
-        $this->boolean($type->remove())->isTrue();
+        $this->assertTrue($type->remove());
 
         $select = $this->zdb->select(\Galette\Core\L10n::TABLE);
         $select->where(
@@ -180,6 +171,6 @@ class PaymentType extends atoum
             )
         );
         $results = $this->zdb->execute($select);
-        $this->integer($results->count())->isIdenticalTo(0);
+        $this->assertSame(0, $results->count());
     }
 }
index a4d3dff8a2bb620dcc7dcae5559c16c762cba06c..978abb1d4888ee2dba0cd22bbc59584e331512c1 100644 (file)
@@ -61,17 +61,15 @@ class PdfModel extends GaletteTestCase
     /**
      * Set up tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
-        parent::beforeTestMethod($method);
+        parent::setUp();
 
         $models = new \Galette\Repository\PdfModels($this->zdb, $this->preferences, $this->login);
         $res = $models->installInit(false);
-        $this->boolean($res)->isTrue();
+        $this->assertTrue($res);
 
         $this->adh = new \Galette\Entity\Adherent($this->zdb);
         $this->adh->setDependencies(
@@ -85,13 +83,11 @@ class PdfModel extends GaletteTestCase
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
-        parent::afterTestMethod($method);
+        parent::tearDown();
 
         $delete = $this->zdb->delete(\Galette\Entity\Contribution::TABLE);
         $delete->where(['info_cotis' => 'FAKER' . $this->seed]);
@@ -134,10 +130,10 @@ class PdfModel extends GaletteTestCase
             'date_now'           => '/{DATE_NOW}/',
             'login_uri'          => '/{LOGIN_URI}/'
         ];
-        $this->array($model->getPatterns())->isIdenticalTo($main_expected);
+        $this->assertSame($main_expected, $model->getPatterns());
 
         $model = new \Galette\Entity\PdfMain($this->zdb, $this->preferences);
-        $this->array($model->getPatterns())->isIdenticalTo($main_expected);
+        $this->assertSame($main_expected, $model->getPatterns());
 
         $expected = $main_expected + [
             'adh_title'         => '/{TITLE_ADH}/',
@@ -173,7 +169,7 @@ class PdfModel extends GaletteTestCase
             '_adh_email'        => '/{MAIL_ADH}/',
         ];
         $model = new \Galette\Entity\PdfAdhesionFormModel($this->zdb, $this->preferences);
-        $this->array($model->getPatterns())->isIdenticalTo($expected);
+        $this->assertSame($expected, $model->getPatterns());
 
         $expected += [
             'contrib_label'     => '/{CONTRIB_LABEL}/',
@@ -202,10 +198,10 @@ class PdfModel extends GaletteTestCase
             'deadline'           => '/{DEADLINE}/'
         ];
         $model = new \Galette\Entity\PdfInvoice($this->zdb, $this->preferences);
-        $this->array($model->getPatterns())->isIdenticalTo($expected);
+        $this->assertSame($expected, $model->getPatterns());
 
         $model = new \Galette\Entity\PdfReceipt($this->zdb, $this->preferences);
-        $this->array($model->getPatterns())->isIdenticalTo($expected);
+        $this->assertSame($expected, $model->getPatterns());
     }
 
     /**
@@ -213,7 +209,7 @@ class PdfModel extends GaletteTestCase
      *
      * @return array
      */
-    protected function typesProvider(): array
+    public static function typesProvider(): array
     {
         return [
             [
@@ -246,7 +242,7 @@ class PdfModel extends GaletteTestCase
      */
     public function testGetypeClass($type, $expected)
     {
-        $this->string(\Galette\Entity\PdfModel::getTypeClass($type))->isIdenticalTo($expected);
+        $this->assertSame($expected, \Galette\Entity\PdfModel::getTypeClass($type));
     }
 
     /**
@@ -271,14 +267,15 @@ class PdfModel extends GaletteTestCase
         $stored = $adf->store($field_data);
         $error_detected = $adf->getErrors();
         $warning_detected = $adf->getWarnings();
-        $this->boolean($stored)->isTrue(
+        $this->assertTrue(
+            $stored,
             implode(
                 ' ',
                 $adf->getErrors() + $adf->getWarnings()
             )
         );
-        $this->array($error_detected)->isEmpty(implode(' ', $adf->getErrors()));
-        $this->array($warning_detected)->isEmpty(implode(' ', $adf->getWarnings()));
+        $this->assertEmpty($error_detected, implode(' ', $adf->getErrors()));
+        $this->assertEmpty($warning_detected, implode(' ', $adf->getWarnings()));
 
         $field_data = [
             'form_name'         => 'contrib',
@@ -295,14 +292,15 @@ class PdfModel extends GaletteTestCase
         $stored = $cdf->store($field_data);
         $error_detected = $cdf->getErrors();
         $warning_detected = $cdf->getWarnings();
-        $this->boolean($stored)->isTrue(
+        $this->assertTrue(
+            $stored,
             implode(
                 ' ',
                 $cdf->getErrors() + $cdf->getWarnings()
             )
         );
-        $this->array($error_detected)->isEmpty(implode(' ', $cdf->getErrors()));
-        $this->array($warning_detected)->isEmpty(implode(' ', $cdf->getWarnings()));
+        $this->assertEmpty($error_detected, implode(' ', $cdf->getErrors()));
+        $this->assertEmpty($warning_detected, implode(' ', $cdf->getWarnings()));
 
         //prepare model
         $pk = \Galette\Entity\PdfModel::PK;
@@ -356,40 +354,46 @@ class PdfModel extends GaletteTestCase
         $this->createPdfContribution($cdf);
         $model->setContribution($this->contrib);
 
-        $this->string($model->hheader)->isIdenticalTo("<table>
+        $this->assertSame(
+            "<table>
     <tr>
         <td id=\"pdf_assoname\"><strong id=\"asso_name\">Galette</strong><br/></td>
         <td id=\"pdf_logo\"><img src=\"http:///logo\" width=\"129\" height=\"60\"/></td>
     </tr>
-</table>");
+</table>",
+            $model->hheader
+        );
 
-        $this->string($model->hfooter)->isIdenticalTo('<div id="pdf_footer">
+        $this->assertSame(
+            '<div id="pdf_footer">
     Association Galette - Galette
 Palais des Papes
 Au milieu
 84000 Avignon - France<br/>
     
-</div>');
+</div>',
+            $model->hfooter
+        );
 
-        $this->string($model->hbody)->isEqualTo(
+        $this->assertSame(
             'name: DURAND René login: arthur.hamon birthdate: 1937-12-26 dynlabel: Dynamic text field dynvalue: ' .
             'My value (: ' .
             '- enddate: ' . $this->contrib->end_date . ' amount: 92 (ninety-two) dynlabel: Dynamic date field ' .
-            'dynvalue: 2020-12-03'
+            'dynvalue: 2020-12-03',
+            $model->hbody
         );
 
         $legend = $model->getLegend();
-        $this->array($legend)
-            ->hasSize(3)
-            ->hasKeys(['main', 'member', 'contribution']);
-
-        $this->array($legend['main']['patterns'])->hasSize(8);
-        $this->array($legend['member']['patterns'])
-            ->hasSize(28)
-            ->hasKeys(['label_dynfield_' . $adf->getId() . '_adh', 'dynfield_' . $adf->getId() . '_adh']);
-        $this->array($legend['contribution']['patterns'])
-            ->hasSize(14)
-            ->hasKeys(['label_dynfield_' . $cdf->getId() . '_contrib', 'dynfield_' . $cdf->getId() . '_contrib']);
+        $this->assertCount(3, $legend);
+        $this->assertArrayHasKey('main', $legend);
+        $this->assertArrayHasKey('member', $legend);
+        $this->assertArrayHasKey('contribution', $legend);
+
+        $this->assertCount(8, $legend['main']['patterns']);
+        $this->assertCount(28, $legend['member']['patterns']);
+        $this->assertTrue(isset($legend['member']['patterns']['label_dynfield_' . $adf->getId() . '_adh']));
+        $this->assertCount(14, $legend['contribution']['patterns']);
+        $this->assertTrue(isset($legend['contribution']['patterns']['label_dynfield_' . $cdf->getId() . '_contrib']));
     }
 
     /**
@@ -406,10 +410,10 @@ Au milieu
         if (is_array($check)) {
             var_dump($check);
         }
-        $this->boolean($check)->isTrue();
+        $this->assertTrue($check);
 
         $store = $adh->store();
-        $this->boolean($store)->isTrue();
+        $this->assertTrue($store);
         return $adh;
     }
 
@@ -455,12 +459,12 @@ Au milieu
         $model = new \Galette\Entity\PdfInvoice($this->zdb, $this->preferences);
 
         $orig_title = $model->title;
-        $this->string($orig_title)->isIdenticalTo('_T("Invoice") {CONTRIBUTION_YEAR}-{CONTRIBUTION_ID}');
+        $this->assertSame('_T("Invoice") {CONTRIBUTION_YEAR}-{CONTRIBUTION_ID}', $orig_title);
 
         $model->title = 'Another test';
-        $this->boolean($model->store())->isTrue();
+        $this->assertTrue($model->store());
 
         $model = new \Galette\Entity\PdfInvoice($this->zdb, $this->preferences);
-        $this->string($model->title)->isIdenticalTo('Another test');
+        $this->assertSame('Another test', $model->title);
     }
 }
diff --git a/tests/Galette/Entity/tests/units/SavedSeach.php b/tests/Galette/Entity/tests/units/SavedSeach.php
deleted file mode 100644 (file)
index 7cf51b5..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-<?php
-
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * Saved search tests
- *
- * PHP version 5
- *
- * Copyright © 2019-2023 The Galette Team
- *
- * This file is part of Galette (http://galette.tuxfamily.org).
- *
- * Galette is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Galette is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Galette. If not, see <http://www.gnu.org/licenses/>.
- *
- * @category  Entity
- * @package   GaletteTests
- *
- * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2019-2023 The Galette Team
- * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
- * @version   SVN: $Id$
- * @link      http://galette.tuxfamily.org
- * @since     2019-05-08
- */
-
-namespace Galette\Entity\test\units;
-
-use atoum;
-use Laminas\Db\Adapter\Adapter;
-
-/**
- * Saved search tests
- *
- * @category  Entity
- * @name      SavedSearch
- * @package   GaletteTests
- * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2019-2023 The Galette Team
- * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
- * @link      http://galette.tuxfamily.org
- * @since     2019-05-08
- */
-class SavedSearch extends atoum
-{
-    private \Galette\Core\Db $zdb;
-    private \Galette\Core\I18n $i18n;
-    private \Galette\Core\Login $login;
-
-    /**
-     * Set up tests
-     *
-     * @param string $method Calling method
-     *
-     * @return void
-     */
-    public function beforeTestMethod($method)
-    {
-        $this->zdb = new \Galette\Core\Db();
-        $this->i18n = new \Galette\Core\I18n();
-
-        $this->login = new \mock\Galette\Core\Login($this->zdb, $this->i18n);
-        $this->calling($this->login)->isLogged = true;
-        $this->calling($this->login)->isSuperAdmin = true;
-        $this->calling($this->login)->__get = 0; //to get login id
-    }
-
-    /**
-     * Tear down tests
-     *
-     * @param string $method Calling method
-     *
-     * @return void
-     */
-    public function afterTestMethod($method)
-    {
-        if (TYPE_DB === 'mysql') {
-            $this->array($this->zdb->getWarnings())->isIdenticalTo([]);
-        }
-        $this->deleteCreated();
-    }
-
-    /**
-     * Delete status
-     *
-     * @return void
-     */
-    private function deleteCreated()
-    {
-        $this->zdb->db->query(
-            'TRUNCATE TABLE ' . PREFIX_DB . \Galette\Entity\SavedSearch::TABLE,
-            \Laminas\Db\Adapter\Adapter::QUERY_MODE_EXECUTE
-        );
-    }
-
-    /**
-     * Test saved search
-     *
-     * @return void
-     */
-    public function testSave()
-    {
-        global $i18n, $translator; // globals :(
-        $i18n = $this->i18n;
-        $i18n->changeLanguage('en_US');
-
-        $saved = new \Galette\Entity\SavedSearch($this->zdb, $this->login);
-        $searches = new \Galette\Repository\SavedSearches($this->zdb, $this->login);
-
-        $post = [
-            'parameters'    => [
-                'filter_str'        => '',
-                'field_filter'      => 0,
-                'membership_filter' => 0,
-                'filter_account'    => 0,
-                'roup_filter'       => 0,
-                'email_filter'      => 5,
-                'nbshow'            => 10
-            ],
-            'form'          => 'Adherent',
-            'name'          => 'Simple search'
-        ];
-
-        $errored = $post;
-        unset($errored['form']);
-        $this->boolean($saved->check($errored))->isFalse();
-        $this->array($saved->getErrors())->isIdenticalTo(['form' => 'Form is mandatory!']);
-
-        //store search
-        $this->boolean($saved->check($post))->isTrue();
-        $this->boolean($saved->store())->isTrue();
-        $this->array($searches->getList(true))->hasSize(1);
-        //store again, got a duplicate
-        $this->boolean($saved->store())->isTrue();
-        $this->array($searches->getList(true))->hasSize(2);
-    }
-}
diff --git a/tests/Galette/Entity/tests/units/SavedSearch.php b/tests/Galette/Entity/tests/units/SavedSearch.php
new file mode 100644 (file)
index 0000000..d7f1942
--- /dev/null
@@ -0,0 +1,147 @@
+<?php
+
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Saved search tests
+ *
+ * PHP version 5
+ *
+ * Copyright © 2019-2023 The Galette Team
+ *
+ * This file is part of Galette (http://galette.tuxfamily.org).
+ *
+ * Galette is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Galette is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Galette. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category  Entity
+ * @package   GaletteTests
+ *
+ * @author    Johan Cwiklinski <johan@x-tnd.be>
+ * @copyright 2019-2023 The Galette Team
+ * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
+ * @version   SVN: $Id$
+ * @link      http://galette.tuxfamily.org
+ * @since     2019-05-08
+ */
+
+namespace Galette\Entity\test\units;
+
+use PHPUnit\Framework\TestCase;
+use Laminas\Db\Adapter\Adapter;
+
+/**
+ * Saved search tests
+ *
+ * @category  Entity
+ * @name      SavedSearch
+ * @package   GaletteTests
+ * @author    Johan Cwiklinski <johan@x-tnd.be>
+ * @copyright 2019-2023 The Galette Team
+ * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
+ * @link      http://galette.tuxfamily.org
+ * @since     2019-05-08
+ */
+class SavedSearch extends TestCase
+{
+    private \Galette\Core\Db $zdb;
+    private \Galette\Core\I18n $i18n;
+    private \Galette\Core\Login $login;
+
+    /**
+     * Set up tests
+     *
+     * @return void
+     */
+    public function setUp(): void
+    {
+        $this->zdb = new \Galette\Core\Db();
+        $this->i18n = new \Galette\Core\I18n();
+
+        $this->login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, new \Galette\Core\I18n()))
+            ->onlyMethods(array('isLogged', 'isSuperAdmin', '__get'))
+            ->getMock();
+        $this->login->method('isLogged')->willReturn(true);
+        $this->login->method('isSuperAdmin')->willReturn(true);
+        $this->login->method('__get')->willReturn(0);
+    }
+
+    /**
+     * Tear down tests
+     *
+     * @return void
+     */
+    public function tearDown(): void
+    {
+        if (TYPE_DB === 'mysql') {
+            $this->assertSame([], $this->zdb->getWarnings());
+        }
+        $this->deleteCreated();
+    }
+
+    /**
+     * Delete status
+     *
+     * @return void
+     */
+    private function deleteCreated()
+    {
+        $this->zdb->db->query(
+            'TRUNCATE TABLE ' . PREFIX_DB . \Galette\Entity\SavedSearch::TABLE,
+            \Laminas\Db\Adapter\Adapter::QUERY_MODE_EXECUTE
+        );
+    }
+
+    /**
+     * Test saved search
+     *
+     * @return void
+     */
+    public function testSave()
+    {
+        global $i18n, $translator; // globals :(
+        $i18n = $this->i18n;
+        $i18n->changeLanguage('en_US');
+
+        $saved = new \Galette\Entity\SavedSearch($this->zdb, $this->login);
+        $searches = new \Galette\Repository\SavedSearches($this->zdb, $this->login);
+
+        $post = [
+            'parameters'    => [
+                'filter_str'        => '',
+                'field_filter'      => 0,
+                'membership_filter' => 0,
+                'filter_account'    => 0,
+                'roup_filter'       => 0,
+                'email_filter'      => 5,
+                'nbshow'            => 10
+            ],
+            'form'          => 'Adherent',
+            'name'          => 'Simple search'
+        ];
+
+        $errored = $post;
+        unset($errored['form']);
+        $this->assertFalse($saved->check($errored));
+        $this->assertSame(['form' => 'Form is mandatory!'], $saved->getErrors());
+
+        //store search
+        $this->assertTrue($saved->check($post));
+        $this->assertTrue($saved->store());
+        $this->assertCount(1, $searches->getList(true));
+        //store again, got a duplicate
+        $this->assertTrue($saved->store());
+        $this->assertCount(2, $searches->getList(true));
+    }
+}
index a1b611fa6c284232144eb747413b7522cc076b23..a65fdd6ba1cb2904ee87c64964c1f64ec3f94dd9 100644 (file)
@@ -58,13 +58,11 @@ class Social extends GaletteTestCase
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
-        parent::afterTestMethod($method);
+        parent::tearDown();
 
         $this->deleteSocials();
 
@@ -100,22 +98,22 @@ class Social extends GaletteTestCase
         $social = new \Galette\Entity\Social($this->zdb);
 
         //setters and getters
-        $this->object($social->setType('mytype'))->isInstanceOf('\Galette\Entity\Social');
-        $this->string($social->type)->isIdenticalTo('mytype');
+        $this->assertInstanceOf(\Galette\Entity\Social::class, $social->setType('mytype'));
+        $this->assertSame('mytype', $social->type);
 
-        $this->object($social->setUrl('myurl'))->isInstanceOf('\Galette\Entity\Social');
-        $this->string($social->url)->isIdenticalTo('myurl');
+        $this->assertInstanceOf(\Galette\Entity\Social::class, $social->setUrl('myurl'));
+        $this->assertSame('myurl', $social->url);
 
         //null as member id for Galette main preferences
-        $this->object($social->setLinkedMember(null))->isInstanceOf('\Galette\Entity\Social');
-        $this->variable($social->id_adh)->isNull();
-        $this->variable($social->member)->isNull();
+        $this->assertInstanceOf(\Galette\Entity\Social::class, $social->setLinkedMember(null));
+        $this->assertNull($social->id_adh);
+        $this->assertNull($social->member);
 
         $this->getMemberTwo();
-        $this->object($social->setLinkedMember($this->adh->id))->isInstanceOf(\Galette\Entity\Social::class);
-        $this->integer($social->id_adh)->isIdenticalTo($this->adh->id);
-        $this->object($social->member)->isInstanceOf(\Galette\Entity\Adherent::class);
-        $this->string($social->member->name)->isIdenticalTo($this->adh->name);
+        $this->assertInstanceOf(\Galette\Entity\Social::class, $social->setLinkedMember($this->adh->id));
+        $this->assertSame($this->adh->id, $social->id_adh);
+        $this->assertInstanceOf(\Galette\Entity\Adherent::class, $social->member);
+        $this->assertSame($this->adh->name, $social->member->name);
     }
 
     /**
@@ -126,12 +124,12 @@ class Social extends GaletteTestCase
     public function testGetSystemTypes()
     {
         $social = new \Galette\Entity\Social($this->zdb);
-        $this->array($social->getSystemTypes())->hasSize(9);
-        $this->array($social->getSystemTypes())->isIdenticalTo($social->getSystemTypes(true));
-        $this->array($social->getSystemTypes(false))->hasSize(9);
+        $this->assertCount(9, $social->getSystemTypes());
+        $this->assertSame($social->getSystemTypes(true), $social->getSystemTypes());
+        $this->assertCount(9, $social->getSystemTypes(false));
 
-        $this->string($social->getSystemType(\Galette\Entity\Social::TWITTER))->isIdenticalTo('Twitter');
-        $this->string($social->getSystemType(\Galette\Entity\Social::TWITTER, false))->isIdenticalTo('twitter');
+        $this->assertSame('Twitter', $social->getSystemType(\Galette\Entity\Social::TWITTER));
+        $this->assertSame('twitter', $social->getSystemType(\Galette\Entity\Social::TWITTER, false));
     }
 
     /**
@@ -141,58 +139,58 @@ class Social extends GaletteTestCase
      */
     public function testGetListForMember(): void
     {
-        $this->array(\Galette\Entity\Social::getListForMember(null))->isEmpty();
+        $this->assertEmpty(\Galette\Entity\Social::getListForMember(null));
 
         $this->getMemberTwo();
-        $this->array(\Galette\Entity\Social::getListForMember($this->adh->id))->isEmpty();
+        $this->assertEmpty(\Galette\Entity\Social::getListForMember($this->adh->id));
 
         $social = new \Galette\Entity\Social($this->zdb);
-        $this->boolean(
+        $this->assertTrue(
             $social
                 ->setType(\Galette\Entity\Social::MASTODON)
                 ->setUrl('mastodon URL')
                 ->setLinkedMember($this->adh->id)
                 ->store()
-        )->isTrue();
+        );
 
         $socials = \Galette\Entity\Social::getListForMember($this->adh->id);
-        $this->array($socials)->HasSize(1);
+        $this->assertCount(1, $socials);
         $social = array_pop($socials);
-        $this->string($social->type)->isIdenticalTo(\Galette\Entity\Social::MASTODON);
-        $this->integer($social->id_adh)->isIdenticalTo($this->adh->id);
-        $this->string($social->url)->isIdenticalTo('mastodon URL');
+        $this->assertSame(\Galette\Entity\Social::MASTODON, $social->type);
+        $this->assertSame($this->adh->id, $social->id_adh);
+        $this->assertSame('mastodon URL', $social->url);
 
         $social = new \Galette\Entity\Social($this->zdb);
-        $this->boolean(
+        $this->assertTrue(
             $social
                 ->setType(\Galette\Entity\Social::MASTODON)
                 ->setUrl('Galette mastodon URL')
                 ->setLinkedMember(null)
                 ->store()
-        )->isTrue();
+        );
 
         $social = new \Galette\Entity\Social($this->zdb);
-        $this->boolean(
+        $this->assertTrue(
             $social
                 ->setType(\Galette\Entity\Social::JABBER)
                 ->setUrl('Galette jabber')
                 ->setLinkedMember(null)
                 ->store()
-        )->isTrue();
+        );
 
         $social = new \Galette\Entity\Social($this->zdb);
-        $this->boolean(
+        $this->assertTrue(
             $social
                 ->setType(\Galette\Entity\Social::MASTODON)
                 ->setUrl('Another Galette mastodon URL')
                 ->setLinkedMember(null)
                 ->store()
-        )->isTrue();
+        );
 
-        $this->array(\Galette\Entity\Social::getListForMember(null))->hasSize(3);
-        $this->array(\Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::JABBER))->hasSize(1);
+        $this->assertCount(3, \Galette\Entity\Social::getListForMember(null));
+        $this->assertCount(1, \Galette\Entity\Social::getListForMember(null, \Galette\Entity\Social::JABBER));
 
-        $this->boolean($social->remove())->isTrue();
-        $this->array(\Galette\Entity\Social::getListForMember(null))->hasSize(2);
+        $this->assertTrue($social->remove());
+        $this->assertCount(2, \Galette\Entity\Social::getListForMember(null));
     }
 }
index 52803a5d6690dd1a4fd80be9994d7e6c42c1996f..78baced3108fb8d8f6d1f883f4249085510eef8c 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\Entity\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 use Laminas\Db\Adapter\Adapter;
 
 /**
@@ -52,7 +52,7 @@ use Laminas\Db\Adapter\Adapter;
  * @link      http://galette.tuxfamily.org
  * @since     2018-04-15
  */
-class Status extends atoum
+class Status extends TestCase
 {
     private \Galette\Core\Db $zdb;
     private array $remove = [];
@@ -61,11 +61,9 @@ class Status extends atoum
     /**
      * Set up tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $this->zdb = new \Galette\Core\Db();
         $this->i18n = new \Galette\Core\I18n(
@@ -76,14 +74,12 @@ class Status extends atoum
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
         if (TYPE_DB === 'mysql') {
-            $this->array($this->zdb->getWarnings())->isIdenticalTo([]);
+            $this->assertSame([], $this->zdb->getWarnings());
         }
         $this->deleteStatus();
     }
@@ -120,13 +116,14 @@ class Status extends atoum
 
         $status = new \Galette\Entity\Status($this->zdb);
 
-        $this->integer(
+        $this->assertSame(
+            -2,
             $status->add('Active member', 81)
-        )->isIdenticalTo(-2);
+        );
 
-        $this->boolean(
+        $this->assertTrue(
             $status->add('Test status', 81)
-        )->isTrue();
+        );
 
         $select = $this->zdb->select(\Galette\Core\L10n::TABLE);
         $select->where(
@@ -135,25 +132,29 @@ class Status extends atoum
             )
         );
         $results = $this->zdb->execute($select);
-        $result = $results->current();
+        $result = (array)$results->current();
 
-        $this->array((array)$result)
-            ->string['text_orig']->isIdenticalTo('Test status');
+        $this->assertSame(
+            'Test status',
+            $result['text_orig']
+        );
 
         $this->remove[] = $status->id;
         $id = $status->id;
 
-        $this->integer(
+        $this->assertSame(
+            \Galette\Entity\Entitled::ID_NOT_EXITS,
             $status->update(42, 'Active member', 81)
-        )->isIdenticalTo(\Galette\Entity\Entitled::ID_NOT_EXITS);
+        );
 
-        $this->boolean(
+        $this->assertTrue(
             $status->update($id, 'Tested status', 81)
-        )->isTrue();
+        );
 
-        $this->string(
+        $this->assertSame(
+            'Tested status',
             $status->getLabel($id)
-        )->isIdenticalTo('Tested status');
+        );
 
         $select = $this->zdb->select(\Galette\Core\L10n::TABLE);
         $select->where(
@@ -162,26 +163,25 @@ class Status extends atoum
             )
         );
         $results = $this->zdb->execute($select);
-        $result = $results->current();
+        $result = (array)$results->current();
 
-        $this->array((array)$result)
-            ->string['text_orig']->isIdenticalTo('Tested status');
+        $this->assertSame(
+            'Tested status',
+            $result['text_orig']
+        );
 
-        $this->integer(
+        $this->assertSame(
+            \Galette\Entity\Entitled::ID_NOT_EXITS,
             $status->delete(42)
-        )->isIdenticalTo(\Galette\Entity\Entitled::ID_NOT_EXITS);
+        );
 
-        $this->exception(
-            function () use ($status) {
-                $status->delete($status::DEFAULT_STATUS);
-            }
-        )
-            ->hasMessage('You cannot delete default status!')
-            ->isInstanceOf('\RuntimeException');
+        $this->expectException(\RuntimeException::class);
+        $this->expectExceptionMessage('You cannot delete default status!');
+        $status->delete($status::DEFAULT_STATUS);
 
-        $this->boolean(
+        $this->assertTrue(
             $status->delete($id)
-        )->isTrue();
+        );
 
         $select = $this->zdb->select(\Galette\Core\L10n::TABLE);
         $select->where(
@@ -190,7 +190,7 @@ class Status extends atoum
             )
         );
         $results = $this->zdb->execute($select);
-        $this->integer($results->count())->isIdenticalTo(0);
+        $this->assertSame(0, $results->count());
     }
 
     /**
@@ -203,14 +203,14 @@ class Status extends atoum
         $status = new \Galette\Entity\Status($this->zdb);
 
         $list = $status->getList();
-        $this->array($list)->hasSize(10);
+        $this->assertCount(10, $list);
 
         if ($this->zdb->isPostgres()) {
             $select = $this->zdb->select($status::TABLE . '_id_seq');
             $select->columns(['last_value']);
             $results = $this->zdb->execute($select);
             $result = $results->current();
-            $this->integer($result->last_value)->isGreaterThanOrEqualTo(10, 'Incorrect status sequence');
+            $this->assertGreaterThanOrEqual(10, $result->last_value, 'Incorrect status sequence');
 
             $this->zdb->db->query(
                 'SELECT setval(\'' . PREFIX_DB . $status::TABLE . '_id_seq\', 1)',
@@ -222,14 +222,14 @@ class Status extends atoum
         $status->installInit();
 
         $list = $status->getList();
-        $this->array($list)->hasSize(10);
+        $this->assertCount(10, $list);
 
         if ($this->zdb->isPostgres()) {
             $select = $this->zdb->select($status::TABLE . '_id_seq');
             $select->columns(['last_value']);
             $results = $this->zdb->execute($select);
             $result = $results->current();
-            $this->integer($result->last_value)->isGreaterThanOrEqualTo(10, 'Incorrect status sequence ' . $result->last_value);
+            $this->assertGreaterThanOrEqual(10, $result->last_value, 'Incorrect status sequence ' . $result->last_value);
         }
     }
 }
index 4d6b720bc006bfa8b3826af95dd296b2aee665b9..09d69720489bef6f3c088f81ff40674096f27bc6 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\Entity\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 use Galette\GaletteTestCase;
 use Laminas\Db\Adapter\Adapter;
 
@@ -71,11 +71,11 @@ class Texts extends GaletteTestCase
         $texts->installInit();
 
         $list = $texts->getRefs(\Galette\Core\I18n::DEFAULT_LANG);
-        $this->array($list)->hasSize($count_texts);
+        $this->assertCount($count_texts, $list);
 
         foreach (array_keys($this->i18n->getArrayList()) as $lang) {
             $list = $texts->getRefs($lang);
-            $this->array($list)->hasSize($count_texts);
+            $this->assertCount($count_texts, $list);
         }
 
         if ($this->zdb->isPostgres()) {
@@ -83,8 +83,7 @@ class Texts extends GaletteTestCase
             $select->columns(['last_value']);
             $results = $this->zdb->execute($select);
             $result = $results->current();
-            $this->integer($result->last_value)
-                 ->isGreaterThanOrEqualTo($count_texts, 'Incorrect texts sequence ' . $result->last_value);
+            $this->assertGreaterThanOrEqual($count_texts, $result->last_value, 'Incorrect texts sequence ' . $result->last_value);
 
             $this->zdb->db->query(
                 'SELECT setval(\'' . PREFIX_DB . $texts::TABLE . '_id_seq\', 1)',
@@ -96,15 +95,14 @@ class Texts extends GaletteTestCase
         $texts->installInit(false);
 
         $list = $texts->getRefs(\Galette\Core\I18n::DEFAULT_LANG);
-        $this->array($list)->hasSize($count_texts);
+        $this->assertCount($count_texts, $list);
 
         if ($this->zdb->isPostgres()) {
             $select = $this->zdb->select($texts::TABLE . '_id_seq');
             $select->columns(['last_value']);
             $results = $this->zdb->execute($select);
             $result = $results->current();
-            $this->integer($result->last_value)
-                 ->isGreaterThanOrEqualTo(12, 'Incorrect texts sequence ' . $result->last_value);
+            $this->assertGreaterThanOrEqual(12, $result->last_value, 'Incorrect texts sequence ' . $result->last_value);
         }
     }
 }
index e72ef6f804483f12f6861f6e74457584137566c7..2af9a56c96e5a5892101b256d03adaf4f7dbf1c6 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\Entity\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 use Laminas\Db\Adapter\Adapter;
 
 /**
@@ -52,7 +52,7 @@ use Laminas\Db\Adapter\Adapter;
  * @link      http://galette.tuxfamily.org
  * @since     2019-12-14
  */
-class Title extends atoum
+class Title extends TestCase
 {
     private \Galette\Core\Db $zdb;
     private array $remove = [];
@@ -60,11 +60,9 @@ class Title extends atoum
     /**
      * Set up tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $this->zdb = new \Galette\Core\Db();
     }
@@ -72,14 +70,12 @@ class Title extends atoum
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
         if (TYPE_DB === 'mysql') {
-            $this->array($this->zdb->getWarnings())->isIdenticalTo([]);
+            $this->assertSame([], $this->zdb->getWarnings());
         }
         $this->deleteTitle();
     }
@@ -117,37 +113,31 @@ class Title extends atoum
         $titles = new \Galette\Repository\Titles($this->zdb);
         if (count($titles->getList()) === 0) {
             $res = $titles->installInit();
-            $this->boolean($res)->isTrue();
+            $this->assertTrue($res);
         }
 
         $title = new \Galette\Entity\Title();
 
         $title->short = 'Te.';
         $title->long = 'Test';
-        $this->boolean($title->store($this->zdb))->isTrue();
+        $this->assertTrue($title->store($this->zdb));
 
         $id = $title->id;
         $this->remove[] = $id;
         $title = new \Galette\Entity\Title($id); //reload
 
         $title->long = 'Test title';
-        $this->boolean($title->store($this->zdb))->isTrue();
+        $this->assertTrue($title->store($this->zdb));
         $title = new \Galette\Entity\Title($id); //reload
 
-        $this->string($title->long)->isIdenticalTo('Test title');
+        $this->assertSame('Test title', $title->long);
 
         $title = new \Galette\Entity\Title(\Galette\Entity\Title::MR);
-        $this->exception(
-            function () use ($title) {
-                $title->remove($this->zdb);
-            }
-        )
-            ->hasMessage('You cannot delete Mr. or Mrs. titles!')
-            ->isInstanceOf('\RuntimeException');
+        $this->expectException(\RuntimeException::class);
+        $this->expectExceptionMessage('You cannot delete Mr. or Mrs. titles!');
+        $title->remove($this->zdb);
 
         $title = new \Galette\Entity\Title($id); //reload
-        $this->boolean(
-            $title->remove($this->zdb)
-        )->isTrue();
+        $this->assertTrue($title->remove($this->zdb));
     }
 }
index 198515dbdca7eb01d20d5ad1b2314d730f6a90b0..5e07e902a17c5a4b5c4958f836114f2207d311ec 100644 (file)
@@ -59,13 +59,11 @@ class Transaction extends GaletteTestCase
     /**
      * Cleanup after each test method
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
-        parent::afterTestMethod($method);
+        parent::tearDown();
 
         $this->zdb = new \Galette\Core\Db();
 
@@ -96,13 +94,11 @@ class Transaction extends GaletteTestCase
     /**
      * Set up tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
-        parent::beforeTestMethod($method);
+        parent::setUp();
         $this->initContributionsTypes();
 
         $this->contrib = new \Galette\Entity\Contribution($this->zdb, $this->login);
@@ -136,10 +132,10 @@ class Transaction extends GaletteTestCase
         if (is_array($check)) {
             var_dump($check);
         }
-        $this->boolean($check)->isTrue();
+        $this->assertTrue($check);
 
         $store = $this->transaction->store($this->history);
-        $this->boolean($store)->isTrue();
+        $this->assertTrue($store);
 
         return $this->transaction;
     }
@@ -151,25 +147,22 @@ class Transaction extends GaletteTestCase
      */
     public function testEmpty()
     {
-        $this->variable($this->transaction->id)->isNull();
-        $this->variable($this->transaction->date)->isEqualTo(date('Y-m-d'));
-        $this->variable($this->transaction->amount)->isNull();
-        $this->variable($this->transaction->description)->isNull();
-
-        $this->float($this->transaction->getDispatchedAmount())->isIdenticalTo((double)0);
-        $this->float($this->transaction->getMissingAmount())->isIdenticalTo((double)0);
-        $this->string($this->transaction->getRowClass())->isIdenticalTo('transaction-normal');
-        $this->array($this->transaction->fields)
-            ->hasSize(5)
-            ->hasKeys([
-                \Galette\Entity\Transaction::PK,
-                \Galette\Entity\Adherent::PK,
-                'trans_date',
-                'trans_amount',
-                'trans_desc'
-            ]);
-
-        $this->variable($this->transaction->unknown_property)->isEqualTo(false);
+        $this->assertNull($this->transaction->id);
+        $this->assertEquals(date('Y-m-d'), $this->transaction->date);
+        $this->assertNull($this->transaction->amount);
+        $this->assertNull($this->transaction->description);
+
+        $this->assertSame((double)0, $this->transaction->getDispatchedAmount());
+        $this->assertSame((double)0, $this->transaction->getMissingAmount());
+        $this->assertSame('transaction-normal', $this->transaction->getRowClass());
+        $this->assertCount(5, $this->transaction->fields);
+        $this->assertArrayHasKey(\Galette\Entity\Transaction::PK, $this->transaction->fields);
+        $this->assertArrayHasKey(\Galette\Entity\Adherent::PK, $this->transaction->fields);
+        $this->assertArrayHasKey('trans_date', $this->transaction->fields);
+        $this->assertArrayHasKey('trans_amount', $this->transaction->fields);
+        $this->assertArrayHasKey('trans_desc', $this->transaction->fields);
+
+        $this->assertEquals(false, $this->transaction->unknown_property);
     }
 
     /**
@@ -185,31 +178,31 @@ class Transaction extends GaletteTestCase
         $data = ['trans_date' => 'mypassword'];
         $expected = ['- Wrong date format (Y-m-d) for Date!'];
         $check = $transaction->check($data, [], []);
-        $this->array($check)->isIdenticalTo($expected);
+        $this->assertSame($expected, $check);
 
         //set a correct date
         $data = ['trans_date' => '1999-01-01'];
         $check = $transaction->check($data, [], []);
-        $this->boolean($check)->isTrue();
-        $this->string($transaction->date)->isIdenticalTo('1999-01-01');
+        $this->assertTrue($check);
+        $this->assertSame('1999-01-01', $transaction->date);
 
         //set a bad amount
         $data = ['trans_amount' => 'mypassword'];
         $expected = ['- The amount must be an integer!'];
         $check = $transaction->check($data, [], []);
-        $this->array($check)->isIdenticalTo($expected);
+        $this->assertSame($expected, $check);
 
         //set a correct amount
         $data = ['trans_amount' => 1256];
         $check = $transaction->check($data, ['trans_amount' => 1], []);
-        $this->boolean($check)->isTrue();
-        $this->variable($transaction->amount)->isIdenticalTo(1256.00);
+        $this->assertTrue($check);
+        $this->assertSame(1256.00, $transaction->amount);
 
         //set a bad description
         $data = ['trans_desc' => 'this is a very long description that should give an error; because the length of transaction description is limited to 150 characters long, even if this is quite hard to find something to write.'];
         $expected = ['- Transaction description must be 150 characters long maximum.'];
         $check = $transaction->check($data, [], []);
-        $this->array($check)->isIdenticalTo($expected);
+        $this->assertSame($expected, $check);
     }
 
     /**
@@ -243,13 +236,13 @@ class Transaction extends GaletteTestCase
         if (is_array($check)) {
             var_dump($check);
         }
-        $this->boolean($check)->isTrue();
+        $this->assertTrue($check);
 
         $store = $this->transaction->store($this->history);
-        $this->boolean($store)->isTrue();
+        $this->assertTrue($store);
 
         $transaction = new \Galette\Entity\Transaction($this->zdb, $this->login, $this->transaction->id);
-        $this->variable($transaction->amount)->isIdenticalTo(42.00);
+        $this->assertSame(42.00, $transaction->amount);
     }
 
     /**
@@ -259,17 +252,25 @@ class Transaction extends GaletteTestCase
      */
     public function testGetFieldLabel()
     {
-        $this->string($this->transaction->getFieldLabel('trans_amount'))
-            ->isIdenticalTo('Amount');
+        $this->assertSame(
+            'Amount',
+            $this->transaction->getFieldLabel('trans_amount')
+        );
 
-        $this->string($this->transaction->getFieldLabel('trans_date'))
-            ->isIdenticalTo('Date');
+        $this->assertSame(
+            'Date',
+            $this->transaction->getFieldLabel('trans_date')
+        );
 
-        $this->string($this->transaction->getFieldLabel('trans_desc'))
-            ->isIdenticalTo('Description');
+        $this->assertSame(
+            'Description',
+            $this->transaction->getFieldLabel('trans_desc')
+        );
 
-        $this->string($this->transaction->getFieldLabel(\Galette\Entity\Adherent::PK))
-            ->isIdenticalTo('Originator');
+        $this->assertSame(
+            'Originator',
+            $this->transaction->getFieldLabel(\Galette\Entity\Adherent::PK)
+        );
     }
 
     /**
@@ -279,10 +280,13 @@ class Transaction extends GaletteTestCase
      */
     public function testLoad()
     {
-        $this->login = new \mock\Galette\Core\Login($this->zdb, $this->i18n);
-        $this->calling($this->login)->isLogged = true;
-        $this->calling($this->login)->isStaff = true;
-        $this->calling($this->login)->isAdmin = true;
+        $this->login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, new \Galette\Core\I18n()))
+            ->onlyMethods(array('isLogged', 'isAdmin', 'isStaff'))
+            ->getMock();
+        $this->login->method('isLogged')->willReturn(true);
+        $this->login->method('isAdmin')->willReturn(true);
+        $this->login->method('isStaff')->willReturn(true);
 
         $this->getMemberOne();
 
@@ -292,8 +296,8 @@ class Transaction extends GaletteTestCase
         $id = $this->transaction->id;
         $transaction = new \Galette\Entity\Transaction($this->zdb, $this->login);
 
-        $this->boolean($transaction->load((int)$id))->isTrue();
-        $this->boolean($transaction->load(1355522012))->isFalse();
+        $this->assertTrue($transaction->load((int)$id));
+        $this->assertFalse($transaction->load(1355522012));
     }
 
     /**
@@ -309,10 +313,10 @@ class Transaction extends GaletteTestCase
         $this->createTransaction();
 
         $tid = $this->transaction->id;
-        $this->boolean($this->transaction->load($tid))->isTrue();
-        $this->boolean($this->transaction->remove($this->history))->isTrue();
-        $this->boolean($this->transaction->load($tid))->isFalse();
-        $this->boolean($this->transaction->remove($this->history))->isFalse();
+        $this->assertTrue($this->transaction->load($tid));
+        $this->assertTrue($this->transaction->remove($this->history));
+        $this->assertFalse($this->transaction->load($tid));
+        $this->assertFalse($this->transaction->remove($this->history));
     }
 
     /**
@@ -327,39 +331,39 @@ class Transaction extends GaletteTestCase
         $this->createTransaction();
         $transaction = $this->transaction;
 
-        $this->boolean($transaction->canShow($this->login))->isFalse();
+        $this->assertFalse($transaction->canShow($this->login));
 
         //Superadmin can fully change transactions
         $this->logSuperAdmin();
 
-        $this->boolean($transaction->canShow($this->login))->isTrue();
+        $this->assertTrue($transaction->canShow($this->login));
 
         //logout
         $this->login->logOut();
-        $this->boolean($this->login->isLogged())->isFalse();
+        $this->assertFalse($this->login->isLogged());
 
         //Member can fully change its own transactions
         $mdata = $this->dataAdherentOne();
-        $this->boolean($this->login->login($mdata['login_adh'], $mdata['mdp_adh']))->isTrue();
-        $this->boolean($this->login->isLogged())->isTrue();
-        $this->boolean($this->login->isAdmin())->isFalse();
-        $this->boolean($this->login->isStaff())->isFalse();
+        $this->assertTrue($this->login->login($mdata['login_adh'], $mdata['mdp_adh']));
+        $this->assertTrue($this->login->isLogged());
+        $this->assertFalse($this->login->isAdmin());
+        $this->assertFalse($this->login->isStaff());
 
-        $this->boolean($transaction->canShow($this->login))->isTrue();
+        $this->assertTrue($transaction->canShow($this->login));
 
         //logout
         $this->login->logOut();
-        $this->boolean($this->login->isLogged())->isFalse();
+        $this->assertFalse($this->login->isLogged());
 
         //Another member has no access
         $this->getMemberTwo();
         $mdata = $this->dataAdherentTwo();
-        $this->boolean($this->login->login($mdata['login_adh'], $mdata['mdp_adh']))->isTrue();
-        $this->boolean($this->login->isLogged())->isTrue();
-        $this->boolean($this->login->isAdmin())->isFalse();
-        $this->boolean($this->login->isStaff())->isFalse();
+        $this->assertTrue($this->login->login($mdata['login_adh'], $mdata['mdp_adh']));
+        $this->assertTrue($this->login->isLogged());
+        $this->assertFalse($this->login->isAdmin());
+        $this->assertFalse($this->login->isStaff());
 
-        $this->boolean($transaction->canShow($this->login))->isFalse();
+        $this->assertFalse($transaction->canShow($this->login));
 
         //parents can chow change children transactions
         $this->getMemberOne();
@@ -395,34 +399,34 @@ class Transaction extends GaletteTestCase
         if (is_array($check)) {
             var_dump($check);
         }
-        $this->boolean($check)->isTrue();
+        $this->assertTrue($check);
 
         $store = $ctransaction->store($this->history);
-        $this->boolean($store)->isTrue();
+        $this->assertTrue($store);
 
         $this->login->logOut();
 
         //load child from db
         $child = new \Galette\Entity\Adherent($this->zdb);
         $child->enableDep('parent');
-        $this->boolean($child->load($cid))->isTrue();
+        $this->assertTrue($child->load($cid));
 
-        $this->string($child->name)->isIdenticalTo($child_data['nom_adh']);
-        $this->object($child->parent)->isInstanceOf('\Galette\Entity\Adherent');
-        $this->integer($child->parent->id)->isIdenticalTo($member->id);
-        $this->boolean($this->login->login($mdata['login_adh'], $mdata['mdp_adh']))->isTrue();
+        $this->assertSame($child_data['nom_adh'], $child->name);
+        $this->assertInstanceOf('\Galette\Entity\Adherent', $child->parent);
+        $this->assertSame($member->id, $child->parent->id);
+        $this->assertTrue($this->login->login($mdata['login_adh'], $mdata['mdp_adh']));
 
         $mdata = $this->dataAdherentOne();
-        $this->boolean($this->login->login($mdata['login_adh'], $mdata['mdp_adh']))->isTrue();
-        $this->boolean($this->login->isLogged())->isTrue();
-        $this->boolean($this->login->isAdmin())->isFalse();
-        $this->boolean($this->login->isStaff())->isFalse();
+        $this->assertTrue($this->login->login($mdata['login_adh'], $mdata['mdp_adh']));
+        $this->assertTrue($this->login->isLogged());
+        $this->assertFalse($this->login->isAdmin());
+        $this->assertFalse($this->login->isStaff());
 
-        $this->boolean($ctransaction->canShow($this->login))->isTrue();
+        $this->assertTrue($ctransaction->canShow($this->login));
 
         //logout
         $this->login->logOut();
-        $this->boolean($this->login->isLogged())->isFalse();
+        $this->assertFalse($this->login->isLogged());
     }
 
     /**
@@ -462,12 +466,18 @@ class Transaction extends GaletteTestCase
         $contrib = $this->createContrib($data);
         $contribs_ids[] = $contrib->id;
 
-        $this->boolean($contrib->isTransactionPart())->isTrue();
-        $this->boolean($contrib->isTransactionPartOf($this->transaction->id))->isTrue();
+        $this->assertTrue($contrib->isTransactionPart());
+        $this->assertTrue($contrib->isTransactionPartOf($this->transaction->id));
 
-        $this->float($this->transaction->getDispatchedAmount())->isIdenticalTo((double)25);
-        $this->float($this->transaction->getMissingAmount())->isIdenticalTo((double)67);
-        $this->string($this->transaction->getRowClass())->isIdenticalTo('transaction-uncomplete');
+        $this->assertSame(
+            (double)25,
+            $this->transaction->getDispatchedAmount()
+        );
+        $this->assertSame(
+            (double)67,
+            $this->transaction->getMissingAmount()
+        );
+        $this->assertSame('transaction-uncomplete', $this->transaction->getRowClass());
 
         //complete the transaction
         $data = [
@@ -484,16 +494,22 @@ class Transaction extends GaletteTestCase
         $contrib = $this->createContrib($data);
         $contribs_ids[] = $contrib->id;
 
-        $this->boolean($contrib->isTransactionPart())->isTrue();
-        $this->boolean($contrib->isTransactionPartOf($this->transaction->id))->isTrue();
-        $this->boolean($contrib->isFee())->isFalse();
-        $this->string($contrib->getTypeLabel())->isIdenticalTo('Donation');
-        $this->string($contrib->getRawType())->isIdenticalTo('donation');
+        $this->assertTrue($contrib->isTransactionPart());
+        $this->assertTrue($contrib->isTransactionPartOf($this->transaction->id));
+        $this->assertFalse($contrib->isFee());
+        $this->assertSame('Donation', $contrib->getTypeLabel());
+        $this->assertSame('donation', $contrib->getRawType());
 
 
-        $this->float($this->transaction->getDispatchedAmount())->isIdenticalTo((double)92);
-        $this->float($this->transaction->getMissingAmount())->isIdenticalTo((double)0);
-        $this->string($this->transaction->getRowClass())->isIdenticalTo('transaction-normal');
+        $this->assertSame(
+            (double)92,
+            $this->transaction->getDispatchedAmount()
+        );
+        $this->assertSame(
+            (double)0,
+            $this->transaction->getMissingAmount()
+        );
+        $this->assertSame('transaction-normal', $this->transaction->getRowClass());
 
         //cannot add more
         $data = [
@@ -509,27 +525,39 @@ class Transaction extends GaletteTestCase
         ];
         $contrib = new \Galette\Entity\Contribution($this->zdb, $this->login);
         $check = $contrib->check($data, [], []);
-        $this->array($check)->isIdenticalTo(['- Sum of all contributions exceed corresponding transaction amount.']);
+        $this->assertSame(['- Sum of all contributions exceed corresponding transaction amount.'], $check);
 
         $contrib_id = $contribs_ids[0];
         $contrib = new \Galette\Entity\Contribution($this->zdb, $this->login, $contrib_id);
-        $this->boolean($contrib->unsetTransactionPart($this->zdb, $this->login, $tid, $contrib_id))->isTrue();
+        $this->assertTrue($contrib->unsetTransactionPart($this->zdb, $this->login, $tid, $contrib_id));
 
-        $this->float($this->transaction->getDispatchedAmount())->isIdenticalTo((double)67);
-        $this->float($this->transaction->getMissingAmount())->isIdenticalTo((double)25);
-        $this->string($this->transaction->getRowClass())->isIdenticalTo('transaction-uncomplete');
+        $this->assertSame(
+            (double)67,
+            $this->transaction->getDispatchedAmount()
+        );
+        $this->assertSame(
+            (double)25,
+            $this->transaction->getMissingAmount()
+        );
+        $this->assertSame('transaction-uncomplete', $this->transaction->getRowClass());
 
-        $this->boolean($contrib->setTransactionPart($this->zdb, $tid, $contrib_id))->isTrue();
+        $this->assertTrue($contrib->setTransactionPart($this->zdb, $tid, $contrib_id));
 
-        $this->float($this->transaction->getDispatchedAmount())->isIdenticalTo((double)92);
-        $this->float($this->transaction->getMissingAmount())->isIdenticalTo((double)0);
-        $this->string($this->transaction->getRowClass())->isIdenticalTo('transaction-normal');
+        $this->assertSame(
+            (double)92,
+            $this->transaction->getDispatchedAmount()
+        );
+        $this->assertSame(
+            (double)0,
+            $this->transaction->getMissingAmount()
+        );
+        $this->assertSame('transaction-normal', $this->transaction->getRowClass());
 
         //delete transaction, and ensures all contributions has been removed as well
-        $this->boolean($this->transaction->remove($this->history))->isTrue();
-        $this->boolean($this->transaction->load($tid))->isFalse();
+        $this->assertTrue($this->transaction->remove($this->history));
+        $this->assertFalse($this->transaction->load($tid));
         foreach ($contribs_ids as $contrib_id) {
-            $this->boolean($this->contrib->load($contrib_id))->isFalse();
+            $this->assertFalse($this->contrib->load($contrib_id));
         }
     }
 }
index 382971bc56f2cd858009b7cc74806a993f778e95..82c3a3989b0aaeda70ed03c4f4ce5ccc52d50580 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\IO\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 use Galette\Entity\Adherent;
 use Galette\DynamicFields\DynamicField;
 use Galette\GaletteTestCase;
@@ -61,26 +61,22 @@ class CsvIn extends GaletteTestCase
     /**
      * Set up tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
-        parent::beforeTestMethod($method);
+        parent::setUp();
         $this->contents_table = null;
     }
 
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
-        parent::afterTestMethod($method);
+        parent::tearDown();
 
         $delete = $this->zdb->delete(\Galette\Entity\Adherent::TABLE);
         $this->zdb->execute($delete);
@@ -135,8 +131,9 @@ class CsvIn extends GaletteTestCase
 
         $members = new \Galette\Repository\Members();
         $list = $members->getList();
-        $this->integer($list->count())->isIdenticalTo(
+        $this->assertSame(
             $count_before,
+            $list->count(),
             print_r(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1), true)
         );
 
@@ -152,14 +149,20 @@ class CsvIn extends GaletteTestCase
         $response = $controller->getImportModel($request, $response);
         $csvin = new \Galette\IO\CsvIn($this->container->get('zdb'));
 
-        $this->integer($response->getStatusCode())->isIdenticalTo(200);
-        $this->array($response->getHeaders())
-            ->array['Content-Type']->isIdenticalTo(['text/csv'])
-            ->array['Content-Disposition']->isIdenticalTo(['attachment;filename="galette_import_model.csv"']);
+        $this->assertSame(200, $response->getStatusCode());
+        $headers = $response->getHeaders();
+        $this->assertIsArray($headers);
+        $this->assertSame(['text/csv'], $headers['Content-Type']);
+        $this->assertSame(
+            ['attachment;filename="galette_import_model.csv"'],
+            $headers['Content-Disposition']
+        );
 
         $csvfile_model = $response->getBody()->__toString();
-        $this->string($csvfile_model)
-             ->isIdenticalTo("\"" . implode("\";\"", $fields) . "\"\r\n");
+        $this->assertSame(
+            "\"" . implode("\";\"", $fields) . "\"\r\n",
+            $csvfile_model
+        );
 
         $contents = $csvfile_model;
         foreach ($members_list as $member) {
@@ -171,15 +174,15 @@ class CsvIn extends GaletteTestCase
         }
 
         $path = GALETTE_CACHE_DIR . $file_name;
-        $this->integer(file_put_contents($path, $contents));
+        $this->assertIsInt(file_put_contents($path, $contents));
         $_FILES['new_file'] = [
             'error' => UPLOAD_ERR_OK,
             'name'      => $file_name,
             'tmp_name'  => $path,
             'size'      => filesize($path)
         ];
-        $this->boolean($csvin->store($_FILES['new_file'], true))->isTrue();
-        $this->boolean(file_exists($csvin->getDestDir() . $csvin->getFileName()))->isTrue();
+        $this->assertTrue($csvin->store($_FILES['new_file'], true));
+        $this->assertTrue(file_exists($csvin->getDestDir() . $csvin->getFileName()));
 
         $post = [
             'import_file'   => $file_name
@@ -189,20 +192,20 @@ class CsvIn extends GaletteTestCase
         $request = $request->withParsedBody($post);
 
         $response = $controller->doImports($request, $response);
-        $this->integer($response->getStatusCode())->isIdenticalTo(301);
-        $this->array($this->flash_data['slimFlash'])->isIdenticalTo($flash_messages);
+        $this->assertSame(301, $response->getStatusCode());
+        $this->assertSame($flash_messages, $this->flash_data['slimFlash']);
         $this->flash->clearMessages();
 
         $members = new \Galette\Repository\Members();
         $list = $members->getList();
-        $this->integer($list->count())->isIdenticalTo($count_after);
+        $this->assertSame($count_after, $list->count());
 
         if ($count_before != $count_after) {
             foreach ($list as $member) {
                 $created = $members_list[$member->fingerprint];
                 foreach ($fields as $field) {
                     if (property_exists($member, $field)) {
-                        $this->variable($member->$field)->isEqualTo($created[$field]);
+                        $this->assertEquals($created[$field], $member->$field);
                     } else {
                         //manage dynamic fields
                         $matches = [];
@@ -223,7 +226,10 @@ class CsvIn extends GaletteTestCase
                                 $expected[0]['text_val'] = $values[$created[$field]];
                             }
 
-                            $this->array($adh->getDynamicFields()->getValues($matches[1]))->isEqualTo($expected);
+                            $this->assertEquals(
+                                $expected,
+                                $adh->getDynamicFields()->getValues($matches[1])
+                            );
                         } else {
                             throw new \RuntimeException("Unknown field $field");
                         }
@@ -277,11 +283,11 @@ class CsvIn extends GaletteTestCase
     protected function getModel($fields): \Galette\Entity\ImportModel
     {
         $model = new \Galette\Entity\ImportModel();
-        $this->boolean($model->remove($this->zdb))->isTrue();
+        $this->assertTrue($model->remove($this->zdb));
 
-        $this->object($model->setFields($fields))->isInstanceOf('Galette\Entity\ImportModel');
-        $this->boolean($model->store($this->zdb))->isTrue();
-        $this->boolean($model->load())->isTrue();
+        $this->assertInstanceOf(\Galette\Entity\ImportModel::class, $model->setFields($fields));
+        $this->assertTrue($model->store($this->zdb));
+        $this->assertTrue($model->load());
         return $model;
     }
 
@@ -304,13 +310,14 @@ class CsvIn extends GaletteTestCase
         ]);
         $select->where(['text_orig' => $text_orig]);
         $results = $this->zdb->execute($select);
-        $this->integer($results->count())->isIdenticalTo(count($langs));
+        $this->assertSame(count($langs), $results->count());
 
         foreach ($results as $result) {
-            $this->boolean(in_array(str_replace('.utf8', '', $result['text_locale']), $langs))->isTrue();
-            $this->integer((int)$result['text_nref'])->isIdenticalTo(1);
-            $this->string($result['text_trans'])->isIdenticalTo(
-                ($result['text_locale'] == 'en_US' ? $text_orig : '')
+            $this->assertTrue(in_array(str_replace('.utf8', '', $result['text_locale']), $langs));
+            $this->assertSame(1, (int)$result['text_nref']);
+            $this->assertSame(
+                ($result['text_locale'] == 'en_US' ? $text_orig : ''),
+                $result['text_trans']
             );
         }
     }
@@ -337,21 +344,22 @@ class CsvIn extends GaletteTestCase
         $stored = $df->store($field_data);
         $error_detected = $df->getErrors();
         $warning_detected = $df->getWarnings();
-        $this->boolean($stored)->isTrue(
+        $this->assertTrue(
+            $stored,
             implode(
                 ' ',
                 $df->getErrors() + $df->getWarnings()
             )
         );
-        $this->array($error_detected)->isEmpty(implode(' ', $df->getErrors()));
-        $this->array($warning_detected)->isEmpty(implode(' ', $df->getWarnings()));
+        $this->assertEmpty($error_detected, implode(' ', $df->getErrors()));
+        $this->assertEmpty($warning_detected, implode(' ', $df->getWarnings()));
         //check if dynamic translation has been added
         $this->checkDynamicTranslation($field_data['field_name']);
 
         $select = $this->zdb->select(DynamicField::TABLE);
         $select->columns(array('num' => new \Laminas\Db\Sql\Expression('COUNT(1)')));
         $result = $this->zdb->execute($select)->current();
-        $this->integer((int)$result->num)->isIdenticalTo(1);
+        $this->assertSame(1, (int)$result->num);
 
         $fields = ['nom_adh', 'ville_adh', 'dynfield_' . $df->getId(), 'fingerprint'];
         $file_name = 'test-import-atoum-dyn.csv';
@@ -436,23 +444,24 @@ class CsvIn extends GaletteTestCase
         $stored = $cdf->store($cfield_data);
         $error_detected = $cdf->getErrors();
         $warning_detected = $cdf->getWarnings();
-        $this->boolean($stored)->isTrue(
+        $this->assertTrue(
+            $stored,
             implode(
                 ' ',
                 $cdf->getErrors() + $cdf->getWarnings()
             )
         );
-        $this->array($error_detected)->isEmpty(implode(' ', $cdf->getErrors()));
-        $this->array($warning_detected)->isEmpty(implode(' ', $cdf->getWarnings()));
+        $this->assertEmpty($error_detected, implode(' ', $cdf->getErrors()));
+        $this->assertEmpty($warning_detected, implode(' ', $cdf->getWarnings()));
         //check if dynamic translation has been added
         $this->checkDynamicTranslation($cfield_data['field_name']);
 
         $select = $this->zdb->select(DynamicField::TABLE);
         $select->columns(array('num' => new \Laminas\Db\Sql\Expression('COUNT(1)')));
         $result = $this->zdb->execute($select)->current();
-        $this->integer((int)$result->num)->isIdenticalTo(2);
+        $this->assertSame(2, (int)$result->num);
 
-        $this->array($cdf->getValues())->isIdenticalTo($values);
+        $this->assertSame($values, $cdf->getValues());
 
         $fields = ['nom_adh', 'ville_adh', 'dynfield_' . $cdf->getId(), 'fingerprint'];
         $file_name = 'test-import-atoum-dyn-cdyn.csv';
@@ -501,21 +510,22 @@ class CsvIn extends GaletteTestCase
         $stored = $cdf->store($cfield_data);
         $error_detected = $cdf->getErrors();
         $warning_detected = $cdf->getWarnings();
-        $this->boolean($stored)->isTrue(
+        $this->assertTrue(
+            $stored,
             implode(
                 ' ',
                 $cdf->getErrors() + $cdf->getWarnings()
             )
         );
-        $this->array($error_detected)->isEmpty(implode(' ', $cdf->getErrors()));
-        $this->array($warning_detected)->isEmpty(implode(' ', $cdf->getWarnings()));
+        $this->assertEmpty($error_detected, implode(' ', $cdf->getErrors()));
+        $this->assertEmpty($warning_detected, implode(' ', $cdf->getWarnings()));
         //check if dynamic translation has been added
         $this->checkDynamicTranslation($cfield_data['field_name']);
 
         $select = $this->zdb->select(DynamicField::TABLE);
         $select->columns(array('num' => new \Laminas\Db\Sql\Expression('COUNT(1)')));
         $result = $this->zdb->execute($select)->current();
-        $this->integer((int)$result->num)->isIdenticalTo(3);
+        $this->assertSame(3, (int)$result->num);
 
 
         $fields = ['nom_adh', 'ville_adh', 'dynfield_' . $cdf->getId(), 'fingerprint'];
index 37079649dcb60a626fef7ca673747ac491e91a83..01b85b50de7591438457af3d9aedff44bfabe881 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\IO\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * News tests class
@@ -51,18 +51,16 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2017-03-07
  */
-class News extends atoum
+class News extends TestCase
 {
     private \Galette\Core\I18n $i18n;
 
     /**
      * Set up tests
      *
-     * @param string $method Method name
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $this->i18n = new \Galette\Core\I18n();
         global $i18n;
@@ -81,8 +79,7 @@ class News extends atoum
         //load news without caching
         $news = new \Galette\IO\News('https://galette.eu/site/feed.xml', true);
         $posts = $news->getPosts();
-        $this->array($posts)
-            ->size->isGreaterThan(0);
+        $this->assertGreaterThan(0, count($posts));
     }
 
     /**
@@ -95,18 +92,17 @@ class News extends atoum
         //will use default lang to build RSS URL
         $file = GALETTE_CACHE_DIR . md5('https://galette.eu/site/feed.xml') . '.cache';
 
-        //ensure file does not exists
-        $this->boolean(file_exists($file))->isFalse;
+        //ensure file does not exist
+        $this->assertFalse(file_exists($file));
 
         //load news with caching
         $news = new \Galette\IO\News('https://galette.eu/site/feed.xml');
 
         $posts = $news->getPosts();
-        $this->array($posts)
-            ->size->isGreaterThan(0);
+        $this->assertGreaterThan(0, count($posts));
 
         //ensure file does exists
-        $this->boolean(file_exists($file))->isTrue;
+        $this->assertTrue(file_exists($file));
 
         $dformat = 'Y-m-d H:i:s';
         $mdate = \DateTime::createFromFormat(
@@ -121,7 +117,7 @@ class News extends atoum
             new \DateInterval('PT25H')
         );
         $touched = touch($file, $expired->getTimestamp());
-        $this->boolean($touched)->isTrue;
+        $this->assertTrue($touched);
 
         $news = new \Galette\IO\News('https://galette.eu/site/feed.xml');
         $mnewdate = \DateTime::createFromFormat(
@@ -132,7 +128,7 @@ class News extends atoum
             )
         );
         $isnewdate = $mnewdate > $mdate;
-        $this->boolean($isnewdate)->isTrue;
+        $this->assertTrue($isnewdate);
 
         //drop file finally
         unlink($file);
@@ -146,11 +142,12 @@ class News extends atoum
      */
     public function testLoadNewsWExeption()
     {
-        $this->assert('News cannot be loaded')
-            ->if($this->function->ini_get = 0)
-            ->given($news = new \Galette\IO\News('https://galette.eu/site/feed.xml', true))
-            ->then
-                ->array($news->getPosts())
-                ->hasSize(0);
+        $news = $this->getMockBuilder(\Galette\IO\News::class)
+            ->setConstructorArgs(array('https://galette.eu/site/feed.xml', true))
+            ->onlyMethods(array('allowURLFOpen'))
+            ->getMock();
+        $news->method('allowURLFOpen')->willReturn(false);
+
+        $this->assertCount(0, $news->getPosts());
     }
 }
index 9b78b628d6cc9751839c84dc1e51da2db3b25db7..50143da613f106842ffcb9c86631486a43140ae1 100644 (file)
@@ -63,7 +63,7 @@ class Groups extends GaletteTestCase
      *
      * @return void
      */
-    public function tearDown()
+    public function tearDown(): void
     {
         $this->deleteGroups();
     }
@@ -83,7 +83,7 @@ class Groups extends GaletteTestCase
             \Laminas\Db\Adapter\Adapter::QUERY_MODE_EXECUTE
         );
 
-        $groups = $this->groupsProvider();
+        $groups = self::groupsProvider();
         foreach ($groups as $group) {
             foreach ($group['children'] as $child) {
                 $delete = $zdb->delete(\Galette\Entity\Group::TABLE);
@@ -114,7 +114,7 @@ class Groups extends GaletteTestCase
      *
      * @return array[]
      */
-    protected function groupsProvider(): array
+    public static function groupsProvider(): array
     {
         return [
             [
@@ -163,7 +163,7 @@ class Groups extends GaletteTestCase
     {
         $group = new \Galette\Entity\Group();
         $group->setName($parent_name);
-        $this->boolean($group->store())->isTrue();
+        $this->assertTrue($group->store());
         $parent_id = $group->getId();
         $this->parents[] = $group->getId();
 
@@ -171,7 +171,7 @@ class Groups extends GaletteTestCase
             $group = new \Galette\Entity\Group();
             $group->setName($child);
             $group->setParentGroup($parent_id);
-            $this->boolean($group->store())->isTrue();
+            $this->assertTrue($group->store());
             $sub_id = $group->getId();
             $this->children[] = $group->getId();
 
@@ -179,7 +179,7 @@ class Groups extends GaletteTestCase
                 $group = new \Galette\Entity\Group();
                 $group->setName($subchild);
                 $group->setParentGroup($sub_id);
-                $this->boolean($group->store())->isTrue();
+                $this->assertTrue($group->store());
                 $this->subchildren[] = $group->getId();
             }
         }
@@ -192,17 +192,22 @@ class Groups extends GaletteTestCase
      */
     public function testGetSimpleList()
     {
+        $groups = self::groupsProvider();
+        foreach ($groups as $group) {
+            $this->testCreateGroups($group['parent_name'], $group['children']);
+        }
+
         $list = \Galette\Repository\Groups::getSimpleList();
-        $this->array($list)->hasSize(17);
+        $this->assertCount(17, $list);
 
         foreach ($list as $group_name) {
-            $this->string($group_name)->isNotEmpty();
+            $this->assertNotEmpty($group_name);
         }
 
         $list = \Galette\Repository\Groups::getSimpleList(true);
-        $this->array($list)->hasSize(17);
+        $this->assertCount(17, $list);
         foreach ($list as $group) {
-            $this->object($group)->isInstanceOf(\Galette\Entity\Group::class);
+            $this->assertInstanceOf(\Galette\Entity\Group::class, $group);
         }
     }
 
@@ -215,13 +220,18 @@ class Groups extends GaletteTestCase
     {
         $this->logSuperAdmin();
 
+        $groups = self::groupsProvider();
+        foreach ($groups as $group) {
+            $this->testCreateGroups($group['parent_name'], $group['children']);
+        }
+
         $groups = new \Galette\Repository\Groups($this->zdb, $this->login);
 
         $parents_list = $groups->getList(false);
-        $this->array($parents_list)->hasSize(3);
+        $this->assertCount(3, $parents_list);
 
         $parents_list = $groups->getList(true);
-        $this->array($parents_list)->hasSize(17);
+        $this->assertCount(17, $parents_list);
 
         $select = $this->zdb->select(\Galette\Entity\Group::TABLE);
         $select->where(['group_name' => 'Europe']);
@@ -229,18 +239,18 @@ class Groups extends GaletteTestCase
         $europe = $result->{\Galette\Entity\Group::PK};
 
         $children_list = $groups->getList(true, $europe);
-        $this->array($children_list)->hasSize(4);
+        $this->assertCount(4, $children_list);
 
         //set manager on one group, impersonate him, and check it gets only one group
         $this->getMemberOne();
         $group = new \Galette\Entity\Group((int)$europe);
-        $this->boolean($group->setManagers([$this->adh]))->isTrue();
+        $this->assertTrue($group->setManagers([$this->adh]));
 
         $this->login->impersonate($this->adh->id);
 
         $groups = new \Galette\Repository\Groups($this->zdb, $this->login);
         $parents_list = $groups->getList();
-        $this->array($parents_list)->hasSize(1);
+        $this->assertCount(1, $parents_list);
     }
 
     /**
@@ -250,11 +260,16 @@ class Groups extends GaletteTestCase
      */
     public function testUniqueness()
     {
+        $groups = self::groupsProvider();
+        foreach ($groups as $group) {
+            $this->testCreateGroups($group['parent_name'], $group['children']);
+        }
+
         $group = new \Galette\Entity\Group();
         $group->setLogin($this->login);
         $unique_name = 'One group to rule them all';
         $group->setName($unique_name);
-        $this->boolean($group->store())->isTrue();
+        $this->assertTrue($group->store());
         $group_id = $group->getId();
 
         $select = $this->zdb->select(\Galette\Entity\Group::TABLE);
@@ -268,14 +283,14 @@ class Groups extends GaletteTestCase
         $france = $result->{\Galette\Entity\Group::PK};
 
         //name already exists - not unique
-        $this->boolean(\Galette\Repository\Groups::isUnique($this->zdb, $unique_name))->isFalse();
+        $this->assertFalse(\Galette\Repository\Groups::isUnique($this->zdb, $unique_name));
         //name does not exist on another level - unique
-        $this->boolean(\Galette\Repository\Groups::isUnique($this->zdb, $unique_name, $europe))->isTrue();
+        $this->assertTrue(\Galette\Repository\Groups::isUnique($this->zdb, $unique_name, $europe));
         //name is the current one - unique
-        $this->boolean(\Galette\Repository\Groups::isUnique($this->zdb, $unique_name, null, $group_id))->isTrue();
+        $this->assertTrue(\Galette\Repository\Groups::isUnique($this->zdb, $unique_name, null, $group_id));
 
         //tests on another level
-        $this->boolean(\Galette\Repository\Groups::isUnique($this->zdb, 'Nord', $france))->isFalse();
-        $this->boolean(\Galette\Repository\Groups::isUnique($this->zdb, 'Creuse', $france))->isTrue();
+        $this->assertFalse(\Galette\Repository\Groups::isUnique($this->zdb, 'Nord', $france));
+        $this->assertTrue(\Galette\Repository\Groups::isUnique($this->zdb, 'Creuse', $france));
     }
 }
index 998dd76c6dc0bd9e8e88346f31103362acbfb61d..ce21ca75e16336f6b8b93f5ed66d90b523122a1d 100644 (file)
@@ -59,26 +59,22 @@ class Members extends GaletteTestCase
     /**
      * Set up tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
-        parent::beforeTestMethod($method);
+        parent::setUp();
         $this->createMembers();
     }
 
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
-        parent::afterTestMethod($method);
+        parent::tearDown();
 
         $this->deleteGroups();
         $this->deleteMembers();
@@ -106,13 +102,13 @@ class Members extends GaletteTestCase
         $status = new \Galette\Entity\Status($this->zdb);
         if (count($status->getList()) === 0) {
             $res = $status->installInit();
-            $this->boolean($res)->isTrue();
+            $this->assertTrue($res);
         }
 
         $contribtypes = new \Galette\Entity\ContributionsTypes($this->zdb);
         if (count($contribtypes->getCompleteList()) === 0) {
             $res = $contribtypes->installInit();
-            $this->boolean($res)->isTrue();
+            $this->assertTrue($res);
         }
 
 
@@ -132,8 +128,8 @@ class Members extends GaletteTestCase
             if (isset($test_member['societe_adh'])) {
                 $test_member['is_company'] = true;
             }
-            $this->boolean($member->check($test_member, [], []))->isTrue();
-            $this->boolean($member->store())->isTrue();
+            $this->assertTrue($member->check($test_member, [], []));
+            $this->assertTrue($member->store());
             $mids[] = $member->id;
 
             //set first member displayed publically an active and up to date member
@@ -157,8 +153,8 @@ class Members extends GaletteTestCase
                     'date_fin_cotis'                => $due_date->format('Y-m-d'),
                     \Galette\Entity\ContributionsTypes::PK  => \Galette\Entity\ContributionsTypes::DEFAULT_TYPE
                 ];
-                $this->boolean($contrib->check($cdata, [], []))->isTrue();
-                $this->boolean($contrib->store())->isTrue();
+                $this->assertTrue($contrib->check($cdata, [], []));
+                $this->assertTrue($contrib->store());
             }
 
             //only one member is due free. add him a photo.
@@ -167,7 +163,7 @@ class Members extends GaletteTestCase
                 $url = GALETTE_ROOT . '../tests/fake_image.jpg';
 
                 $copied = copy($url, $file);
-                $this->boolean($copied)->isTrue();
+                $this->assertTrue($copied);
                 $_FILES = array(
                     'photo' => array(
                         'name'      => 'fakephoto.jpg',
@@ -177,7 +173,7 @@ class Members extends GaletteTestCase
                         'error'     => 0
                     )
                 );
-                $this->integer((int)$member->picture->store($_FILES['photo'], true))->isGreaterThan(0);
+                $this->assertGreaterThan(0, (int)$member->picture->store($_FILES['photo'], true));
             }
         }
 
@@ -243,25 +239,22 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members();
 
         $list = $members->getList();
-        $this->integer($list->count())->isIdenticalTo(10);
+        $this->assertSame(10, $list->count());
 
         $list = $members->getEmails($this->zdb);
-        $this->array($list)->hasSize(10)
-            ->hasKeys([
-                'georges.didier@perrot.fr',
-                'marc25@pires.org'
-            ]);
-
+        $this->assertCount(10, $list);
+        $this->assertArrayHasKey('georges.didier@perrot.fr', $list);
+        $this->assertArrayHasKey('marc25@pires.org', $list);
 
         //Filter on active accounts
         $filters = new \Galette\Filters\MembersList();
         $filters->filter_account = \Galette\Repository\Members::ACTIVE_ACCOUNT;
         $members = new \Galette\Repository\Members($filters);
-        $this->object($members->getFilters())->isIdenticalTo($filters);
-        $this->array($members->getErrors())->isEmpty();
+        $this->assertSame($filters, $members->getFilters());
+        $this->assertEmpty($members->getErrors());
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(9);
+        $this->assertSame(9, $list->count());
 
         //Filter on inactive accounts
         $filters = new \Galette\Filters\MembersList();
@@ -269,7 +262,7 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(1);
+        $this->assertSame(1, $list->count());
 
         //Filter with email
         $filters = new \Galette\Filters\MembersList();
@@ -277,7 +270,7 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(10);
+        $this->assertSame(10, $list->count());
 
         //Filter without email
         $filters = new \Galette\Filters\MembersList();
@@ -285,7 +278,7 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(0);
+        $this->assertSame(0, $list->count());
 
         //Search on job
         $filters = new \Galette\Filters\MembersList();
@@ -294,7 +287,7 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(3);
+        $this->assertSame(3, $list->count());
 
         //Search on address
         $filters = new \Galette\Filters\MembersList();
@@ -303,7 +296,7 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(2);
+        $this->assertSame(2, $list->count());
 
         //search on email
         $filters = new \Galette\Filters\MembersList();
@@ -312,7 +305,7 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(6);
+        $this->assertSame(6, $list->count());
 
         //search on name
         $filters = new \Galette\Filters\MembersList();
@@ -321,7 +314,7 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(4);
+        $this->assertSame(4, $list->count());
 
         //search on company
         $filters = new \Galette\Filters\MembersList();
@@ -330,7 +323,7 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(2);
+        $this->assertSame(2, $list->count());
 
         //search on infos
         $filters = new \Galette\Filters\MembersList();
@@ -339,7 +332,7 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(0);
+        $this->assertSame(0, $list->count());
 
         //search on member number
         $filters = new \Galette\Filters\MembersList();
@@ -348,7 +341,7 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(1);
+        $this->assertSame(1, $list->count());
 
         //search on membership
         $filters = new \Galette\Filters\MembersList();
@@ -356,49 +349,49 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(2);
+        $this->assertSame(2, $list->count());
 
         //membership staff
         $filters->membership_filter = \Galette\Repository\Members::MEMBERSHIP_STAFF;
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(1);
+        $this->assertSame(1, $list->count());
 
         //membership admin
         $filters->membership_filter = \Galette\Repository\Members::MEMBERSHIP_ADMIN;
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(1);
+        $this->assertSame(1, $list->count());
 
         //membership never
         $filters->membership_filter = \Galette\Repository\Members::MEMBERSHIP_NEVER;
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(8);
+        $this->assertSame(8, $list->count());
 
         //membership none
         $filters->membership_filter = \Galette\Repository\Members::MEMBERSHIP_NONE;
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(5);
+        $this->assertSame(5, $list->count());
 
         //membership late
         $filters->membership_filter = \Galette\Repository\Members::MEMBERSHIP_LATE;
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(0);
+        $this->assertSame(0, $list->count());
 
         //membership nearly expired
         $filters->membership_filter = \Galette\Repository\Members::MEMBERSHIP_NEARLY;
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(0);
+        $this->assertSame(0, $list->count());
 
         //Search on groups
         //group is ignored if it does not exists... TODO: create a group
@@ -407,7 +400,7 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(0);*/
+        $this->assertSame(0, $list->count());*/
 
         // ADVANCED SEARCH
 
@@ -419,13 +412,13 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(0);
+        $this->assertSame(0, $list->count());
 
         $contribdate->modify('-5 days');
         $filters->contrib_begin_date_begin = $contribdate->format('Y-m-d');
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
-        $this->integer($list->count())->isIdenticalTo(1);
+        $this->assertSame(1, $list->count());
 
         //search on contribution end date
         $filters = new \Galette\Filters\AdvancedMembersList();
@@ -435,13 +428,13 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(0);
+        $this->assertSame(0, $list->count());
 
         $contribdate->modify('+5 days');
         $filters->contrib_begin_date_end = $contribdate->format('Y-m-d');
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
-        $this->integer($list->count())->isIdenticalTo(1);
+        $this->assertSame(1, $list->count());
 
         //search on public info visibility
         $filters = new \Galette\Filters\AdvancedMembersList();
@@ -449,19 +442,19 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(6);
+        $this->assertSame(6, $list->count());
 
         $filters->show_public_infos = \Galette\Repository\Members::FILTER_WO_PUBINFOS;
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(4);
+        $this->assertSame(4, $list->count());
 
         $filters->show_public_infos = \Galette\Repository\Members::FILTER_DC_PUBINFOS;
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(10);
+        $this->assertSame(10, $list->count());
 
         //search on status
         $filters = new \Galette\Filters\AdvancedMembersList();
@@ -469,7 +462,7 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(5);
+        $this->assertSame(5, $list->count());
 
         //search on status from free search
         $filters = new \Galette\Filters\AdvancedMembersList();
@@ -484,7 +477,7 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(5);
+        $this->assertSame(5, $list->count());
 
         //search on contribution amount
         $filters = new \Galette\Filters\AdvancedMembersList();
@@ -492,26 +485,26 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(0);
+        $this->assertSame(0, $list->count());
 
         $filters->contrib_min_amount = 20.0;
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(1);
+        $this->assertSame(1, $list->count());
 
         $filters = new \Galette\Filters\AdvancedMembersList();
         $filters->contrib_max_amount = 5.0;
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(0);
+        $this->assertSame(0, $list->count());
 
         $filters->contrib_max_amount = 20.0;
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(1);
+        $this->assertSame(1, $list->count());
 
         //search on contribution type
         $filters = new \Galette\Filters\AdvancedMembersList();
@@ -519,7 +512,7 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(1);
+        $this->assertSame(1, $list->count());
 
         $filters->contributions_types = [
             \Galette\Entity\ContributionsTypes::DEFAULT_TYPE,
@@ -528,13 +521,13 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(1);
+        $this->assertSame(1, $list->count());
 
         $filters->contributions_types = \Galette\Entity\ContributionsTypes::DEFAULT_TYPE + 1;
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(0);
+        $this->assertSame(0, $list->count());
 
         //search on payment type
         $filters = new \Galette\Filters\AdvancedMembersList();
@@ -542,7 +535,7 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(1);
+        $this->assertSame(1, $list->count());
 
         $filters->payments_types = [
             \Galette\Entity\PaymentType::CASH,
@@ -551,7 +544,7 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(1);
+        $this->assertSame(1, $list->count());
 
         $filters->payments_types = [
             \Galette\Entity\PaymentType::CHECK
@@ -559,35 +552,31 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(0);
+        $this->assertSame(0, $list->count());
 
         //not filtered list
         $members = new \Galette\Repository\Members();
         $list = $members->getList(true);
 
-        $this->array($list)
-            ->hasSize(10)
-            ->object[0]->isInstanceOf('\Galette\Entity\Adherent');
+        $this->assertCount(10, $list);
+        $this->assertInstanceOf(\Galette\Entity\Adherent::class, $list[0]);
 
         //get list with specified fields
         $members = new \Galette\Repository\Members();
         $list = $members->getList(false, ['nom_adh', 'ville_adh']);
-        $this->integer($list->count())->isIdenticalTo(10);
+        $this->assertSame(10, $list->count());
         $arraylist = $list->toArray();
         foreach ($arraylist as $array) {
-            $this->array($array)
-                ->hasSize(3)
-                ->keys->isIdenticalTo([
-                    'nom_adh',
-                    'ville_adh',
-                    'id_adh',
-                ]);
+            $this->assertCount(3, $array);
+            $this->assertArrayHasKey('nom_adh', $array);
+            $this->assertArrayHasKey('ville_adh', $array);
+            $this->assertArrayHasKey('id_adh', $array);
         }
 
         //Get staff
         $members = new \Galette\Repository\Members();
         $list = $members->getStaffMembersList();
-        $this->integer($list->count())->isIdenticalTo(1);
+        $this->assertSame(1, $list->count());
 
         //Remove 2 members
         $torm = [];
@@ -597,16 +586,19 @@ class Members extends GaletteTestCase
         $this->mids = $mids;
 
         $members = new \Galette\Repository\Members();
-        $this->boolean($members->removeMembers('notanid'))->isFalse();
-        $this->boolean($members->removeMembers($torm))->isTrue();
+        $this->assertFalse($members->removeMembers('notanid'));
+        $this->assertTrue($members->removeMembers($torm));
 
         $list = $members->getList();
-        $this->integer($list->count())->isIdenticalTo(8);
+        $this->assertSame(8, $list->count());
 
         //search on infos - as admin
         global $login;
-        $login = new \mock\Galette\Core\Login($this->zdb, $this->i18n);
-        $this->calling($login)->isAdmin = true;
+        $login = $this->getMockBuilder(\Galette\Core\Login::class)
+            ->setConstructorArgs(array($this->zdb, $this->i18n))
+            ->onlyMethods(array('isAdmin'))
+            ->getMock();
+        $login->method('isAdmin')->willReturn(true);
 
         $filters = new \Galette\Filters\MembersList();
         $filters->filter_str = 'any';
@@ -614,7 +606,7 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(0);
+        $this->assertSame(0, $list->count());
     }
 
     /**
@@ -627,25 +619,25 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members();
 
         $list = $members->getPublicList(false);
-        $this->array($list)->hasSize(2);
-        $this->integer($members->getCount())->isIdenticalTo(2);
+        $this->assertCount(2, $list);
+        $this->assertSame(2, $members->getCount());
 
         $adh = $list[0];
 
-        $this->object($adh)->isInstanceOf('\Galette\Entity\Adherent');
-        $this->boolean($adh->appearsInMembersList())->isTrue();
-        $this->variable($adh->_picture)->isNull();
+        $this->assertInstanceOf(\Galette\Entity\Adherent::class, $adh);
+        $this->assertTrue($adh->appearsInMembersList());
+        $this->assertNull($adh->_picture);
 
         $list = $members->getPublicList(true);
-        $this->array($list)->hasSize(1);
-        $this->integer($members->getCount())->isIdenticalTo(1);
+        $this->assertCount(1, $list);
+        $this->assertSame(1, $members->getCount());
 
         $adh = $list[0];
 
-        $this->object($adh)->isInstanceOf('\Galette\Entity\Adherent');
-        $this->boolean($adh->appearsInMembersList())->isTrue();
+        $this->assertInstanceOf(\Galette\Entity\Adherent::class, $adh);
+        $this->assertTrue($adh->appearsInMembersList());
 
-        $this->boolean($adh->hasPicture())->isTrue();
+        $this->assertTrue($adh->hasPicture());
     }
 
     /**
@@ -657,89 +649,85 @@ class Members extends GaletteTestCase
     {
         $members = new \Galette\Repository\Members();
         $list = $members->getList(true);
-        $this->integer(count($list))->isIdenticalTo(10);
-        $this->integer($members->getCount())->isIdenticalTo(10);
+        $this->assertSame(10, count($list));
+        $this->assertSame(10, $members->getCount());
 
         $group = new \Galette\Entity\Group();
         $group->setName('World');
-        $this->boolean($group->store())->isTrue();
+        $this->assertTrue($group->store());
         $world = $group->getId();
-        $this->integer($world)->isGreaterThan(0);
+        $this->assertGreaterThan(0, $world);
 
         //cannot be parent of itself
-        $this
-            ->exception(
-                function () use ($group) {
-                    $group->setParentGroup($group->getId());
-                }
-            )->hasMessage('Group `World` cannot be set as parent!');
+        $this->expectExceptionMessage('Group `World` cannot be set as parent!');
+        $group->setParentGroup($group->getId());
 
         $group = new \Galette\Entity\Group();
         $group->setName('Europe')->setParentGroup($world);
-        $this->boolean($group->store())->isTrue();
+        $this->assertTrue($group->store());
         $europe = $group->getId();
-        $this->integer($europe)->isGreaterThan(0);
-        $this->boolean($group->setMembers([$list[0], $list[1]]))->isTrue();
+        $this->assertGreaterThan(0, $europe);
+        $this->assertTrue($group->setMembers([$list[0], $list[1]]));
 
         $group = new \Galette\Entity\Group();
         $group->setName('Asia')->setParentGroup($world);
-        $this->boolean($group->store())->isTrue();
+        $this->assertTrue($group->store());
         $asia = $group->getId();
-        $this->integer($asia)->isGreaterThan(0);
-        $this->boolean($group->setMembers([$list[2], $list[3]]))->isTrue();
+        $this->assertGreaterThan(0, $asia);
+        $this->assertTrue($group->setMembers([$list[2], $list[3]]));
 
         $group = new \Galette\Entity\Group();
         $group->setName('Africa')->setParentGroup($world);
-        $this->boolean($group->store())->isTrue();
+        $this->assertTrue($group->store());
         $africa = $group->getId();
-        $this->integer($africa)->isGreaterThan(0);
-        $this->boolean($group->setMembers([$list[4], $list[5]]))->isTrue();
+        $this->assertassertGreaterThan(0, $africa);
+        $this->assertTrue($group->setMembers([$list[4], $list[5]]));
 
         $group = new \Galette\Entity\Group();
         $group->setName('America')->setParentGroup($world);
-        $this->boolean($group->store())->isTrue();
+        $this->assertTrue($group->store());
         $america = $group->getId();
-        $this->integer($america)->isGreaterThan(0);
-        $this->boolean($group->setMembers([$list[6], $list[7]]))->isTrue();
+        $this->assertassertGreaterThan(0, $america);
+        $this->assertTrue($group->setMembers([$list[6], $list[7]]));
 
         $group = new \Galette\Entity\Group();
         $group->setName('Antarctica')->setParentGroup($world);
-        $this->boolean($group->store())->isTrue();
+        $this->assertTrue($group->store());
         $antarctica = $group->getId();
-        $this->integer($america)->isGreaterThan(0);
-        $this->boolean($group->setMembers([$list[8], $list[9]]))->isTrue();
+        $this->assertassertGreaterThan(0, $america);
+        $this->assertTrue($group->setMembers([$list[8], $list[9]]));
 
         $group = new \Galette\Entity\Group();
         $group->setName('Activities');
-        $this->boolean($group->store())->isTrue();
+        $this->assertTrue($group->store());
         $activities = $group->getId();
-        $this->integer($activities)->isGreaterThan(0);
+        $this->assertassertGreaterThan(0, $activities);
 
         $group = new \Galette\Entity\Group();
         $group->setName('Pony')->setParentGroup($activities);
-        $this->boolean($group->store())->isTrue();
+        $this->assertTrue($group->store());
         $pony = $group->getId();
-        $this->integer($pony)->isGreaterThan(0);
+        $this->assertassertGreaterThan(0, $pony);
         //assign Members to group
         $members = [];
         for ($i = 0; $i < 5; ++$i) {
             $members[] = $list[$i];
         }
-        $this->boolean($group->setMembers($members))->isTrue();
-        $this->integer(count($group->getMembers()))->isIdenticalTo(5);
+        $this->assertTrue($group->setMembers($members));
+        $this->assertSame(5, count($group->getMembers()));
 
         $group = new \Galette\Entity\Group();
         $group->setName('Swimming pool')->setParentGroup($activities);
-        $this->boolean($group->store())->isTrue();
+        $this->assertTrue($group->store());
         $pool = $group->getId();
-        $this->integer($pool)->isGreaterThan(0);
+        $this->assertassertGreaterThan(0, $pool);
         //assign Members to group
         $members = [$list[0]];
         for ($i = 5; $i < 10; ++$i) {
             $members[] = $list[$i];
         }
-        $this->boolean($group->setMembers($members))->isTrue();
-        $this->integer(count($group->getMembers()))->isIdenticalTo(6);
+        $this->assertTrue($group->setMembers($members));
+        $this->assertSame(6, count($group->getMembers()));
 
         //all groups/members are setup. try to find them now.
         $filters = new \Galette\Filters\AdvancedMembersList();
@@ -748,19 +736,19 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(2);
+        $this->assertSame(2, $list->count());
 
         $filters->groups_search = ['idx' => 2, 'group' => $pony];
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(5);
+        $this->assertSame(5, $list->count());
 
         $filters->groups_search_log_op = \Galette\Filters\AdvancedMembersList::OP_AND;
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(2);
+        $this->assertSame(2, $list->count());
 
         //another try
         $filters = new \Galette\Filters\AdvancedMembersList();
@@ -770,13 +758,13 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(6);
+        $this->assertSame(6, $list->count());
 
         $filters->groups_search_log_op = \Galette\Filters\AdvancedMembersList::OP_AND;
         $members = new \Galette\Repository\Members($filters);
         $list = $members->getList();
 
-        $this->integer($list->count())->isIdenticalTo(1);
+        $this->assertSame(1, $list->count());
     }
 
     /**
@@ -788,12 +776,15 @@ class Members extends GaletteTestCase
     {
         $members = new \Galette\Repository\Members();
         $counts = $members->getRemindersCount();
-        $this->array($counts)->hasSize(3)
-            ->hasKeys(['impending', 'nomail', 'late']);
-        $this->integer((int)$counts['impending'])->isIdenticalTo(0);
-        $this->integer((int)$counts['late'])->isIdenticalTo(0);
-        $this->integer((int)$counts['nomail']['impending'])->isIdenticalTo(0);
-        $this->integer((int)$counts['nomail']['late'])->isIdenticalTo(0);
+        $this->assertCount(3, $counts);
+        $this->assertArrayHasKey('impending', $counts);
+        $this->assertArrayHasKey('late', $counts);
+        $this->assertArrayHasKey('nomail', $counts);
+
+        $this->assertSame(0, (int)$counts['impending']);
+        $this->assertSame(0, (int)$counts['late']);
+        $this->assertSame(0, (int)$counts['nomail']['impending']);
+        $this->assertSame(0, (int)$counts['nomail']['late']);
 
         //create a close to be expired contribution
         $contrib = new \Galette\Entity\Contribution($this->zdb, $this->login);
@@ -814,16 +805,19 @@ class Members extends GaletteTestCase
             'date_fin_cotis'                => $due_date->format('Y-m-d'),
             \Galette\Entity\ContributionsTypes::PK  => \Galette\Entity\ContributionsTypes::DEFAULT_TYPE
         ];
-        $this->boolean($contrib->check($cdata, [], []))->isTrue();
-        $this->boolean($contrib->store())->isTrue();
+        $this->assertTrue($contrib->check($cdata, [], []));
+        $this->assertTrue($contrib->store());
 
         $counts = $members->getRemindersCount();
-        $this->array($counts)->hasSize(3)
-            ->hasKeys(['impending', 'nomail', 'late']);
-        $this->integer((int)$counts['impending'])->isIdenticalTo(1);
-        $this->integer((int)$counts['late'])->isIdenticalTo(0);
-        $this->integer((int)$counts['nomail']['impending'])->isIdenticalTo(0);
-        $this->integer((int)$counts['nomail']['late'])->isIdenticalTo(0);
+        $this->assertCount(3, $counts);
+        $this->assertArrayHasKey('impending', $counts);
+        $this->assertArrayHasKey('late', $counts);
+        $this->assertArrayHasKey('nomail', $counts);
+
+        $this->assertSame(1, (int)$counts['impending']);
+        $this->assertSame(0, (int)$counts['late']);
+        $this->assertSame(0, (int)$counts['nomail']['impending']);
+        $this->assertSame(0, (int)$counts['nomail']['late']);
 
         //create an expired contribution
         $begin_date = clone $now;
@@ -842,16 +836,19 @@ class Members extends GaletteTestCase
             'date_fin_cotis'                => $due_date->format('Y-m-d'),
             \Galette\Entity\ContributionsTypes::PK  => \Galette\Entity\ContributionsTypes::DEFAULT_TYPE
         ];
-        $this->boolean($contrib->check($cdata, [], []))->isTrue();
-        $this->boolean($contrib->store())->isTrue();
+        $this->assertTrue($contrib->check($cdata, [], []));
+        $this->assertTrue($contrib->store());
 
         $counts = $members->getRemindersCount();
-        $this->array($counts)->hasSize(3)
-            ->hasKeys(['impending', 'nomail', 'late']);
-        $this->integer((int)$counts['impending'])->isIdenticalTo(1);
-        $this->integer((int)$counts['late'])->isIdenticalTo(1);
-        $this->integer((int)$counts['nomail']['impending'])->isIdenticalTo(0);
-        $this->integer((int)$counts['nomail']['late'])->isIdenticalTo(0);
+        $this->assertCount(3, $counts);
+        $this->assertArrayHasKey('impending', $counts);
+        $this->assertArrayHasKey('late', $counts);
+        $this->assertArrayHasKey('nomail', $counts);
+
+        $this->assertSame(1, (int)$counts['impending']);
+        $this->assertSame(1, (int)$counts['late']);
+        $this->assertSame(0, (int)$counts['nomail']['impending']);
+        $this->assertSame(0, (int)$counts['nomail']['late']);
 
         //member without email
         $nomail = new \Galette\Entity\Adherent($this->zdb);
@@ -860,14 +857,14 @@ class Members extends GaletteTestCase
             $this->members_fields,
             $this->history
         );
-        $this->boolean($nomail->load($this->mids[9]));
+        $this->assertTrue($nomail->load($this->mids[9]));
         $nomail->setDuplicate();
-        $this->boolean($nomail->check(['login' => 'nomail_login'], [], []))->isTrue();
+        $this->assertTrue($nomail->check(['login' => 'nomail_login'], [], []));
         $stored = $nomail->store();
         if (!$stored) {
             var_dump($nomail->getErrors());
         }
-        $this->boolean($nomail->store())->isTrue();
+        $this->assertTrue($nomail->store());
         $nomail_id = $nomail->id;
 
         //create an expired contribution without email
@@ -880,16 +877,19 @@ class Members extends GaletteTestCase
             'date_fin_cotis'                => $due_date->format('Y-m-d'),
             \Galette\Entity\ContributionsTypes::PK  => \Galette\Entity\ContributionsTypes::DEFAULT_TYPE
         ];
-        $this->boolean($contrib->check($cdata, [], []))->isTrue();
-        $this->boolean($contrib->store())->isTrue();
+        $this->assertTrue($contrib->check($cdata, [], []));
+        $this->assertTrue($contrib->store());
 
         $counts = $members->getRemindersCount();
-        $this->array($counts)->hasSize(3)
-            ->hasKeys(['impending', 'nomail', 'late']);
-        $this->integer((int)$counts['impending'])->isIdenticalTo(1);
-        $this->integer((int)$counts['late'])->isIdenticalTo(1);
-        $this->integer((int)$counts['nomail']['impending'])->isIdenticalTo(0);
-        $this->integer((int)$counts['nomail']['late'])->isIdenticalTo(1);
+        $this->assertCount(3, $counts);
+        $this->assertArrayHasKey('impending', $counts);
+        $this->assertArrayHasKey('late', $counts);
+        $this->assertArrayHasKey('nomail', $counts);
+
+        $this->assertSame(1, (int)$counts['impending']);
+        $this->assertSame(1, (int)$counts['late']);
+        $this->assertSame(0, (int)$counts['nomail']['impending']);
+        $this->assertSame(1, (int)$counts['nomail']['late']);
 
         //cleanup contribution
         $delete = $this->zdb->delete(\Galette\Entity\Contribution::TABLE);
@@ -914,16 +914,19 @@ class Members extends GaletteTestCase
             'date_fin_cotis'                => $due_date->format('Y-m-d'),
             \Galette\Entity\ContributionsTypes::PK  => \Galette\Entity\ContributionsTypes::DEFAULT_TYPE
         ];
-        $this->boolean($contrib->check($cdata, [], []))->isTrue();
-        $this->boolean($contrib->store())->isTrue();
+        $this->assertTrue($contrib->check($cdata, [], []));
+        $this->assertTrue($contrib->store());
 
         $counts = $members->getRemindersCount();
-        $this->array($counts)->hasSize(3)
-            ->hasKeys(['impending', 'nomail', 'late']);
-        $this->integer((int)$counts['impending'])->isIdenticalTo(1);
-        $this->integer((int)$counts['late'])->isIdenticalTo(1);
-        $this->integer((int)$counts['nomail']['impending'])->isIdenticalTo(1);
-        $this->integer((int)$counts['nomail']['late'])->isIdenticalTo(0);
+        $this->assertCount(3, $counts);
+        $this->assertArrayHasKey('impending', $counts);
+        $this->assertArrayHasKey('late', $counts);
+        $this->assertArrayHasKey('nomail', $counts);
+
+        $this->assertSame(1, (int)$counts['impending']);
+        $this->assertSame(1, (int)$counts['late']);
+        $this->assertSame(1, (int)$counts['nomail']['impending']);
+        $this->assertSame(0, (int)$counts['nomail']['late']);
 
         //cleanup contribution
         $delete = $this->zdb->delete(\Galette\Entity\Contribution::TABLE);
@@ -945,7 +948,7 @@ class Members extends GaletteTestCase
         $members = new \Galette\Repository\Members();
         $this->logSuperAdmin();
         $dropdown = $members->getDropdownMembers($this->zdb, $this->login);
-        $this->array($dropdown)->hasSize(10);
+        $this->assertCount(10, $dropdown);
     }
 
     /**
@@ -957,7 +960,7 @@ class Members extends GaletteTestCase
     {
         $members = new \Galette\Repository\Members();
 
-        $this->boolean($members->getArrayList($this->mids[0]))->isFalse();
+        $this->assertFalse($members->getArrayList($this->mids[0]));
 
         $selected = [
             $this->mids[0],
@@ -966,6 +969,6 @@ class Members extends GaletteTestCase
             $this->mids[9]
         ];
         $list = $members->getArrayList($selected, ['nom_adh', 'prenom_adh']);
-        $this->array($list)->hasSize(4);
+        $this->assertCount(4, $list);
     }
 }
index d5f69365fe4dc2c3b96fba5bb11d6d146fc608c9..4f8b98b5e996f8e8465bfea10ae23794fecac7a1 100644 (file)
@@ -58,29 +58,25 @@ class PaymentTypes extends GaletteTestCase
     /**
      * Set up tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
-        parent::beforeTestMethod($method);
+        parent::setUp();
 
         $types = new \Galette\Repository\PaymentTypes($this->zdb, $this->preferences, $this->login);
         $res = $types->installInit(false);
-        $this->boolean($res)->isTrue();
+        $this->assertTrue($res);
     }
 
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
-        parent::afterTestMethod($method);
+        parent::tearDown();
         $this->deletePaymentType();
     }
 
@@ -114,28 +110,30 @@ class PaymentTypes extends GaletteTestCase
         $types = new \Galette\Repository\PaymentTypes($this->zdb, $this->preferences, $this->login);
 
         $list = $types->getList();
-        $this->array($list)->hasSize(6);
+        $this->assertCount(6, $list);
 
         if ($this->zdb->isPostgres()) {
             $select = $this->zdb->select(\Galette\Entity\PaymentType::TABLE . '_id_seq');
             $select->columns(['last_value']);
             $results = $this->zdb->execute($select);
             $result = $results->current();
-            $this->integer($result->last_value)->isGreaterThanOrEqualTo(6, 'Incorrect payments types sequence');
+            $this->assertGreaterThanOrEqual(6, $result->last_value, 'Incorrect payments types sequence');
         }
 
         //reinstall payment types
         $types->installInit();
 
         $list = $types->getList();
-        $this->array($list)->hasSize(6);
+        $this->assertCount(6, $list);
 
         if ($this->zdb->isPostgres()) {
             $select = $this->zdb->select(\Galette\Entity\PaymentType::TABLE . '_id_seq');
             $select->columns(['last_value']);
             $results = $this->zdb->execute($select);
             $result = $results->current();
-            $this->integer($result->last_value)->isGreaterThanOrEqualTo(
+            $this->assertGreaterThanOrEqual(
+                6,
+                $result->last_value,
                 6,
                 'Incorrect payment types sequence ' . $result->last_value
             );
index 076fe405cac6484ba90a5986fa54fb2eb7df2761..1636e9e5adf9d1478ff002e9a02b9641b305c714 100644 (file)
@@ -58,29 +58,25 @@ class PdfModels extends GaletteTestCase
     /**
      * Set up tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
-        parent::beforeTestMethod($method);
+        parent::setUp();
 
         $models = new \Galette\Repository\PdfModels($this->zdb, $this->preferences, $this->login);
         $res = $models->installInit(false);
-        $this->boolean($res)->isTrue();
+        $this->assertTrue($res);
     }
 
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
-        parent::afterTestMethod($method);
+        parent::tearDown();
         $this->deletePdfModels();
     }
 
@@ -145,30 +141,34 @@ class PdfModels extends GaletteTestCase
 
         //install pdf models
         $list = $models->getList();
-        $this->array($list)->hasSize(4);
+        $this->assertCount(4, $list);
 
         if ($this->zdb->isPostgres()) {
             $select = $this->zdb->select(\Galette\Entity\PdfModel::TABLE . '_id_seq');
             $select->columns(['last_value']);
             $results = $this->zdb->execute($select);
             $result = $results->current();
-            $this->integer($result->last_value)
-                 ->isGreaterThanOrEqualTo(4, 'Incorrect PDF models sequence: ' . $result->last_value);
+            $this->assertGreaterThanOrEqual(
+                4,
+                $result->last_value,
+                'Incorrect PDF models sequence: ' . $result->last_value
+            );
         }
 
         //reinstall pdf models
         $models->installInit();
 
         $list = $models->getList();
-        $this->array($list)->hasSize(4);
+        $this->assertCount(4, $list);
 
         if ($this->zdb->isPostgres()) {
             $select = $this->zdb->select(\Galette\Entity\PdfModel::TABLE . '_id_seq');
             $select->columns(['last_value']);
             $results = $this->zdb->execute($select);
             $result = $results->current();
-            $this->integer($result->last_value)->isGreaterThanOrEqualTo(
+            $this->assertGreaterThanOrEqual(
                 4,
+                $result->last_value,
                 'Incorrect PDF models sequence ' . $result->last_value
             );
         }
index 82b27b7567d846c83ea9bd47f8d5fada9a427c67..aacd78b8087cc93492c057b6673d551e4fbd142e 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\Repository\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 use Galette\GaletteTestCase;
 
 /**
@@ -60,13 +60,11 @@ class Reminders extends GaletteTestCase
     /**
      * Set up tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
-        parent::beforeTestMethod($method);
+        parent::setUp();
         $this->initStatus();
         $this->initContributionsTypes();
 
@@ -83,13 +81,11 @@ class Reminders extends GaletteTestCase
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
-        parent::afterTestMethod($method);
+        parent::tearDown();
         $this->cleanContributions();
 
         $delete = $this->zdb->delete(\Galette\Entity\Adherent::TABLE);
@@ -121,15 +117,15 @@ class Reminders extends GaletteTestCase
     {
         //impendings
         $ireminders = new \Galette\Repository\Reminders([\Galette\Entity\Reminder::IMPENDING]);
-        $this->array($ireminders->getList($this->zdb))->isIdenticalTo([]);
+        $this->assertSame([], $ireminders->getList($this->zdb));
 
         //lates
         $lreminders = new \Galette\Repository\Reminders([\Galette\Entity\Reminder::LATE]);
-        $this->array($lreminders->getList($this->zdb))->isIdenticalTo([]);
+        $this->assertSame([], $lreminders->getList($this->zdb));
 
         //all
         $reminders = new \Galette\Repository\Reminders();
-        $this->array($reminders->getList($this->zdb))->isIdenticalTo([]);
+        $this->assertSame([], $reminders->getList($this->zdb));
 
         //create member
         $this->getMemberTwo();
@@ -156,13 +152,13 @@ class Reminders extends GaletteTestCase
         ]);
 
         $adh = $this->adh;
-        $this->boolean($adh->load($id))->isTrue();
+        $this->assertTrue($adh->load($id));
 
         //member is up to date, but not yet close to be expired, no reminder to send
-        $this->boolean($this->adh->isUp2Date())->isTrue();
-        $this->array($reminders->getList($this->zdb))->hasSize(0);
-        $this->array($lreminders->getList($this->zdb))->hasSize(0);
-        $this->array($ireminders->getList($this->zdb))->hasSize(0);
+        $this->assertTrue($this->adh->isUp2Date());
+        $this->assertCount(0, $reminders->getList($this->zdb));
+        $this->assertCount(0, $lreminders->getList($this->zdb));
+        $this->assertCount(0, $ireminders->getList($this->zdb));
 
 
         //create a close to be expired contribution
@@ -185,13 +181,13 @@ class Reminders extends GaletteTestCase
         ]);
 
         $adh = $this->adh;
-        $this->boolean($adh->load($id))->isTrue();
+        $this->assertTrue($adh->load($id));
 
-        //member is up to date, and close to be expired, one impending reminder to send
-        $this->boolean($this->adh->isUp2Date())->isTrue();
-        $this->array($reminders->getList($this->zdb))->hasSize(1);
-        $this->array($lreminders->getList($this->zdb))->hasSize(0);
-        $this->array($ireminders->getList($this->zdb))->hasSize(1);
+        //member is up-to-date, and close to be expired, one impending reminder to send
+        $this->assertTrue($this->adh->isUp2Date());
+        $this->assertCount(1, $reminders->getList($this->zdb));
+        $this->assertCount(0, $lreminders->getList($this->zdb));
+        $this->assertCount(1, $ireminders->getList($this->zdb));
 
 
         //create a close to be expired contribution, 7 days before expiration
@@ -214,14 +210,13 @@ class Reminders extends GaletteTestCase
         ]);
 
         $adh = $this->adh;
-        $this->boolean($adh->load($id))->isTrue();
+        $this->assertTrue($adh->load($id));
 
         //member is up to date, and close to be expired, one impending reminder to send
-        $this->boolean($this->adh->isUp2Date())->isTrue();
-        $this->array($reminders->getList($this->zdb))->hasSize(1);
-        $this->array($lreminders->getList($this->zdb))->hasSize(0);
-        $this->array($ireminders->getList($this->zdb))->hasSize(1);
-
+        $this->assertTrue($this->adh->isUp2Date());
+        $this->assertCount(1, $reminders->getList($this->zdb));
+        $this->assertCount(0, $lreminders->getList($this->zdb));
+        $this->assertCount(1, $ireminders->getList($this->zdb));
 
         //create a close to be expired contribution, the last day before expiration
         $due_date = clone $now;
@@ -242,14 +237,13 @@ class Reminders extends GaletteTestCase
         ]);
 
         $adh = $this->adh;
-        $this->boolean($adh->load($id))->isTrue();
-
-        //member is up to date, and close to be expired, one impending reminder to send
-        $this->boolean($this->adh->isUp2Date())->isTrue();
-        $this->array($reminders->getList($this->zdb))->hasSize(1);
-        $this->array($lreminders->getList($this->zdb))->hasSize(0);
-        $this->array($ireminders->getList($this->zdb))->hasSize(1);
+        $this->assertTrue($adh->load($id));
 
+        //member is up-to-date, and close to be expired, one impending reminder to send
+        $this->assertTrue($this->adh->isUp2Date());
+        $this->assertCount(1, $reminders->getList($this->zdb));
+        $this->assertCount(0, $lreminders->getList($this->zdb));
+        $this->assertCount(1, $ireminders->getList($this->zdb));
 
         //add a first close to be expired contribution reminder
         $send = new \DateTime();
@@ -266,14 +260,13 @@ class Reminders extends GaletteTestCase
         $insert->values($data);
 
         $add = $this->zdb->execute($insert);
-        $this->integer($add->count())->isGreaterThan(0);
+        $this->assertGreaterThan(0, $add->count());
 
         //there is still one impending reminder to send
-        $this->boolean($this->adh->isUp2Date())->isTrue();
-        $this->array($reminders->getList($this->zdb))->hasSize(1);
-        $this->array($lreminders->getList($this->zdb))->hasSize(0);
-        $this->array($ireminders->getList($this->zdb))->hasSize(1);
-
+        $this->assertTrue($this->adh->isUp2Date());
+        $this->assertCount(1, $reminders->getList($this->zdb));
+        $this->assertCount(0, $lreminders->getList($this->zdb));
+        $this->assertCount(1, $ireminders->getList($this->zdb));
 
         //add a second close to be expired contribution reminder, yesterday
         $send = new \DateTime();
@@ -290,14 +283,13 @@ class Reminders extends GaletteTestCase
         $insert->values($data);
 
         $add = $this->zdb->execute($insert);
-        $this->integer($add->count())->isGreaterThan(0);
+        $this->assertGreaterThan(0, $add->count());
 
         //nothing to send!
-        $this->boolean($this->adh->isUp2Date())->isTrue();
-        $this->array($reminders->getList($this->zdb))->hasSize(0);
-        $this->array($lreminders->getList($this->zdb))->hasSize(0);
-        $this->array($ireminders->getList($this->zdb))->hasSize(0);
-
+        $this->assertTrue($this->adh->isUp2Date());
+        $this->assertCount(0, $reminders->getList($this->zdb));
+        $this->assertCount(0, $lreminders->getList($this->zdb));
+        $this->assertCount(0, $ireminders->getList($this->zdb));
 
         //create an expired contribution, today
         $due_date = clone $now;
@@ -319,14 +311,13 @@ class Reminders extends GaletteTestCase
         ]);
 
         $adh = $this->adh;
-        $this->boolean($adh->load($id))->isTrue();
+        $this->assertTrue($adh->load($id));
 
         //member late, but for less than 30 days, no reminder to send
-        $this->boolean($this->adh->isUp2Date())->isFalse();
-        $this->array($reminders->getList($this->zdb))->hasSize(0);
-        $this->array($lreminders->getList($this->zdb))->hasSize(0);
-        $this->array($ireminders->getList($this->zdb))->hasSize(0);
-
+        $this->assertFalse($this->adh->isUp2Date());
+        $this->assertCount(0, $reminders->getList($this->zdb));
+        $this->assertCount(0, $lreminders->getList($this->zdb));
+        $this->assertCount(0, $ireminders->getList($this->zdb));
 
         //create an expired contribution, 29 days ago
         $due_date = clone $now;
@@ -348,14 +339,13 @@ class Reminders extends GaletteTestCase
         ]);
 
         $adh = $this->adh;
-        $this->boolean($adh->load($id))->isTrue();
+        $this->assertTrue($adh->load($id));
 
         //member is late, but for less than 30 days, no reminder to send
-        $this->boolean($this->adh->isUp2Date())->isFalse();
-        $this->array($reminders->getList($this->zdb))->hasSize(0);
-        $this->array($lreminders->getList($this->zdb))->hasSize(0);
-        $this->array($ireminders->getList($this->zdb))->hasSize(0);
-
+        $this->assertFalse($this->adh->isUp2Date());
+        $this->assertCount(0, $reminders->getList($this->zdb));
+        $this->assertCount(0, $lreminders->getList($this->zdb));
+        $this->assertCount(0, $ireminders->getList($this->zdb));
 
         //create an expired contribution, late by 30 days
         $due_date = clone $now;
@@ -377,14 +367,13 @@ class Reminders extends GaletteTestCase
         ]);
 
         $adh = $this->adh;
-        $this->boolean($adh->load($id))->isTrue();
+        $this->assertTrue($adh->load($id));
 
         //member is late, one late reminder to send
-        $this->boolean($this->adh->isUp2Date())->isFalse();
-        $this->array($reminders->getList($this->zdb))->hasSize(1);
-        $this->array($lreminders->getList($this->zdb))->hasSize(1);
-        $this->array($ireminders->getList($this->zdb))->hasSize(0);
-
+        $this->assertFalse($this->adh->isUp2Date());
+        $this->assertCount(1, $reminders->getList($this->zdb));
+        $this->assertCount(1, $lreminders->getList($this->zdb));
+        $this->assertCount(0, $ireminders->getList($this->zdb));
 
         //create an expired contribution, late by 40 days
         $due_date = clone $now;
@@ -406,14 +395,13 @@ class Reminders extends GaletteTestCase
         ]);
 
         $adh = $this->adh;
-        $this->boolean($adh->load($id))->isTrue();
+        $this->assertTrue($adh->load($id));
 
         //member is late, one late reminder to send
-        $this->boolean($this->adh->isUp2Date())->isFalse();
-        $this->array($reminders->getList($this->zdb))->hasSize(1);
-        $this->array($lreminders->getList($this->zdb))->hasSize(1);
-        $this->array($ireminders->getList($this->zdb))->hasSize(0);
-
+        $this->assertFalse($this->adh->isUp2Date());
+        $this->assertCount(1, $reminders->getList($this->zdb));
+        $this->assertCount(1, $lreminders->getList($this->zdb));
+        $this->assertCount(0, $ireminders->getList($this->zdb));
 
         //add a sent late reminder, as it should have been
         $send = clone $now;
@@ -430,14 +418,13 @@ class Reminders extends GaletteTestCase
         $insert->values($data);
 
         $add = $this->zdb->execute($insert);
-        $this->integer($add->count())->isGreaterThan(0);
+        $this->assertGreaterThan(0, $add->count());
 
         //nothing to send!
-        $this->boolean($this->adh->isUp2Date())->isFalse();
-        $this->array($reminders->getList($this->zdb))->hasSize(0);
-        $this->array($lreminders->getList($this->zdb))->hasSize(0);
-        $this->array($ireminders->getList($this->zdb))->hasSize(0);
-
+        $this->assertFalse($this->adh->isUp2Date());
+        $this->assertCount(0, $reminders->getList($this->zdb));
+        $this->assertCount(0, $lreminders->getList($this->zdb));
+        $this->assertCount(0, $ireminders->getList($this->zdb));
 
         //create an expired contribution, 60 days ago
         $due_date = clone $now;
@@ -459,12 +446,12 @@ class Reminders extends GaletteTestCase
         ]);
 
         $adh = $this->adh;
-        $this->boolean($adh->load($id))->isTrue();
+        $this->assertTrue($adh->load($id));
 
         //member has been late for two months, one late reminder to send
-        $this->boolean($this->adh->isUp2Date())->isFalse();
-        $this->array($reminders->getList($this->zdb))->hasSize(1);
-        $this->array($lreminders->getList($this->zdb))->hasSize(1);
-        $this->array($ireminders->getList($this->zdb))->hasSize(0);
+        $this->assertFalse($this->adh->isUp2Date());
+        $this->assertCount(1, $reminders->getList($this->zdb));
+        $this->assertCount(1, $lreminders->getList($this->zdb));
+        $this->assertCount(0, $ireminders->getList($this->zdb));
     }
 }
index d97b25a571165fdc0a656be50359f283c6728697..b2be6741f19ce4d158b76d1eb8f6519608d05e5d 100644 (file)
@@ -3,7 +3,7 @@
 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
 
 /**
- * Telemetry tests
+ * Password tests
  *
  * PHP version 5
  *
 
 namespace Galette\Util\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 use Galette\Core\Preferences;
+use PHPUnit\Framework\Attributes\DataProvider;
 
 /**
  * Password tests class
  *
  * @category  Util
- * @name      Telemetry
+ * @name      Password
  * @package   GaletteTests
  * @author    Johan Cwiklinski <johan@x-tnd.be>
  * @copyright 2020-2023 The Galette Team
@@ -51,7 +52,7 @@ use Galette\Core\Preferences;
  * @link      http://galette.tuxfamily.org
  * @since     2020-04-25
  */
-class Password extends atoum
+class Password extends TestCase
 {
     private \Galette\Core\Db $zdb;
     private \Galette\Core\Preferences $preferences;
@@ -59,14 +60,12 @@ class Password extends atoum
     /**
      * Tear down tests
      *
-     * @param string $method Method tested
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDow(): void
     {
         if (TYPE_DB === 'mysql') {
-            $this->array($this->zdb->getWarnings())->isIdenticalTo([]);
+            $this->assertSame([], $this->zdb->getWarnings());
         }
         $this->preferences->pref_password_strength = Preferences::PWD_NONE;
         $this->preferences->pref_password_length = 6;
@@ -77,11 +76,9 @@ class Password extends atoum
     /**
      * Set up tests
      *
-     * @param string $method Method tested
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $this->zdb = new \Galette\Core\Db();
         $this->preferences = new \Galette\Core\Preferences($this->zdb);
@@ -92,7 +89,7 @@ class Password extends atoum
      *
      * @return array
      */
-    protected function passProvider()
+    public static function passProvider()
     {
         return [
             // [strength, password, errors]
@@ -130,14 +127,13 @@ class Password extends atoum
     /**
      * Test password validation
      *
-     * @dataProvider passProvider
-     *
      * @param integer $level  Password level
      * @param string  $pass   Password
      * @param array   $errors Errors
      *
      * @return void
      */
+    #[DataProvider('passProvider')]
     public function testValidatePassword($level, $pass, $errors)
     {
         //errror messages mapping
@@ -164,15 +160,15 @@ class Password extends atoum
         if ($level < Preferences::PWD_VERY_STRONG) {
             $this->preferences->pref_password_strength = $level + 1;
             $password = new \Galette\Util\Password($this->preferences);
-            $this->boolean($password->isValid($pass))->isFalse();
-            $this->array($password->getErrors())->isEqualTo($errors);
+            $this->assertFalse($password->isValid($pass));
+            $this->assertEquals($password->getErrors(), $errors);
         }
 
         $this->preferences->pref_password_strength = $level;
         $password = new \Galette\Util\Password($this->preferences);
-        $this->boolean($password->isValid($pass))->isTrue(implode(', ', $password->getErrors()));
-        $this->array($password->getErrors())->isEqualTo([]);
-        $this->array($password->getStrenghtErrors())->isEqualTo($errors);
+        $this->assertTrue($password->isValid($pass), implode(', ', $password->getErrors()));
+        $this->assertSame($password->getErrors(), []);
+        $this->assertEquals($password->getStrenghtErrors(), $errors);
     }
 
     /**
@@ -180,7 +176,7 @@ class Password extends atoum
      *
      * @return array
      */
-    protected function blacklistProvider()
+    public static function blacklistProvider()
     {
         return [
             ['galette', true],
@@ -195,22 +191,21 @@ class Password extends atoum
     /**
      * Test password blacklist
      *
-     * @dataProvider blacklistProvider
-     *
      * @param string  $pass     Password to test
      * @param boolean $expected Excpected return
      *
      * @return void
      */
+    #[DataProvider('blacklistProvider')]
     public function testBlacklist($pass, $expected)
     {
         $this->preferences->pref_password_blacklist = true;
         $password = new \Galette\Util\Password($this->preferences);
-        $this->boolean($password->isBlacklisted($pass))->isIdenticalTo($expected, $pass);
+        $this->assertSame($password->isBlacklisted($pass), $expected, $pass);
 
         $this->preferences->pref_password_blacklist = false;
         $password = new \Galette\Util\Password($this->preferences);
-        $this->boolean($password->isBlacklisted($pass))->isFalse();
+        $this->assertFalse($password->isBlacklisted($pass));
     }
 
     /**
@@ -231,21 +226,23 @@ class Password extends atoum
         $password = new \Galette\Util\Password($this->preferences);
         $password->addPersonalInformation($infos);
         foreach ($infos as $info) {
-            $this->boolean($password->isValid($info))->isTrue(implode(', ', $password->getErrors()));
-            $this->array($password->getErrors())->isEqualTo([]);
+            $this->assertTrue($password->isValid($info), implode(', ', $password->getErrors()));
+            $this->assertSame($password->getErrors(), []);
         }
 
         $this->preferences->pref_password_strength = Preferences::PWD_WEAK;
         $password = new \Galette\Util\Password($this->preferences);
         $password->addPersonalInformation($infos);
         foreach ($infos as $info) {
-            $this->boolean($password->isValid($info))->isFalse();
-            $this->array($password->getErrors())
-                 ->isEqualTo(['Do not use any of your personal information as password!']);
+            $this->assertFalse($password->isValid($info));
+            $this->assertEquals(
+                $password->getErrors(),
+                ['Do not use any of your personal information as password!']
+            );
         }
 
-        $this->boolean($password->isValid('MyLoGiN'))->isFalse();
-        $this->boolean($password->isValid('iMyLoGiN'))->isTrue();
+        $this->assertFalse($password->isValid('MyLoGiN'));
+        $this->assertTrue($password->isValid('iMyLoGiN'));
 
         //create member
         global $zdb, $login, $i18n; // globals :(
@@ -281,7 +278,7 @@ class Password extends atoum
         if (is_array($check)) {
             var_dump($check);
         }
-        $this->boolean($check)->isTrue();
+        $this->assertTrue($check);
 
         $password = new \Galette\Util\Password($this->preferences);
         $password->setAdherent($adh);
@@ -311,10 +308,10 @@ class Password extends atoum
         $adh_data['c24'] = 'pignonp';
 
         foreach ($adh_data as $key => $data) {
-            $this->boolean($password->isValid($data))->isFalse($key);
+            $this->assertFalse($password->isValid($data), $key);
         }
 
-        $this->boolean($password->isValid('19800501'))->isFalse();
-        $this->boolean($password->isValid('01051980'))->isFalse();
+        $this->assertFalse($password->isValid('19800501'));
+        $this->assertFalse($password->isValid('01051980'));
     }
 }
index 23c6f8bcf869993ab388470c73fdf68c3a242ede..28f63774896805a109d3a694e3284cacd6cb54f9 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace Galette\Util\test\units;
 
-use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Telemetry tests class
@@ -51,7 +51,7 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2017-10-07
  */
-class Telemetry extends atoum
+class Telemetry extends TestCase
 {
     private \Galette\Core\Db $zdb;
     private \Galette\Core\Preferences $preferences;
@@ -60,14 +60,12 @@ class Telemetry extends atoum
     /**
      * Tear down tests
      *
-     * @param string $method Method tested
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
         if (TYPE_DB === 'mysql') {
-            $this->array($this->zdb->getWarnings())->isIdenticalTo([]);
+            $this->assertSame([], $this->zdb->getWarnings());
         }
 
         $this->preferences->pref_instance_uuid = '';
@@ -78,11 +76,9 @@ class Telemetry extends atoum
     /**
      * Set up tests
      *
-     * @param string $method Method tested
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $this->zdb = new \Galette\Core\Db();
         $this->preferences = new \Galette\Core\Preferences($this->zdb);
@@ -116,10 +112,9 @@ class Telemetry extends atoum
         );
 
         $result = $telemetry->grabGaletteInfos();
-        $this->string($result['uuid'])
-            ->hasLength(40);
+        $this->assertSame(40, strlen($result['uuid']));
         $expected['uuid'] = $result['uuid'];
-        $this->array($result)->isIdenticalTo($expected);
+        $this->assertSame($expected, $result);
 
         $this->plugins->loadModules($this->preferences, GALETTE_PLUGINS_PATH);
         $telemetry = new \Galette\Util\Telemetry(
@@ -137,30 +132,34 @@ class Telemetry extends atoum
         }
 
         $result = $telemetry->grabGaletteInfos();
-        $this->array($result)->isIdenticalTo($expected);
+        $this->assertSame($expected, $result);
 
-        $telemetry = new \mock\Galette\Util\Telemetry(
-            $this->zdb,
-            $this->preferences,
-            $this->plugins
-        );
-        $this->calling($telemetry)->getCount = function ($table, $where) {
-            switch ($table) {
-                case \Galette\Entity\Adherent::TABLE:
-                    return 56;
-                case \Galette\Entity\Contribution::TABLE:
-                    return 402;
-                case \Galette\Entity\Transaction::TABLE:
-                    return 100;
-            }
-            return 0;
-        };
+        $telemetry = $this->getMockBuilder(\Galette\Util\Telemetry::class)
+            ->setConstructorArgs([$this->zdb, $this->preferences, $this->plugins])
+            ->onlyMethods(array('getCount'))
+            ->getMock();
+        $telemetry->method('getCount')
+            ->will(
+                $this->returnCallback(
+                    function ($table, $where) {
+                        switch ($table) {
+                            case \Galette\Entity\Adherent::TABLE:
+                                return 56;
+                            case \Galette\Entity\Contribution::TABLE:
+                                return 402;
+                            case \Galette\Entity\Transaction::TABLE:
+                                return 100;
+                        }
+                        return 0;
+                    }
+                )
+            );
         $result = $telemetry->grabGaletteInfos();
 
         $expected['usage']['avg_members'] = '50-250';
         $expected['usage']['avg_contributions'] = '250-500';
         $expected['usage']['avg_transactions'] = '50-250';
-        $this->array($result)->isIdenticalTo($expected);
+        $this->assertSame($expected, $result);
     }
 
     /**
@@ -178,12 +177,12 @@ class Telemetry extends atoum
 
         $infos  = $telemetry->grabDbInfos();
 
-        $this->string($infos['engine'])->isNotEmpty();
-        $this->string($infos['version'])->isNotEmpty();
-        $this->variable($infos['size'])->isNotNull();
+        $this->assertNotEmpty($infos['engine']);
+        $this->assertNotEmpty($infos['version']);
+        $this->assertNotNull($infos['size']);
         if (!$this->zdb->isPostgres()) {
             //no sql mode for postgres databases
-            $this->string($infos['sql_mode'])->isNotEmpty();
+            $this->assertNotEmpty($infos['sql_mode']);
         }
     }
 
@@ -194,19 +193,17 @@ class Telemetry extends atoum
      */
     public function testGrabWebserverInfos()
     {
-        $telemetry = new \mock\Galette\Util\Telemetry(
+        $telemetry = new \Galette\Util\Telemetry(
             $this->zdb,
             $this->preferences,
             $this->plugins
         );
         $result = $telemetry->grabWebserverInfos();
 
-        $this->array($result)
-            ->hasSize(2)
-            ->hasKeys(['engine', 'version']);
+        $this->assertSame(['engine', 'version'], array_keys($result));
         //no webserver infos from CLI
-        $this->string($result['engine'])->isEmpty();
-        $this->string($result['version'])->isEmpty();
+        $this->assertEmpty($result['engine']);
+        $this->assertEmpty($result['version']);
     }
 
     /**
@@ -235,7 +232,7 @@ class Telemetry extends atoum
             $this->plugins
         );
         $result = $telemetry->grabPhpInfos();
-        $this->array($result)->isIdenticalTo($expected);
+        $this->assertSame($expected, $result);
     }
 
     /**
@@ -245,9 +242,17 @@ class Telemetry extends atoum
      */
     public function testGrabOsInfos()
     {
+        $distro = '';
+        if (file_exists('/etc/redhat-release')) {
+            $distro = preg_replace('/\s+$/S', '', file_get_contents('/etc/redhat-release'));
+        }
+        if (file_exists('/etc/fedora-release')) {
+            $distro = preg_replace('/\s+$/S', '', file_get_contents('/etc/fedora-release'));
+        }
+
         $expected = [
             'family'       => php_uname('s'),
-            'distribution' => '',
+            'distribution' => $distro,
             'version'      => php_uname('r')
         ];
 
@@ -257,7 +262,7 @@ class Telemetry extends atoum
             $this->plugins
         );
         $result = $telemetry->grabOsInfos();
-        $this->array($result)->isIdenticalTo($expected);
+        $this->assertSame($expected, $result);
     }
 
     /**
@@ -274,24 +279,33 @@ class Telemetry extends atoum
         );
         $result = $telemetry->getTelemetryInfos();
 
-        $this->array($result)->keys->isEqualTo([
-            'galette',
-            'system'
-        ]);
+        $this->assertSame(
+            array_keys($result),
+            [
+                'galette',
+                'system'
+            ]
+        );
 
-        $this->array($result['galette'])->keys->isEqualTo([
-            'uuid',
-            'version',
-            'plugins',
-            'default_language',
-            'usage'
-        ]);
+        $this->assertSame(
+            array_keys($result['galette']),
+            [
+                'uuid',
+                'version',
+                'plugins',
+                'default_language',
+                'usage'
+            ]
+        );
 
-        $this->array($result['system'])->keys->isEqualTo([
-            'db',
-            'web_server',
-            'php',
-            'os'
-        ]);
+        $this->assertSame(
+            array_keys($result['system']),
+            [
+                'db',
+                'web_server',
+                'php',
+                'os'
+            ]
+        );
     }
 }
index a96fad1b87e4340417f864132651007c08f789ae..b7c5593e990f7427ed8174da83bd5d42b7b49c9a 100644 (file)
 
 namespace Galette;
 
-use atoum;
-use Galette\Core\Db;
-use Galette\Core\History;
-use Galette\Core\I18n;
-use Galette\Core\Login;
-use Galette\Core\Preferences;
-use Galette\Entity\Adherent;
-use Galette\Entity\Contribution;
-use Galette\Middleware\Authenticate;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Galette tests case main class
@@ -58,27 +50,27 @@ use Galette\Middleware\Authenticate;
  * @link      http://galette.eu
  * @since     2020-12-27
  */
-abstract class GaletteTestCase extends atoum
+abstract class GaletteTestCase extends TestCase
 {
-    /** @var Db */
+    /** @var \Galette\Core\Db */
     protected \Galette\Core\Db $zdb;
     protected array $members_fields;
     protected array $members_fields_cats;
-    /** @var I18n */
+    /** @var \Galette\Core\I18n */
     protected \Galette\Core\I18n $i18n;
-    /** @var Preferences */
+    /** @var \Galette\Core\Preferences */
     protected \Galette\Core\Preferences $preferences;
     protected \RKA\Session $session;
-    /** @var Login */
+    /** @var \Galette\Core\Login */
     protected \Galette\Core\Login $login;
-    /** @var History */
+    /** @var \Galette\Core\History */
     protected \Galette\Core\History $history;
     protected $logger_storage = '';
 
-    /** @var Adherent */
-    protected Adherent $adh;
-    /** @var Contribution */
-    protected Contribution $contrib;
+    /** @var \Galette\Entity\Adherent */
+    protected \Galette\Entity\Adherent $adh;
+    /** @var \Galette\Entity\Contribution */
+    protected \Galette\Entity\Contribution $contrib;
     protected array $adh_ids = [];
     protected array $contrib_ids = [];
     /** @var array */
@@ -87,16 +79,14 @@ abstract class GaletteTestCase extends atoum
     protected \Slim\Flash\Messages $flash;
     protected \DI\Container $container;
     protected int $seed;
-    protected array $excluded_after_methods = [];
+    protected array $expected_mysql_warnings = [];
 
     /**
      * Set up tests
      *
-     * @param string $method Method tested
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         $flash_data = [];
         $this->flash_data = &$flash_data;
@@ -106,11 +96,12 @@ abstract class GaletteTestCase extends atoum
         $app = $gapp->getApp();
         $plugins = new \Galette\Core\Plugins();
         require GALETTE_BASE_PATH . '/includes/dependencies.php';
+        /** @var \DI\Container $container */
         $container = $app->getContainer();
         $_SERVER['HTTP_HOST'] = '';
 
         $container->set('flash', $this->flash);
-        $container->set(Slim\Flash\Messages::class, $this->flash);
+        $container->set(\Slim\Flash\Messages::class, $this->flash);
 
         $app->addRoutingMiddleware();
 
@@ -133,33 +124,31 @@ abstract class GaletteTestCase extends atoum
         $container = $this->container;
         $galette_log_var = $this->logger_storage;
 
-        $authenticate = new Authenticate($container);
+        $authenticate = new \Galette\Middleware\Authenticate($container);
         $showPublicPages = function (\Slim\Psr7\Request $request, \Psr\Http\Server\RequestHandlerInterface $handler) {
             return $handler->handle($request);
         };
 
-        require_once GALETTE_ROOT . 'includes/routes/main.routes.php';
-        require_once GALETTE_ROOT . 'includes/routes/authentication.routes.php';
-        require_once GALETTE_ROOT . 'includes/routes/management.routes.php';
-        require_once GALETTE_ROOT . 'includes/routes/members.routes.php';
-        require_once GALETTE_ROOT . 'includes/routes/groups.routes.php';
-        require_once GALETTE_ROOT . 'includes/routes/contributions.routes.php';
-        require_once GALETTE_ROOT . 'includes/routes/public_pages.routes.php';
-        require_once GALETTE_ROOT . 'includes/routes/ajax.routes.php';
-        require_once GALETTE_ROOT . 'includes/routes/plugins.routes.php';
+        require GALETTE_ROOT . 'includes/routes/main.routes.php';
+        require GALETTE_ROOT . 'includes/routes/authentication.routes.php';
+        require GALETTE_ROOT . 'includes/routes/management.routes.php';
+        require GALETTE_ROOT . 'includes/routes/members.routes.php';
+        require GALETTE_ROOT . 'includes/routes/groups.routes.php';
+        require GALETTE_ROOT . 'includes/routes/contributions.routes.php';
+        require GALETTE_ROOT . 'includes/routes/public_pages.routes.php';
+        require GALETTE_ROOT . 'includes/routes/ajax.routes.php';
+        require GALETTE_ROOT . 'includes/routes/plugins.routes.php';
     }
 
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
-        if (TYPE_DB === 'mysql' && !in_array($method, $this->excluded_after_methods)) {
-            $this->array($this->zdb->getWarnings())->isIdenticalTo([]);
+        if (TYPE_DB === 'mysql') {
+            $this->assertSame($this->expected_mysql_warnings, $this->zdb->getWarnings());
         }
     }
 
@@ -293,10 +282,10 @@ abstract class GaletteTestCase extends atoum
         if (is_array($check)) {
             var_dump($check);
         }
-        $this->boolean($check)->isTrue();
+        $this->assertTrue($check);
 
         $store = $this->adh->store();
-        $this->boolean($store)->isTrue();
+        $this->assertTrue($store);
 
         return $this->adh;
     }
@@ -304,8 +293,8 @@ abstract class GaletteTestCase extends atoum
     /**
      * Check members expecteds
      *
-     * @param Adherent $adh           Member instance, if any
-     * @param array    $new_expecteds Changes on expected values
+     * @param \Galette\Entity\Adherent $adh           Member instance, if any
+     * @param array                    $new_expecteds Changes on expected values
      *
      * @return void
      */
@@ -319,7 +308,6 @@ abstract class GaletteTestCase extends atoum
             'nom_adh' => 'Durand',
             'prenom_adh' => 'René',
             'ville_adh' => 'Martel',
-            'cp_adh' => '07 926',
             'adresse_adh' => '66, boulevard De Oliveira',
             'email_adh' => 'meunier.josephine@ledoux.com',
             'login_adh' => 'arthur.hamon',
@@ -348,29 +336,30 @@ abstract class GaletteTestCase extends atoum
             $property = $this->members_fields[$key]['propname'];
             switch ($key) {
                 case 'bool_admin_adh':
-                    $this->boolean($adh->isAdmin())->isIdenticalTo($value);
+                    $this->assertSame($value, $adh->isAdmin());
                     break;
                 case 'bool_exempt_adh':
-                    $this->boolean($adh->isDueFree())->isIdenticalTo($value);
+                    $this->assertSame($value, $adh->isDueFree());
                     break;
                 case 'bool_display_info':
-                    $this->boolean($adh->appearsInMembersList())->isIdenticalTo($value);
+                    $this->assertSame($value, $adh->appearsInMembersList());
                     break;
                 case 'activite_adh':
-                    $this->boolean($adh->isActive())->isIdenticalTo($value);
+                    $this->assertSame($value, $adh->isActive());
                     break;
                 case 'mdp_adh':
                     $pw_checked = password_verify($value, $adh->password);
-                    $this->boolean($pw_checked)->isTrue();
+                    $this->assertTrue($pw_checked);
                     break;
                 case 'ddn_adh':
                     //rely on age, not on birthdate
-                    $this->variable($adh->$property)->isNotNull();
-                    $this->string($adh->getAge())->isIdenticalTo(' (82 years old)');
+                    $this->assertNotNull($adh->$property);
+                    $this->assertSame(' (82 years old)', $adh->getAge());
                     break;
                 default:
-                    $this->variable($adh->$property)->isIdenticalTo(
+                    $this->assertSame(
                         $value,
+                        $adh->$property,
                         "$property expected {$value} got {$adh->$property}"
                     );
 
@@ -380,37 +369,35 @@ abstract class GaletteTestCase extends atoum
 
         $d = \DateTime::createFromFormat('Y-m-d', $expecteds['ddn_adh']);
 
-        $expected_str = ' (82 years old)';
-        $this->string($adh->getAge())->isIdenticalTo($expected_str);
-        $this->boolean($adh->hasChildren())->isFalse();
-        $this->boolean($adh->hasParent())->isFalse();
-        $this->boolean($adh->hasPicture())->isFalse();
-
-        $this->string($adh->sadmin)->isIdenticalTo('No');
-        $this->string($adh->sdue_free)->isIdenticalTo('No');
-        $this->string($adh->sappears_in_list)->isIdenticalTo('Yes');
-        $this->string($adh->sstaff)->isIdenticalTo('No');
-        $this->string($adh->sactive)->isIdenticalTo('Active');
-        $this->variable($adh->stitle)->isNull();
-        $this->string($adh->sstatus)->isIdenticalTo('Non-member');
-        $this->string($adh->sfullname)->isIdenticalTo('DURAND René');
-        $this->string($adh->saddress)->isIdenticalTo('66, boulevard De Oliveira');
-        $this->string($adh->sname)->isIdenticalTo('DURAND René');
-
-        $this->string($adh->getAddress())->isIdenticalTo($expecteds['adresse_adh']);
-        $this->string($adh->getZipcode())->isIdenticalTo($expecteds['cp_adh']);
-        $this->string($adh->getTown())->isIdenticalTo($expecteds['ville_adh']);
-        $this->string($adh->getCountry())->isIdenticalTo($expecteds['pays_adh']);
-
-        $this->string($adh::getSName($this->zdb, $adh->id))->isIdenticalTo('DURAND René');
-        $this->string($adh->getRowClass())->isIdenticalTo('active-account cotis-never');
+        $this->assertFalse($adh->hasChildren());
+        $this->assertFalse($adh->hasParent());
+        $this->assertFalse($adh->hasPicture());
+
+        $this->assertSame('No', $adh->sadmin);
+        $this->assertSame('No', $adh->sdue_free);
+        $this->assertSame('Yes', $adh->sappears_in_list);
+        $this->assertSame('No', $adh->sstaff);
+        $this->assertSame('Active', $adh->sactive);
+        $this->assertNull($adh->stitle);
+        $this->assertSame('Non-member', $adh->sstatus);
+        $this->assertSame('DURAND René', $adh->sfullname);
+        $this->assertSame('66, boulevard De Oliveira', $adh->saddress);
+        $this->assertSame('DURAND René', $adh->sname);
+
+        $this->assertSame($expecteds['adresse_adh'], $adh->getAddress());
+        $this->assertSame($expecteds['cp_adh'], $adh->getZipcode());
+        $this->assertSame($expecteds['ville_adh'], $adh->getTown());
+        $this->assertSame($expecteds['pays_adh'], $adh->getCountry());
+
+        $this->assertSame('DURAND René', $adh::getSName($this->zdb, $adh->id));
+        $this->assertSame('active-account cotis-never', $adh->getRowClass());
     }
 
     /**
      * Check members expecteds
      *
-     * @param Adherent $adh           Member instance, if any
-     * @param array    $new_expecteds Changes on expected values
+     * @param \Galette\Entity\Adherent $adh           Member instance, if any
+     * @param array                    $new_expecteds Changes on expected values
      *
      * @return void
      */
@@ -452,28 +439,29 @@ abstract class GaletteTestCase extends atoum
             $property = $this->members_fields[$key]['propname'];
             switch ($key) {
                 case 'bool_admin_adh':
-                    $this->boolean($adh->isAdmin())->isIdenticalTo($value);
+                    $this->assertSame($value, $adh->isAdmin());
                     break;
                 case 'bool_exempt_adh':
-                    $this->boolean($adh->isDueFree())->isIdenticalTo($value);
+                    $this->assertSame($value, $adh->isDueFree());
                     break;
                 case 'bool_display_info':
-                    $this->boolean($adh->appearsInMembersList())->isIdenticalTo($value);
+                    $this->assertSame($value, $adh->appearsInMembersList());
                     break;
                 case 'activite_adh':
-                    $this->boolean($adh->isActive())->isIdenticalTo($value);
+                    $this->assertSame($value, $adh->isActive());
                     break;
                 case 'mdp_adh':
                     $pw_checked = password_verify($value, $adh->password);
-                    $this->boolean($pw_checked)->isTrue();
+                    $this->assertTrue($pw_checked);
                     break;
                 case 'ddn_adh':
                     //rely on age, not on birthdate
-                    $this->variable($adh->$property)->isNotNull();
-                    $this->string($adh->getAge())->isIdenticalTo(' (28 years old)');
+                    $this->assertNotNull($adh->$property);
+                    $this->assertSame(' (28 years old)', $adh->getAge());
                     break;
                 default:
-                    $this->variable($adh->$property)->isIdenticalTo(
+                    $this->assertSame(
+                        $adh->$property,
                         $value,
                         "$property expected {$value} got {$adh->$property}"
                     );
@@ -483,36 +471,34 @@ abstract class GaletteTestCase extends atoum
 
         $d = \DateTime::createFromFormat('Y-m-d', $expecteds['ddn_adh']);
 
-        $expected_str = ' (28 years old)';
-        $this->string($adh->getAge())->isIdenticalTo($expected_str);
-        $this->boolean($adh->hasChildren())->isFalse();
-        $this->boolean($adh->hasParent())->isFalse();
-        $this->boolean($adh->hasPicture())->isFalse();
-
-        $this->string($adh->sadmin)->isIdenticalTo('No');
-        $this->string($adh->sdue_free)->isIdenticalTo('No');
-        $this->string($adh->sappears_in_list)->isIdenticalTo('No');
-        $this->string($adh->sstaff)->isIdenticalTo('No');
-        $this->string($adh->sactive)->isIdenticalTo('Active');
-        $this->variable($adh->stitle)->isNull();
-        $this->string($adh->sstatus)->isIdenticalTo('Non-member');
-        $this->string($adh->sfullname)->isIdenticalTo('HOARAU Lucas');
-        $this->string($adh->saddress)->isIdenticalTo('2, boulevard Legros');
-        $this->string($adh->sname)->isIdenticalTo('HOARAU Lucas');
-
-        $this->string($adh->getAddress())->isIdenticalTo($expecteds['adresse_adh']);
-        $this->string($adh->getZipcode())->isIdenticalTo($expecteds['cp_adh']);
-        $this->string($adh->getTown())->isIdenticalTo($expecteds['ville_adh']);
-        $this->string($adh->getCountry())->isIdenticalTo($expecteds['pays_adh']);
-
-        $this->string($adh::getSName($this->zdb, $adh->id))->isIdenticalTo('HOARAU Lucas');
-        $this->string($adh->getRowClass())->isIdenticalTo('active-account cotis-never');
+        $this->assertFalse($adh->hasChildren());
+        $this->assertFalse($adh->hasParent());
+        $this->assertFalse($adh->hasPicture());
+
+        $this->assertSame('No', $adh->sadmin);
+        $this->assertSame('No', $adh->sdue_free);
+        $this->assertSame('No', $adh->sappears_in_list);
+        $this->assertSame('No', $adh->sstaff);
+        $this->assertSame('Active', $adh->sactive);
+        $this->assertNull($adh->stitle);
+        $this->assertSame('Non-member', $adh->sstatus);
+        $this->assertSame('HOARAU Lucas', $adh->sfullname);
+        $this->assertSame('2, boulevard Legros', $adh->saddress);
+        $this->assertSame('HOARAU Lucas', $adh->sname);
+
+        $this->assertSame($expecteds['adresse_adh'], $adh->getAddress());
+        $this->assertSame($expecteds['cp_adh'], $adh->getZipcode());
+        $this->assertSame($expecteds['ville_adh'], $adh->getTown());
+        $this->assertSame($expecteds['pays_adh'], $adh->getCountry());
+
+        $this->assertSame('HOARAU Lucas', $adh::getSName($this->zdb, $adh->id));
+        $this->assertSame('active-account cotis-never', $adh->getRowClass());
     }
 
     /**
      * Look in database if test member already exists
      *
-     * @return false|ResultSet
+     * @return false|\Laminas\Db\ResultSet\ResultSet
      */
     protected function adhOneExists()
     {
@@ -536,7 +522,7 @@ abstract class GaletteTestCase extends atoum
     /**
      * Look in database if test member already exists
      *
-     * @return false|ResultSet
+     * @return false|\Laminas\Db\ResultSet\ResultSet
      */
     protected function adhTwoExists()
     {
@@ -570,6 +556,7 @@ abstract class GaletteTestCase extends atoum
         } else {
             $this->loadAdherent($rs->current()->id_adh);
         }
+        return $this->adh;
     }
 
     /**
@@ -585,6 +572,7 @@ abstract class GaletteTestCase extends atoum
         } else {
             $this->loadAdherent($rs->current()->id_adh);
         }
+        return $this->adh;
     }
 
     /**
@@ -602,10 +590,10 @@ abstract class GaletteTestCase extends atoum
         if (is_array($check)) {
             var_dump($check);
         }
-        $this->boolean($check)->isTrue();
+        $this->assertTrue($check);
 
         $store = $contrib->store();
-        $this->boolean($store)->isTrue();
+        $this->assertTrue($store);
 
         return $contrib;
     }
@@ -643,8 +631,8 @@ abstract class GaletteTestCase extends atoum
     /**
      * Check contributions expected
      *
-     * @param Contribution $contrib       Contribution instance, if any
-     * @param array        $new_expecteds Changes on expected values
+     * @param \Galette\Entity\Contribution $contrib       Contribution instance, if any
+     * @param array                        $new_expecteds Changes on expected values
      *
      * @return void
      */
@@ -660,9 +648,9 @@ abstract class GaletteTestCase extends atoum
         $due_date->sub(new \DateInterval('P1D'));
         $due_date->add(new \DateInterval('P1Y'));
 
-        $this->object($contrib->raw_date)->isInstanceOf('DateTime');
-        $this->object($contrib->raw_begin_date)->isInstanceOf('DateTime');
-        $this->object($contrib->raw_end_date)->isInstanceOf('DateTime');
+        $this->assertInstanceOf('DateTime', $contrib->raw_date);
+        $this->assertInstanceOf('DateTime', $contrib->raw_begin_date);
+        $this->assertInstanceOf('DateTime', $contrib->raw_end_date);
 
         $expecteds = [
             'id_adh' => "{$this->adh->id}",
@@ -674,7 +662,7 @@ abstract class GaletteTestCase extends atoum
         ];
         $expecteds = array_merge($expecteds, $new_expecteds);
 
-        $this->string($contrib->raw_end_date->format('Y-m-d'))->isIdenticalTo($expecteds['date_fin_cotis']);
+        $this->assertSame($expecteds['date_fin_cotis'], $contrib->raw_end_date->format('Y-m-d'));
 
         foreach ($expecteds as $key => $value) {
             $property = $this->contrib->fields[$key]['propname'];
@@ -682,13 +670,13 @@ abstract class GaletteTestCase extends atoum
                 case \Galette\Entity\ContributionsTypes::PK:
                     $ct = $this->contrib->type;
                     if ($ct instanceof \Galette\Entity\ContributionsTypes) {
-                        $this->integer((int)$ct->id)->isIdenticalTo($value);
+                        $this->assertSame($value, (int)$ct->id);
                     } else {
-                        $this->integer($ct)->isIdenticalTo($value);
+                        $this->assertSame($value, $ct);
                     }
                     break;
                 default:
-                    $this->variable($contrib->$property)->isEqualTo($value, $property);
+                    $this->assertEquals($contrib->$property, $value, $property);
                     break;
             }
         }
@@ -696,20 +684,23 @@ abstract class GaletteTestCase extends atoum
         //load member from db
         $this->adh = new \Galette\Entity\Adherent($this->zdb, $this->adh->id);
         //member is now up-to-date
-        $this->string($this->adh->getRowClass())->isIdenticalTo('active-account cotis-ok');
-        $this->string($this->adh->due_date)->isIdenticalTo($this->contrib->end_date);
-        $this->boolean($this->adh->isUp2Date())->isTrue();
-        $this->boolean($contrib->isFee())->isTrue();
-        $this->string($contrib->getTypeLabel())->isIdenticalTo('Membership');
-        $this->string($contrib->getRawType())->isIdenticalTo('membership');
-        $this->array($this->contrib->getRequired())->isIdenticalTo([
-            'id_type_cotis'     => 1,
-            'id_adh'            => 1,
-            'date_enreg'        => 1,
-            'date_debut_cotis'  => 1,
-            'date_fin_cotis'    => 1,
-            'montant_cotis'     => 1
-        ]);
+        $this->assertSame('active-account cotis-ok', $this->adh->getRowClass());
+        $this->assertSame($this->contrib->end_date, $this->adh->due_date);
+        $this->assertTrue($this->adh->isUp2Date());
+        $this->assertTrue($contrib->isFee());
+        $this->assertSame('Membership', $contrib->getTypeLabel());
+        $this->assertSame('membership', $contrib->getRawType());
+        $this->assertSame(
+            $this->contrib->getRequired(),
+            [
+                'id_type_cotis'     => 1,
+                'id_adh'            => 1,
+                'date_enreg'        => 1,
+                'date_debut_cotis'  => 1,
+                'date_fin_cotis'    => 1,
+                'montant_cotis'     => 1
+            ]
+        );
     }
 
     /**
@@ -723,7 +714,7 @@ abstract class GaletteTestCase extends atoum
         if (count($status->getList()) === 0) {
             //status are not yet instantiated.
             $res = $status->installInit();
-            $this->boolean($res)->isTrue();
+            $this->assertTrue($res);
         }
     }
 
@@ -738,7 +729,7 @@ abstract class GaletteTestCase extends atoum
         if (count($ct->getCompleteList()) === 0) {
             //status are not yet instanciated.
             $res = $ct->installInit();
-            $this->boolean($res)->isTrue();
+            $this->assertTrue($res);
         }
     }
 
@@ -751,8 +742,8 @@ abstract class GaletteTestCase extends atoum
     {
         $titles = new \Galette\Repository\Titles($this->zdb);
         if (count($titles->getList($this->zdb)) === 0) {
-            $res = $titles->installInit($this->zdb);
-            $this->boolean($res)->isTrue();
+            $res = $titles->installInit();
+            $this->assertTrue($res);
         }
     }
 
@@ -765,7 +756,7 @@ abstract class GaletteTestCase extends atoum
     {
         $models = new \Galette\Repository\PdfModels($this->zdb, $this->preferences, $this->login);
         $res = $models->installInit(false);
-        $this->boolean($res)->isTrue();
+        $this->assertTrue($res);
     }
 
     /**
@@ -789,7 +780,7 @@ abstract class GaletteTestCase extends atoum
     protected function logSuperAdmin(): void
     {
         $this->login->logAdmin('superadmin', $this->preferences);
-        $this->boolean($this->login->isLogged())->isTrue();
-        $this->boolean($this->login->isSuperAdmin())->isTrue();
+        $this->assertTrue($this->login->isLogged());
+        $this->assertTrue($this->login->isSuperAdmin());
     }
 }
index 38c85bc9e478899777fa7674fa87a744e5de3085..10b73558ec4bb735518163585323bedc9ee998f3 100644 (file)
@@ -38,6 +38,7 @@
 namespace Galette\Core\test\units;
 
 use atoum;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Update tests
@@ -51,7 +52,7 @@ use atoum;
  * @link      http://galette.tuxfamily.org
  * @since     2021-05-06
  */
-class Install extends atoum
+class Install extends TestCase
 {
     private \Galette\Core\Db $zdb;
     private array $flash_data;
@@ -61,11 +62,9 @@ class Install extends atoum
     /**
      * Set up tests
      *
-     * @param stgring $method Method tested
-     *
      * @return void
      */
-    public function beforeTestMethod($method)
+    public function setUp(): void
     {
         setlocale(LC_ALL, 'en_US');
 
@@ -91,14 +90,12 @@ class Install extends atoum
     /**
      * Tear down tests
      *
-     * @param string $method Calling method
-     *
      * @return void
      */
-    public function afterTestMethod($method)
+    public function tearDown(): void
     {
         if (TYPE_DB === 'mysql') {
-            $this->array($this->zdb->getWarnings())->isIdenticalTo([]);
+            $this->assertSame([], $this->zdb->getWarnings());
         }
     }
 
@@ -115,12 +112,12 @@ class Install extends atoum
             $this->zdb->type_db,
             '0.6'
         );
-        $this->array($update_scripts)->size->isGreaterThan(5);
+        $this->assertGreaterThan(5, count($update_scripts));
 
         $install->setMode(\Galette\Core\Install::UPDATE);
         $errors = [];
         $install->setDbType($this->zdb->type_db, $errors);
-        $this->array($errors)->isIdenticalTo([]);
+        $this->assertSame([], $errors);
 
         $install->setInstalledVersion('0.60');
         $install->setTablesPrefix(PREFIX_DB);
@@ -128,10 +125,13 @@ class Install extends atoum
 
         $report = $install->getInitializationReport();
         foreach ($report as $entry) {
-            $this->boolean($entry['res'])->isTrue(($entry['debug'] ?? '') . "\n" . ($entry['query'] ?? ''));
+            $this->assertTrue(
+                $entry['res'],
+                ($entry['debug'] ?? '') . "\n" . ($entry['query'] ?? '')
+            );
         }
 
-        $this->boolean($exec)->isTrue();
-        $this->string($this->zdb->getDbVersion())->isIdenticalTo(GALETTE_DB_VERSION);
+        $this->assertTrue($exec);
+        $this->assertSame(GALETTE_DB_VERSION, $this->zdb->getDbVersion());
     }
 }
index 8b47b02ed78219420ffb370b2780cf8b372ad475..663c79eb58ea7d365751efaa45a58c797bb953b2 100644 (file)
@@ -15,5 +15,5 @@ Please read atoum documentation at http://docs.atoum.org/ if you want
 to learn more.
 
 Note that tests respects Galette's path model under lib directory,
-but in an additionnal tests/units/ directory. For example, Plugins
+but in an additional tests/units/ directory. For example, Plugins
 (\Galette\Core\Plugins) test class will be \Galette\Core\tests\units\Plugins.
index 278b59cc9a0f3e48f8ca938defa05a4496056753..8e0455208bce35eb29fe151c8fd684e8af4ae89e 100755 (executable)
@@ -104,4 +104,13 @@ if (!defined('_CURRENT_THEME_PATH')) {
     );
 }
 
+$updateenv = getenv('UPDATE');
+if (
+    $updateenv !== 'UPDATE'
+) {
+    //do not initialize Ttiles on update tests
+    $titles = new \Galette\Repository\Titles($zdb);
+    $res = $titles->installInit($zdb);
+}
+
 require_once __DIR__ . '/GaletteTestCase.php';
diff --git a/tests/clover.php b/tests/clover.php
deleted file mode 100644 (file)
index bdaf0d1..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * Atoum code coverage in clover format, for scrutinizer
- * To use it, you can choose either:
- *  * php path/to/test/file -c path/to/this/file
- *  * php path/to/atoum/scripts/runner.php -c path/to/this/file -f path/to/test/file
- *
- * PHP version 5
- *
- * Copyright © 2020 The Galette Team
- *
- * This file is part of Galette (http://galette.tuxfamily.org).
- *
- * Galette is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Galette is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Galette. If not, see <http://www.gnu.org/licenses/>.
- *
- * @category  Core
- * @package   GaletteTests
- *
- * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2020 The Galette Team
- * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
- * @link      http://galette.tuxfamily.org
- * @since     2020-06-14
- */
-
-use atoum\atoum;
-
-$script->addDefaultReport();
-
-$cloverWriter = new atoum\writers\file(__DIR__ . '/clover.xml');
-$cloverReport = new atoum\reports\asynchronous\clover();
-$cloverReport->addWriter($cloverWriter);
-
-$runner->addReport($cloverReport);
diff --git a/tests/coverage.php b/tests/coverage.php
deleted file mode 100644 (file)
index 6690626..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * Atoum code coverage in HTML format.
- * To use it, you can choose either:
- *  * php path/to/test/file -c path/to/this/file
- *  * php path/to/atoum/scripts/runner.php -c path/to/this/file -f path/to/test/file
- *
- * PHP version 5
- *
- * Copyright © 2007-2014 The Galette Team
- *
- * This file is part of Galette (http://galette.tuxfamily.org).
- *
- * Galette is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Galette is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Galette. If not, see <http://www.gnu.org/licenses/>.
- *
- * @category  Core
- * @package   GaletteTests
- *
- * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2013-2014 The Galette Team
- * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
- * @version   SVN: $Id$
- * @link      http://galette.tuxfamily.org
- * @since     2013-01-13
- */
-
-use atoum\atoum;
-
-$coverageField = new atoum\report\fields\runner\coverage\html(
-    'Galette',
-    __DIR__ . '/coverage'
-);
-
-$coverageField->setRootUrl(
-    'file://' . realpath(__DIR__ . '/coverage/')
-);
-
-$script
-    ->addDefaultReport()
-    ->addField($coverageField);
index 4db30e47636944e0d555529549607ca8b9221bef..156932cbcd43104e1889dc4b0eb3329102e193d2 100644 (file)
@@ -1,10 +1,12 @@
 <?php
+
 /**
  * Test translation features.
  *
  * example (see galette/lan/Makefile for up to date command):
  * xgettext translations.php --keyword=_T --keyword=__ --keyword=_Tn:1,2 --keyword=_Tx:1c,2 --keyword=_Tnx:1c,2,3  -L PHP --from-code=UTF-8 --add-comments=TRANS --force-po -o php_translations.pot
  */
+
 _T('Translation, no domain');
 __('Another known syntax');
 _T('Translation, galette domain', 'galette');