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
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)
"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,
"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": {
$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) {
});
$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;
});
});
$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;
});
$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 {
}
} else {
$mstring = str_replace('%s', $name, $string);
- if (!extension_loaded($name)) {
+ if (!$this->isExtensionLoaded($name)) {
if ($required) {
$this->missing[] = $mstring;
} else {
{
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);
+ }
}
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.'
);
return $url;
}
+
+ /**
+ * Check if allow_url_fopen is enabled
+ *
+ * @return boolean
+ */
+ protected function allowURLFOpen(): bool
+ {
+ return ini_get('allow_url_fopen');
+ }
}
_T("Unknown ACL rule '%acl'!")
)
);
- break;
}
if (!$go) {
Analog::log(
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;
}
}
namespace Galette\Controllers\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
use Galette\GaletteTestCase;
use Slim\Psr7\Headers;
use Slim\Psr7\Request;
/**
* 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();
*
* @return void
*/
- public function tearDown()
+ public function tearDown(): void
{
$this->zdb = new \Galette\Core\Db();
$this->cleanHistory();
}
+ /**
+ * Cleanup after class
+ *
+ * @return void
+ */
+ public static function tearDownAfterClass(): void
+ {
+ $self = new self(__METHOD__);
+ $self->tearDown();
+ }
+
/**
* Test store models
*
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();
$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);
}
/**
//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]);
}
/**
//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
$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
//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]);
}
/**
//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]);
}
/**
//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
);
$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]);
}
/**
//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]);
}
}
namespace Galette\Core\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* CheckModules tests class
* @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();
}
/**
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'));
}
/**
*/
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));
}
/**
$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));
}
}
namespace Galette\Core\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* Database tests class
* @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();
}
/**
* 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']);
{
$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,
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);
}
/**
PORT_DB,
NAME_DB
);
- $this->boolean($res)->isTrue();
+ $this->assertTrue($res);
}
/**
);
$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);
}
/**
$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']);
}
/**
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;
}
}
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);
}
/**
'WHERE `p`.`nom_pref` = \'pref_nom\'';
}
- $this->string($query)->isIdenticalTo($expected);
+ $this->assertSame($expected, $query);
}
/**
public function testSelectAll()
{
$all = $this->db->selectAll('preferences');
- $this->object($all)->isInstanceOf('Laminas\Db\ResultSet\ResultSet');
+ $this->assertInstanceOf('Laminas\Db\ResultSet\ResultSet', $all);
}
/**
$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);
}
/**
*/
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'
$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);
}
/**
*/
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());
}
/**
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);
}
/**
*/
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());
}
/**
{
$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)
+ );
}
/**
sort($tables);
sort($expected);
- $this->array($tables)
- ->hasSize(count($expected), print_r($tables, true) . ' ' . print_r($expected, true))
- ->isIdenticalTo($expected);
+ $this->assertSame($expected, $tables);
}
/**
*/
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);
}
/**
"'somethin'' to \"quote\"'" :
"'somethin\\' to \\\"quote\\\"'";
- $this->string($quoted)
- ->isIdenticalTo($expected);
+ $this->assertSame($expected, $quoted);
}
/**
$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);
}
/**
*/
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);
}
/**
{
$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);
}
}
*
* PHP version 5
*
- * Copyright © 2021 The Galette Team
+ * Copyright © 2021-2023 The Galette Team
*
* This file is part of Galette (http://galette.tuxfamily.org).
*
* @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
* @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
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
*/
//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);
}
}
*/
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);
}
/**
$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();
}
namespace Galette\Core\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* I18n tests class
* @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;
/**
* 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(
/**
* 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->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());
}
/**
{
$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);
}
}
{
$list = $this->i18n->getArrayList();
- $this->array($list)
- ->size->isGreaterThan(3);
+ $this->assertGreaterThan(3, count($list));
}
/**
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);
}
/**
$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();
$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);
}
/**
$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);
}
/**
$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);
}
}
namespace Galette\Core\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* Install tests class
* @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();
/**
* 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());
}
}
$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);
}
/**
'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',
);
//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'
//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();
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);
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);
}
/**
$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);
}
/**
$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);
}
/**
$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);
}
/**
*/
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');
}
/**
$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);
}
/**
$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);
}
/**
$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);
}
/**
$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);
}
/**
$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);
}
}
namespace Galette\Core\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* L10n tests class
* @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;
/**
* 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(
/**
* 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);
]);
$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');
]);
$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']);
}
}
}
/**
* 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();
/**
* 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);
$this->zdb->execute($delete);
$this->cleanHistory();
+ parent::tearDown();
}
/**
$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;
$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
+ ]
+ );
}
/**
$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();
->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'));
}
/**
$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']);
}
/**
]
);
- $this->exception(
- function () use ($insert) {
- $this->zdb->execute($insert);
- }
- )
- ->hasMessage('Duplicate entry');
+ $this->expectExceptionMessage('Duplicate entry');
+ $this->zdb->execute($insert);
}
/**
$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}",
];
$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'];
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;
}
}
//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());
}
}
*
* @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();
}
/**
*/
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);
}
/**
*/
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);
}
/**
*/
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);
}
/**
*/
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));
}
/**
*/
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);
}
/**
*/
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'));
}
/**
*/
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'));
}
/**
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();
$status = new \Galette\Entity\Status($this->zdb);
if (count($status->getList()) === 0) {
$res = $status->installInit();
- $this->boolean($res)->isTrue();
+ $this->assertTrue($res);
}
$data = [
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));
}
/**
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));
}
/**
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');
'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));
}
/**
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');
}
}
namespace Galette\Core\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* Picture tests class
* @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();
/**
* 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(), []);
}
}
$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());
}
}
namespace Galette\Core\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* Password tests class
* @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;
/**
* 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);
/**
* 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());
}
}
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));
}
/**
$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(
$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();
}
$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();
}
*/
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);
}
/**
*/
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);
}
/**
*/
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());
}
/**
*/
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);
}
/**
*/
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);
}
}
namespace Galette\Core\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* Picture tests class
* @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;
/**
* 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();
/**
* 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());
}
}
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()
+ );
}
/**
*/
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());
}
/**
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'));
}
/**
/*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())
'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 = [
'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));
}
}
*/
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)
+ );
}
}
namespace Galette\Core\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* Plugins tests class
* @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;
/**
* 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);
/**
* 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());
}
}
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);
}
/**
*/
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'));
}
/**
*/
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']));
}
/**
*/
public function testModuleRoot()
{
- $this->variable($this->plugins->moduleRoot('plugin-test2'))
- ->isIdenticalTo($this->plugin2['root']);
+ $this->assertSame($this->plugin2['root'], $this->plugins->moduleRoot('plugin-test2'));
}
/**
{
$this->plugins->resetModulesList();
- $this->array($this->plugins->getModules())
- ->isempty();
+ $this->assertEmpty($this->plugins->getModules());
}
/**
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');
}
/**
*/
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');
}
}
namespace Galette\Core\test\units;
-use atoum;
-use Galette\Middleware\Authenticate;
-use Slim\Routing\RouteParser;
+use PHPUnit\Framework\TestCase;
/**
* Preferences tests class
* @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;
/**
* 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();
$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);
'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);
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;
}
}
//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';
$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 = '';
sort($fields_names);
sort($expected);
- $this->array($fields_names)->isIdenticalTo($expected);
+ $this->assertSame($expected, $fields_names);
}
/**
$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);
}
/**
$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(
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);
}
/**
*
* @return array
*/
- protected function sizesProvider()
+ public static function sizesProvider()
{
return [
[//defaults
$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());
}
/**
*
* @return array
*/
- protected function colorsProvider(): array
+ public static function colorsProvider(): array
{
return [
[
{
$prop = 'pref_card_' . $prop;
$this->preferences->$prop = $color;
- $this->string($this->preferences->$prop)->isIdenticalTo($expected);
+ $this->assertSame($expected, $this->preferences->$prop);
}
/**
$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 = [
$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 = [];
}
$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)
+ );
}
/**
*/
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());
}
/**
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']
+ );
}
}
namespace Galette\Core\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* Picture tests class
* @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();
/**
* 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());
}
}
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());
}
}
namespace Galette\DynamicFields\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* Dynamic booleans test
* @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;
/**
* 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);
public function testConstructor()
{
$o = new \Galette\DynamicFields\Boolean($this->zdb, 10);
- $this->variable($o->getId())
- ->isNull();
+ $this->assertNull($o->getId());
}
/**
*/
public function testGetTypeName()
{
- $this->variable($this->bool->getTypeName())
- ->isIdenticalTo(_T('boolean'));
+ $this->assertSame(_T('boolean'), $this->bool->getTypeName());
}
/**
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());
}
}
namespace Galette\DynamicFields\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* Dynamic choice test
* @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;
/**
* 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);
public function testConstructor()
{
$o = new \Galette\DynamicFields\Choice($this->zdb, 10);
- $this->variable($o->getId())
- ->isNull();
+ $this->assertNull($o->getId());
}
/**
*/
public function testGetTypeName()
{
- $this->variable($this->choice->getTypeName())
- ->isIdenticalTo(_T('choice'));
+ $this->assertSame(_T('choice'), $this->choice->getTypeName());
}
/**
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());
}
}
namespace Galette\DynamicFields\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* Dynamic date test
* @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;
/**
* 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);
public function testConstructor()
{
$o = new \Galette\DynamicFields\Date($this->zdb, 10);
- $this->variable($o->getId())
- ->isNull();
+ $this->assertNull($o->getId());
}
/**
*/
public function testGetTypeName()
{
- $this->variable($this->date->getTypeName())
- ->isIdenticalTo(_T('date'));
+ $this->assertSame(_T('date'), $this->date->getTypeName());
}
/**
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());
}
}
namespace Galette\DynamicFields\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* Dynamic fields test
* @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();
}
/**
* 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);
*/
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',
$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());
}
/**
*
* @return array
*/
- protected function permsProvider(): array
+ public static function permsProvider(): array
{
return [
[
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());
}
/**
$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());
}
/**
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());
}
/**
*
* @return \string[][]
*/
- protected function formNamesProvider(): array
+ public static function formNamesProvider(): array
{
return [
[
*/
public function testGetFormTitle(string $form, string $expected)
{
- $this->string(\Galette\DynamicFields\DynamicField::getFormTitle($form))->isIdenticalTo($expected);
+ $this->assertSame($expected, \Galette\DynamicFields\DynamicField::getFormTitle($form));
}
/**
*/
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));
}
/**
$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());
}
/**
$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));
}
/**
$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());
}
/**
];
$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));
}
/**
$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());
}
}
namespace Galette\DynamicFields\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* Dynamic file test
* @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;
/**
* 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);
public function testConstructor()
{
$o = new \Galette\DynamicFields\File($this->zdb, 10);
- $this->variable($o->getId())
- ->isNull();
+ $this->assertNull($o->getId());
}
/**
*/
public function testGetTypeName()
{
- $this->variable($this->file->getTypeName())
- ->isIdenticalTo(_T('file'));
+ $this->assertSame(_T('file'), $this->file->getTypeName());
}
/**
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());
}
}
namespace Galette\DynamicFields\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* Dynamic single line test
* @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;
/**
* 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);
public function testConstructor()
{
$o = new \Galette\DynamicFields\Line($this->zdb, 10);
- $this->variable($o->getId())
- ->isNull();
+ $this->assertNull($o->getId());
}
/**
*/
public function testGetTypeName()
{
- $this->variable($this->line->getTypeName())
- ->isIdenticalTo(_T('single line'));
+ $this->assertSame(_T('single line'), $this->line->getTypeName());
}
/**
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());
}
}
namespace Galette\DynamicFields\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* Dynamic separator test
* @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;
/**
* 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);
public function testConstructor()
{
$o = new \Galette\DynamicFields\Separator($this->zdb, 10);
- $this->variable($o->getId())
- ->isIdenticalTo(null);
+ $this->assertNull($o->getId());
}
/**
*/
public function testGetTypeName()
{
- $this->variable($this->separator->getTypeName())
- ->isIdenticalTo(_T('separator'));
+ $this->assertSame(_T('separator'), $this->separator->getTypeName());
}
/**
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());
}
}
namespace Galette\DynamicFields\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* Dynamic texts test
* @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;
/**
* 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);
public function testConstructor()
{
$o = new \Galette\DynamicFields\Text($this->zdb, 10);
- $this->variable($o->getId())
- ->isNull();
+ $this->assertNull($o->getId());
}
/**
*/
public function testGetTypeName()
{
- $this->variable($this->text->getTypeName())
- ->isIdenticalTo(_T('free text'));
+ $this->assertSame(_T('free text'), $this->text->getTypeName());
}
/**
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());
}
}
*
* @return void
*/
- public function tearDown()
+ public function tearDown(): void
{
$this->zdb = new \Galette\Core\Db();
/**
* 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();
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);
}
/**
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();
'dynamics' => false,
'socials' => false
];
- $this->array($adh->deps)->isIdenticalTo($expected);
+ $this->assertSame($expected, $adh->deps);
$expected = [
'picture' => false,
->enableDep('dues')
->enableDep('dynamics')
->enableDep('children');
- $this->array($adh->deps)->isIdenticalTo($expected);
+ $this->assertSame($expected, $adh->deps);
$expected = [
'picture' => false,
'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,
'socials' => true
];
$adh->enableAllDeps('children');
- $this->array($adh->deps)->isIdenticalTo($expected);
+ $this->assertSame($expected, $adh->deps);
}
/**
{
$adh = $this->adh;
- $this->exception(
- function () use ($adh) {
- $adh->row_classes;
- }
- )->isInstanceOf('RuntimeException');
+ $this->expectException('RuntimeException');
+ $adh->row_classes;
}
/**
$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);
}
/**
$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);
\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');
$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' => '',
];
$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' => '',
];
$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',
];
$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);
}
/**
$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());
}
/**
$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));
}
/**
$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);
}
/**
'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);
}
/**
'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);
}
/**
//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();
//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));
}
/**
*
* @return array[]
*/
- protected function nameCaseProvider(): array
+ public static function nameCaseProvider(): array
{
return [
[
*/
public function testsGetNameWithCase(string $name, string $surname, $title, $id, $nick, string $expected)
{
- $this->string(
+ $this->assertSame(
+ $expected,
\Galette\Entity\Adherent::getNameWithCase(
$name,
$surname,
$id,
$nick,
)
- )->isIdenticalTo($expected);
+ );
}
}
/**
* 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);
/**
* 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);
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);
}
/**
//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);
}
/**
'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 = [
$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 = [
$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);
}
/**
$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';
$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();
$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;
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);
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);
];
$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();
}
/**
*/
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')
+ );
}
/**
*/
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();
$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));
}
/**
$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());
}
/**
$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();
//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());
}
}
namespace Galette\Entity\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* Preferences tests class
* @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;
/**
* Set up tests
*
- * @param string $method Calling method
- *
* @return void
*/
- public function beforeTestMethod($method)
+ public function setUp(): void
{
$this->zdb = new \Galette\Core\Db();
'sexe_adh',
'parent_id'
];
- $this->array($nrequired)->isIdenticalTo($expected);
+ $this->assertSame($expected, $nrequired);
}
/**
*/
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(
'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,
$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']);
}
/**
*/
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]);
}
/**
$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);
}
/**
$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);
}
/**
//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;
$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);
}
/**
*/
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'));
}
/**
break;
}
}
- $this->boolean($exists)->isTrue();
+ $this->assertTrue($exists);
$delete = $this->zdb->delete(\Galette\Entity\FieldsConfig::TABLE);
$delete->where(
]
);
$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(
);
$categorized = $fields_config->getCategorizedFields();
- $this->array($categorized)->isIdenticalTo($categorized_init);
+ $this->assertSame($categorized_init, $categorized);
}
/**
$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']));
}
/**
$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']);
}
}
namespace Galette\Entity\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
use Galette\GaletteTestCase;
use Laminas\Db\Adapter\Adapter;
/**
* 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();
}
/**
$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());
}
/**
$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());
}
/**
$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());
}
/**
$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());
}
/**
$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));
}
}
namespace Galette\Entity\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* ListsConfig tests class
* @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;
/**
* Set up tests
*
- * @param string $method Calling method
- *
* @return void
*/
- public function beforeTestMethod($method)
+ public function setUp(): void
{
$this->zdb = new \Galette\Core\Db();
/**
* 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();
}
$new_list[] = $this->lists_config->getField($key);
}
- $this->boolean($this->lists_config->setListFields($new_list))->isTrue();
+ $this->assertTrue($this->lists_config->setListFields($new_list));
}
/**
$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);
}
/**
$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 = [
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;
$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.
}
$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 = [
$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']);
}
}
}
namespace Galette\Entity\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* Payment type tests
* @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;
/**
* 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);
$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();
}
$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(
)
);
$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(
)
);
$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(
)
);
$results = $this->zdb->execute($select);
- $this->integer($results->count())->isIdenticalTo(0);
+ $this->assertSame(0, $results->count());
}
}
/**
* 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(
/**
* 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]);
'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}/',
'_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}/',
'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());
}
/**
*
* @return array
*/
- protected function typesProvider(): array
+ public static function typesProvider(): array
{
return [
[
*/
public function testGetypeClass($type, $expected)
{
- $this->string(\Galette\Entity\PdfModel::getTypeClass($type))->isIdenticalTo($expected);
+ $this->assertSame($expected, \Galette\Entity\PdfModel::getTypeClass($type));
}
/**
$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',
$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;
$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']));
}
/**
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;
}
$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);
}
}
+++ /dev/null
-<?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);
- }
-}
--- /dev/null
+<?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));
+ }
+}
/**
* 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();
$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);
}
/**
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));
}
/**
*/
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));
}
}
namespace Galette\Entity\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
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 = [];
/**
* 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(
/**
* 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();
}
$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(
)
);
$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(
)
);
$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(
)
);
$results = $this->zdb->execute($select);
- $this->integer($results->count())->isIdenticalTo(0);
+ $this->assertSame(0, $results->count());
}
/**
$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)',
$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);
}
}
}
namespace Galette\Entity\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
use Galette\GaletteTestCase;
use Laminas\Db\Adapter\Adapter;
$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()) {
$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)',
$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);
}
}
}
namespace Galette\Entity\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
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 = [];
/**
* Set up tests
*
- * @param string $method Calling method
- *
* @return void
*/
- public function beforeTestMethod($method)
+ public function setUp(): void
{
$this->zdb = new \Galette\Core\Db();
}
/**
* 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();
}
$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));
}
}
/**
* 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();
/**
* 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);
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;
}
*/
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);
}
/**
$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);
}
/**
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);
}
/**
*/
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)
+ );
}
/**
*/
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();
$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));
}
/**
$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));
}
/**
$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();
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());
}
/**
$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 = [
$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 = [
];
$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));
}
}
}
namespace Galette\IO\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
use Galette\Entity\Adherent;
use Galette\DynamicFields\DynamicField;
use Galette\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);
$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)
);
$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) {
}
$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
$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 = [];
$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");
}
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;
}
]);
$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']
);
}
}
$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';
$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';
$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'];
namespace Galette\IO\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* News tests class
* @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;
//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));
}
/**
//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(
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(
)
);
$isnewdate = $mnewdate > $mdate;
- $this->boolean($isnewdate)->isTrue;
+ $this->assertTrue($isnewdate);
//drop file finally
unlink($file);
*/
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());
}
}
*
* @return void
*/
- public function tearDown()
+ public function tearDown(): void
{
$this->deleteGroups();
}
\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);
*
* @return array[]
*/
- protected function groupsProvider(): array
+ public static function groupsProvider(): array
{
return [
[
{
$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();
$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();
$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();
}
}
*/
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);
}
}
{
$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']);
$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);
}
/**
*/
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);
$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));
}
}
/**
* 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();
$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);
}
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
'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.
$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',
'error' => 0
)
);
- $this->integer((int)$member->picture->store($_FILES['photo'], true))->isGreaterThan(0);
+ $this->assertGreaterThan(0, (int)$member->picture->store($_FILES['photo'], true));
}
}
$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();
$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();
$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();
$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();
$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();
$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();
$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();
$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();
$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();
$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();
$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();
$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
$members = new \Galette\Repository\Members($filters);
$list = $members->getList();
- $this->integer($list->count())->isIdenticalTo(0);*/
+ $this->assertSame(0, $list->count());*/
// ADVANCED SEARCH
$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();
$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();
$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();
$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();
$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();
$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();
$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,
$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();
$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,
$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
$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 = [];
$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';
$members = new \Galette\Repository\Members($filters);
$list = $members->getList();
- $this->integer($list->count())->isIdenticalTo(0);
+ $this->assertSame(0, $list->count());
}
/**
$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());
}
/**
{
$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();
$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();
$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());
}
/**
{
$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);
'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;
'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);
$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
'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);
'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);
$members = new \Galette\Repository\Members();
$this->logSuperAdmin();
$dropdown = $members->getDropdownMembers($this->zdb, $this->login);
- $this->array($dropdown)->hasSize(10);
+ $this->assertCount(10, $dropdown);
}
/**
{
$members = new \Galette\Repository\Members();
- $this->boolean($members->getArrayList($this->mids[0]))->isFalse();
+ $this->assertFalse($members->getArrayList($this->mids[0]));
$selected = [
$this->mids[0],
$this->mids[9]
];
$list = $members->getArrayList($selected, ['nom_adh', 'prenom_adh']);
- $this->array($list)->hasSize(4);
+ $this->assertCount(4, $list);
}
}
/**
* 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();
}
$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
);
/**
* 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();
}
//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
);
}
namespace Galette\Repository\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
use Galette\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();
/**
* 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);
{
//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();
]);
$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
]);
$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
]);
$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;
]);
$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();
$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();
$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;
]);
$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;
]);
$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;
]);
$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;
]);
$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;
$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;
]);
$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));
}
}
/* 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
* @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;
/**
* 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;
/**
* 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);
*
* @return array
*/
- protected function passProvider()
+ public static function passProvider()
{
return [
// [strength, password, errors]
/**
* 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
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);
}
/**
*
* @return array
*/
- protected function blacklistProvider()
+ public static function blacklistProvider()
{
return [
['galette', true],
/**
* 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));
}
/**
$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 :(
if (is_array($check)) {
var_dump($check);
}
- $this->boolean($check)->isTrue();
+ $this->assertTrue($check);
$password = new \Galette\Util\Password($this->preferences);
$password->setAdherent($adh);
$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'));
}
}
namespace Galette\Util\test\units;
-use atoum;
+use PHPUnit\Framework\TestCase;
/**
* Telemetry tests class
* @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;
/**
* 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 = '';
/**
* 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);
);
$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(
}
$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);
}
/**
$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']);
}
}
*/
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']);
}
/**
$this->plugins
);
$result = $telemetry->grabPhpInfos();
- $this->array($result)->isIdenticalTo($expected);
+ $this->assertSame($expected, $result);
}
/**
*/
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')
];
$this->plugins
);
$result = $telemetry->grabOsInfos();
- $this->array($result)->isIdenticalTo($expected);
+ $this->assertSame($expected, $result);
}
/**
);
$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'
+ ]
+ );
}
}
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
* @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 */
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;
$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();
$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());
}
}
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;
}
/**
* 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
*/
'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',
$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}"
);
$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
*/
$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}"
);
$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()
{
/**
* Look in database if test member already exists
*
- * @return false|ResultSet
+ * @return false|\Laminas\Db\ResultSet\ResultSet
*/
protected function adhTwoExists()
{
} else {
$this->loadAdherent($rs->current()->id_adh);
}
+ return $this->adh;
}
/**
} else {
$this->loadAdherent($rs->current()->id_adh);
}
+ return $this->adh;
}
/**
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;
}
/**
* 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
*/
$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}",
];
$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'];
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;
}
}
//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
+ ]
+ );
}
/**
if (count($status->getList()) === 0) {
//status are not yet instantiated.
$res = $status->installInit();
- $this->boolean($res)->isTrue();
+ $this->assertTrue($res);
}
}
if (count($ct->getCompleteList()) === 0) {
//status are not yet instanciated.
$res = $ct->installInit();
- $this->boolean($res)->isTrue();
+ $this->assertTrue($res);
}
}
{
$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);
}
}
{
$models = new \Galette\Repository\PdfModels($this->zdb, $this->preferences, $this->login);
$res = $models->installInit(false);
- $this->boolean($res)->isTrue();
+ $this->assertTrue($res);
}
/**
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());
}
}
namespace Galette\Core\test\units;
use atoum;
+use PHPUnit\Framework\TestCase;
/**
* Update tests
* @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;
/**
* Set up tests
*
- * @param stgring $method Method tested
- *
* @return void
*/
- public function beforeTestMethod($method)
+ public function setUp(): void
{
setlocale(LC_ALL, 'en_US');
/**
* 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->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);
$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());
}
}
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.
);
}
+$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';
+++ /dev/null
-<?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);
+++ /dev/null
-<?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);
<?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');