mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
Merge branch 'release/1.7.4'
This commit is contained in:
commit
dbfc108fec
4
.github/workflows/tests.yaml
vendored
4
.github/workflows/tests.yaml
vendored
|
|
@ -27,7 +27,7 @@ jobs:
|
|||
extensions: opcache, gd
|
||||
coverage: none
|
||||
env:
|
||||
COMPOSER_TOKEN: ${{ secrets.GLOBAL_TOKEN }}
|
||||
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Update composer
|
||||
run: composer update
|
||||
|
|
@ -67,6 +67,6 @@ jobs:
|
|||
author_name: 'Github Action Tests'
|
||||
text: '💥 Automated Test Failure'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GLOBAL_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||
if: env.WORKFLOW_CONCLUSION == 'failure'
|
||||
|
|
|
|||
20
CHANGELOG.md
20
CHANGELOG.md
|
|
@ -1,3 +1,23 @@
|
|||
# v1.7.4
|
||||
## 02/01/2021
|
||||
|
||||
1. [](#new)
|
||||
* Added `FlexForm::setSubmitMethod()` to customize form submit action
|
||||
1. [](#improved)
|
||||
* Improved GPM error handling
|
||||
1. [](#bugfix)
|
||||
* Fixed `bin/gpm uninstall` script not working because of bad typehint [#3172](https://github.com/getgrav/grav/issues/3172)
|
||||
* Fixed `login: visibility_requires_access` not working in pages [#3176](https://github.com/getgrav/grav/issues/3176)
|
||||
* Fixed cannot change image format [#3173](https://github.com/getgrav/grav/issues/3173)
|
||||
* Fixed saving page in expert mode [#3174](https://github.com/getgrav/grav/issues/3174)
|
||||
* Fixed exception in `$flexPage->frontmatter()` method when setting value
|
||||
* Fixed `onBlueprintCreated` event being called multiple times in `Flex Pages` [grav-plugin-flex-objects#97](https://github.com/trilbymedia/grav-plugin-flex-objects/issues/97)
|
||||
* Fixed wrong ordering in page collections if `intl` extension has been enabled [#3167](https://github.com/getgrav/grav/issues/3167)
|
||||
* Fixed page redirect to the first visible child page (needs to be routable and published, too)
|
||||
* Fixed untranslated module pages showing up in the menu
|
||||
* Fixed page save failing because of uploaded images [#3191](https://github.com/getgrav/grav/issues/3191)
|
||||
* Fixed incorrect config lookup for loading in `ImageLoadingTrait` [#3192](https://github.com/getgrav/grav/issues/3192)
|
||||
|
||||
# v1.7.3
|
||||
## 01/21/2021
|
||||
|
||||
|
|
|
|||
|
|
@ -58,19 +58,19 @@
|
|||
"willdurand/negotiation": "^3.0",
|
||||
"itsgoingd/clockwork": "^5.0",
|
||||
"enshrined/svg-sanitize": "~0.13",
|
||||
"symfony/http-client": "^4.4"
|
||||
"symfony/http-client": "^4.4",
|
||||
"composer/semver": "^1.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"codeception/codeception": "^4.1",
|
||||
"phpstan/phpstan": "^0.12",
|
||||
"phpstan/phpstan-deprecation-rules": "^0.12",
|
||||
"phpunit/php-code-coverage": "~9.2",
|
||||
"fzaninotto/faker": "^1.9",
|
||||
"victorjonsson/markdowndocs": "dev-master",
|
||||
"codeception/module-asserts": "^1.3",
|
||||
"codeception/module-phpbrowser": "^1.0"
|
||||
},
|
||||
"provide": {
|
||||
"replace": {
|
||||
"symfony/polyfill-php72": "*",
|
||||
"symfony/polyfill-php73": "*"
|
||||
},
|
||||
|
|
|
|||
385
composer.lock
generated
385
composer.lock
generated
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "62ae3addf676d9092ec59fb139b837c7",
|
||||
"content-hash": "32b6cbbe234714397aea3c6ed1eddf6b",
|
||||
"packages": [
|
||||
{
|
||||
"name": "antoligy/dom-string-iterators",
|
||||
|
|
@ -130,6 +130,86 @@
|
|||
],
|
||||
"time": "2021-01-12T12:10:35+00:00"
|
||||
},
|
||||
{
|
||||
"name": "composer/semver",
|
||||
"version": "1.7.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/composer/semver.git",
|
||||
"reference": "647490bbcaf7fc4891c58f47b825eb99d19c377a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/composer/semver/zipball/647490bbcaf7fc4891c58f47b825eb99d19c377a",
|
||||
"reference": "647490bbcaf7fc4891c58f47b825eb99d19c377a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.3.2 || ^7.0 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.5 || ^5.0.5"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Composer\\Semver\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nils Adermann",
|
||||
"email": "naderman@naderman.de",
|
||||
"homepage": "http://www.naderman.de"
|
||||
},
|
||||
{
|
||||
"name": "Jordi Boggiano",
|
||||
"email": "j.boggiano@seld.be",
|
||||
"homepage": "http://seld.be"
|
||||
},
|
||||
{
|
||||
"name": "Rob Bast",
|
||||
"email": "rob.bast@gmail.com",
|
||||
"homepage": "http://robbast.nl"
|
||||
}
|
||||
],
|
||||
"description": "Semver library that offers utilities, version constraint parsing and validation.",
|
||||
"keywords": [
|
||||
"semantic",
|
||||
"semver",
|
||||
"validation",
|
||||
"versioning"
|
||||
],
|
||||
"support": {
|
||||
"irc": "irc://irc.freenode.org/composer",
|
||||
"issues": "https://github.com/composer/semver/issues",
|
||||
"source": "https://github.com/composer/semver/tree/1.7.2"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://packagist.com",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/composer",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/composer/composer",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2020-12-03T15:47:16+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/cache",
|
||||
"version": "1.10.2",
|
||||
|
|
@ -416,16 +496,16 @@
|
|||
},
|
||||
{
|
||||
"name": "enshrined/svg-sanitize",
|
||||
"version": "0.13.3",
|
||||
"version": "0.14.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/darylldoyle/svg-sanitizer.git",
|
||||
"reference": "bc66593f255b7d2613d8f22041180036979b6403"
|
||||
"reference": "beff89576a72540ee99476aeb9cfe98222e76fb8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/darylldoyle/svg-sanitizer/zipball/bc66593f255b7d2613d8f22041180036979b6403",
|
||||
"reference": "bc66593f255b7d2613d8f22041180036979b6403",
|
||||
"url": "https://api.github.com/repos/darylldoyle/svg-sanitizer/zipball/beff89576a72540ee99476aeb9cfe98222e76fb8",
|
||||
"reference": "beff89576a72540ee99476aeb9cfe98222e76fb8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -455,9 +535,9 @@
|
|||
"description": "An SVG sanitizer for PHP",
|
||||
"support": {
|
||||
"issues": "https://github.com/darylldoyle/svg-sanitizer/issues",
|
||||
"source": "https://github.com/darylldoyle/svg-sanitizer/tree/develop"
|
||||
"source": "https://github.com/darylldoyle/svg-sanitizer/tree/0.14.0"
|
||||
},
|
||||
"time": "2020-01-20T01:34:17+00:00"
|
||||
"time": "2021-01-21T10:13:20+00:00"
|
||||
},
|
||||
{
|
||||
"name": "erusev/parsedown",
|
||||
|
|
@ -562,16 +642,16 @@
|
|||
},
|
||||
{
|
||||
"name": "filp/whoops",
|
||||
"version": "2.9.1",
|
||||
"version": "2.9.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/filp/whoops.git",
|
||||
"reference": "307fb34a5ab697461ec4c9db865b20ff2fd40771"
|
||||
"reference": "df7933820090489623ce0be5e85c7e693638e536"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/filp/whoops/zipball/307fb34a5ab697461ec4c9db865b20ff2fd40771",
|
||||
"reference": "307fb34a5ab697461ec4c9db865b20ff2fd40771",
|
||||
"url": "https://api.github.com/repos/filp/whoops/zipball/df7933820090489623ce0be5e85c7e693638e536",
|
||||
"reference": "df7933820090489623ce0be5e85c7e693638e536",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -621,9 +701,15 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/filp/whoops/issues",
|
||||
"source": "https://github.com/filp/whoops/tree/2.9.1"
|
||||
"source": "https://github.com/filp/whoops/tree/2.9.2"
|
||||
},
|
||||
"time": "2020-11-01T12:00:00+00:00"
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/denis-sokolov",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-01-24T12:00:00+00:00"
|
||||
},
|
||||
{
|
||||
"name": "gregwar/cache",
|
||||
|
|
@ -1124,16 +1210,16 @@
|
|||
},
|
||||
{
|
||||
"name": "maximebf/debugbar",
|
||||
"version": "v1.16.4",
|
||||
"version": "v1.16.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/maximebf/php-debugbar.git",
|
||||
"reference": "c86c717e4bf3c6d98422da5c38bfa7b0f494b04c"
|
||||
"reference": "6d51ee9e94cff14412783785e79a4e7ef97b9d62"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/c86c717e4bf3c6d98422da5c38bfa7b0f494b04c",
|
||||
"reference": "c86c717e4bf3c6d98422da5c38bfa7b0f494b04c",
|
||||
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/6d51ee9e94cff14412783785e79a4e7ef97b9d62",
|
||||
"reference": "6d51ee9e94cff14412783785e79a4e7ef97b9d62",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -1183,9 +1269,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/maximebf/php-debugbar/issues",
|
||||
"source": "https://github.com/maximebf/php-debugbar/tree/v1.16.4"
|
||||
"source": "https://github.com/maximebf/php-debugbar/tree/v1.16.5"
|
||||
},
|
||||
"time": "2020-12-07T10:48:48+00:00"
|
||||
"time": "2020-12-07T11:07:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "miljar/php-exif",
|
||||
|
|
@ -2152,16 +2238,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/console",
|
||||
"version": "v4.4.18",
|
||||
"version": "v4.4.19",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/console.git",
|
||||
"reference": "12e071278e396cc3e1c149857337e9e192deca0b"
|
||||
"reference": "24026c44fc37099fa145707fecd43672831b837a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/console/zipball/12e071278e396cc3e1c149857337e9e192deca0b",
|
||||
"reference": "12e071278e396cc3e1c149857337e9e192deca0b",
|
||||
"url": "https://api.github.com/repos/symfony/console/zipball/24026c44fc37099fa145707fecd43672831b837a",
|
||||
"reference": "24026c44fc37099fa145707fecd43672831b837a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -2218,10 +2304,10 @@
|
|||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Console Component",
|
||||
"description": "Eases the creation of beautiful and testable command line interfaces",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/console/tree/v4.4.18"
|
||||
"source": "https://github.com/symfony/console/tree/v4.4.19"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -2237,7 +2323,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2020-12-18T07:41:31+00:00"
|
||||
"time": "2021-01-27T09:09:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/contracts",
|
||||
|
|
@ -2335,16 +2421,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/event-dispatcher",
|
||||
"version": "v4.4.18",
|
||||
"version": "v4.4.19",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/event-dispatcher.git",
|
||||
"reference": "5d4c874b0eb1c32d40328a09dbc37307a5a910b0"
|
||||
"reference": "c352647244bd376bf7d31efbd5401f13f50dad0c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/5d4c874b0eb1c32d40328a09dbc37307a5a910b0",
|
||||
"reference": "5d4c874b0eb1c32d40328a09dbc37307a5a910b0",
|
||||
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/c352647244bd376bf7d31efbd5401f13f50dad0c",
|
||||
"reference": "c352647244bd376bf7d31efbd5401f13f50dad0c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -2395,10 +2481,10 @@
|
|||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony EventDispatcher Component",
|
||||
"description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/event-dispatcher/tree/v4.4.18"
|
||||
"source": "https://github.com/symfony/event-dispatcher/tree/v4.4.19"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -2414,20 +2500,20 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2020-12-18T07:41:31+00:00"
|
||||
"time": "2021-01-27T09:09:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/http-client",
|
||||
"version": "v4.4.18",
|
||||
"version": "v4.4.19",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/http-client.git",
|
||||
"reference": "dc518f62677944938026746e6e58ac37ebcc6238"
|
||||
"reference": "d8df50fe9229576b254c6822eb5cfff36c02c967"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/http-client/zipball/dc518f62677944938026746e6e58ac37ebcc6238",
|
||||
"reference": "dc518f62677944938026746e6e58ac37ebcc6238",
|
||||
"url": "https://api.github.com/repos/symfony/http-client/zipball/d8df50fe9229576b254c6822eb5cfff36c02c967",
|
||||
"reference": "d8df50fe9229576b254c6822eb5cfff36c02c967",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -2444,7 +2530,7 @@
|
|||
"symfony/http-client-implementation": "1.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"guzzlehttp/promises": "^1.3.1",
|
||||
"guzzlehttp/promises": "^1.4",
|
||||
"nyholm/psr7": "^1.0",
|
||||
"php-http/httplug": "^1.0|^2.0",
|
||||
"psr/http-client": "^1.0",
|
||||
|
|
@ -2475,10 +2561,10 @@
|
|||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony HttpClient component",
|
||||
"description": "Provides powerful methods to fetch HTTP resources synchronously or asynchronously",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/http-client/tree/v4.4.18"
|
||||
"source": "https://github.com/symfony/http-client/tree/v4.4.19"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -2494,7 +2580,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2020-12-05T06:03:08+00:00"
|
||||
"time": "2021-01-27T09:09:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-ctype",
|
||||
|
|
@ -2900,16 +2986,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/process",
|
||||
"version": "v4.4.18",
|
||||
"version": "v4.4.19",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/process.git",
|
||||
"reference": "075316ff72233ce3d04a9743414292e834f2cb4a"
|
||||
"reference": "7e950b6366d4da90292c2e7fa820b3c1842b965a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/process/zipball/075316ff72233ce3d04a9743414292e834f2cb4a",
|
||||
"reference": "075316ff72233ce3d04a9743414292e834f2cb4a",
|
||||
"url": "https://api.github.com/repos/symfony/process/zipball/7e950b6366d4da90292c2e7fa820b3c1842b965a",
|
||||
"reference": "7e950b6366d4da90292c2e7fa820b3c1842b965a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -2938,10 +3024,10 @@
|
|||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Process Component",
|
||||
"description": "Executes commands in sub-processes",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/process/tree/v4.4.18"
|
||||
"source": "https://github.com/symfony/process/tree/v4.4.19"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -2957,20 +3043,20 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2020-12-08T16:59:59+00:00"
|
||||
"time": "2021-01-27T09:09:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/var-dumper",
|
||||
"version": "v4.4.18",
|
||||
"version": "v4.4.19",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/var-dumper.git",
|
||||
"reference": "4f31364bbc8177f2a6dbc125ac3851634ebe2a03"
|
||||
"reference": "a1eab2f69906dc83c5ddba4632180260d0ab4f7f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/4f31364bbc8177f2a6dbc125ac3851634ebe2a03",
|
||||
"reference": "4f31364bbc8177f2a6dbc125ac3851634ebe2a03",
|
||||
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/a1eab2f69906dc83c5ddba4632180260d0ab4f7f",
|
||||
"reference": "a1eab2f69906dc83c5ddba4632180260d0ab4f7f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -2987,7 +3073,7 @@
|
|||
"ext-iconv": "*",
|
||||
"symfony/console": "^3.4|^4.0|^5.0",
|
||||
"symfony/process": "^4.4|^5.0",
|
||||
"twig/twig": "^1.34|^2.4|^3.0"
|
||||
"twig/twig": "^1.43|^2.13|^3.0.4"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).",
|
||||
|
|
@ -3023,14 +3109,14 @@
|
|||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony mechanism for exploring and dumping PHP variables",
|
||||
"description": "Provides mechanisms for walking through any arbitrary PHP variable",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"debug",
|
||||
"dump"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/var-dumper/tree/v4.4.18"
|
||||
"source": "https://github.com/symfony/var-dumper/tree/v4.4.19"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -3046,20 +3132,20 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2020-12-08T16:59:59+00:00"
|
||||
"time": "2021-01-27T09:09:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
"version": "v4.4.18",
|
||||
"version": "v4.4.19",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/yaml.git",
|
||||
"reference": "bbce94f14d73732340740366fcbe63363663a403"
|
||||
"reference": "17ed9f14c1aa05b1a5cf2e2c5ef2d0be28058ef9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/yaml/zipball/bbce94f14d73732340740366fcbe63363663a403",
|
||||
"reference": "bbce94f14d73732340740366fcbe63363663a403",
|
||||
"url": "https://api.github.com/repos/symfony/yaml/zipball/17ed9f14c1aa05b1a5cf2e2c5ef2d0be28058ef9",
|
||||
"reference": "17ed9f14c1aa05b1a5cf2e2c5ef2d0be28058ef9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -3098,10 +3184,10 @@
|
|||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Yaml Component",
|
||||
"description": "Loads and dumps YAML files",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/yaml/tree/v4.4.18"
|
||||
"source": "https://github.com/symfony/yaml/tree/v4.4.19"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -3117,7 +3203,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2020-12-08T16:59:59+00:00"
|
||||
"time": "2021-01-27T09:09:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "twig/twig",
|
||||
|
|
@ -3257,23 +3343,23 @@
|
|||
"packages-dev": [
|
||||
{
|
||||
"name": "behat/gherkin",
|
||||
"version": "v4.6.2",
|
||||
"version": "v4.7.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Behat/Gherkin.git",
|
||||
"reference": "51ac4500c4dc30cbaaabcd2f25694299df666a31"
|
||||
"reference": "987bcdc3d29ba433e6bd4b1db4ae59737ba3dacd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Behat/Gherkin/zipball/51ac4500c4dc30cbaaabcd2f25694299df666a31",
|
||||
"reference": "51ac4500c4dc30cbaaabcd2f25694299df666a31",
|
||||
"url": "https://api.github.com/repos/Behat/Gherkin/zipball/987bcdc3d29ba433e6bd4b1db4ae59737ba3dacd",
|
||||
"reference": "987bcdc3d29ba433e6bd4b1db4ae59737ba3dacd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.1"
|
||||
"php": ">=5.6"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.5|~5",
|
||||
"phpunit/phpunit": "~5.7|~6|~7",
|
||||
"symfony/phpunit-bridge": "~2.7|~3|~4",
|
||||
"symfony/yaml": "~2.3|~3|~4"
|
||||
},
|
||||
|
|
@ -3302,7 +3388,7 @@
|
|||
"homepage": "http://everzet.com"
|
||||
}
|
||||
],
|
||||
"description": "Gherkin DSL parser for PHP 5.3",
|
||||
"description": "Gherkin DSL parser for PHP",
|
||||
"homepage": "http://behat.org/",
|
||||
"keywords": [
|
||||
"BDD",
|
||||
|
|
@ -3314,22 +3400,22 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/Behat/Gherkin/issues",
|
||||
"source": "https://github.com/Behat/Gherkin/tree/master"
|
||||
"source": "https://github.com/Behat/Gherkin/tree/v4.7.1"
|
||||
},
|
||||
"time": "2020-03-17T14:03:26+00:00"
|
||||
"time": "2021-01-26T16:24:32+00:00"
|
||||
},
|
||||
{
|
||||
"name": "codeception/codeception",
|
||||
"version": "4.1.15",
|
||||
"version": "4.1.17",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Codeception/Codeception.git",
|
||||
"reference": "9b174d18ba58bb2e8cc4cecce619d6124df1d83a"
|
||||
"reference": "c153b1ab289b3e3109e685379aa8847c54ac2b68"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Codeception/Codeception/zipball/9b174d18ba58bb2e8cc4cecce619d6124df1d83a",
|
||||
"reference": "9b174d18ba58bb2e8cc4cecce619d6124df1d83a",
|
||||
"url": "https://api.github.com/repos/Codeception/Codeception/zipball/c153b1ab289b3e3109e685379aa8847c54ac2b68",
|
||||
"reference": "c153b1ab289b3e3109e685379aa8847c54ac2b68",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -3403,7 +3489,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/Codeception/Codeception/issues",
|
||||
"source": "https://github.com/Codeception/Codeception/tree/4.1.15"
|
||||
"source": "https://github.com/Codeception/Codeception/tree/4.1.17"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -3411,7 +3497,7 @@
|
|||
"type": "open_collective"
|
||||
}
|
||||
],
|
||||
"time": "2021-01-17T19:19:40+00:00"
|
||||
"time": "2021-02-01T07:30:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "codeception/lib-asserts",
|
||||
|
|
@ -3469,16 +3555,16 @@
|
|||
},
|
||||
{
|
||||
"name": "codeception/lib-innerbrowser",
|
||||
"version": "1.3.6",
|
||||
"version": "1.4.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Codeception/lib-innerbrowser.git",
|
||||
"reference": "41b79ba6761001bdb1f373a347400180693ad4e7"
|
||||
"reference": "b7406c710684c255d9b067d7795269a5585a0406"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Codeception/lib-innerbrowser/zipball/41b79ba6761001bdb1f373a347400180693ad4e7",
|
||||
"reference": "41b79ba6761001bdb1f373a347400180693ad4e7",
|
||||
"url": "https://api.github.com/repos/Codeception/lib-innerbrowser/zipball/b7406c710684c255d9b067d7795269a5585a0406",
|
||||
"reference": "b7406c710684c255d9b067d7795269a5585a0406",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -3523,9 +3609,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/Codeception/lib-innerbrowser/issues",
|
||||
"source": "https://github.com/Codeception/lib-innerbrowser/tree/1.3.6"
|
||||
"source": "https://github.com/Codeception/lib-innerbrowser/tree/1.4.0"
|
||||
},
|
||||
"time": "2021-01-17T11:21:09+00:00"
|
||||
"time": "2021-01-29T18:17:25+00:00"
|
||||
},
|
||||
{
|
||||
"name": "codeception/module-asserts",
|
||||
|
|
@ -3796,61 +3882,6 @@
|
|||
],
|
||||
"time": "2020-11-10T18:47:58+00:00"
|
||||
},
|
||||
{
|
||||
"name": "fzaninotto/faker",
|
||||
"version": "v1.9.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/fzaninotto/Faker.git",
|
||||
"reference": "848d8125239d7dbf8ab25cb7f054f1a630e68c2e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/fzaninotto/Faker/zipball/848d8125239d7dbf8ab25cb7f054f1a630e68c2e",
|
||||
"reference": "848d8125239d7dbf8ab25cb7f054f1a630e68c2e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.3.3 || ^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-intl": "*",
|
||||
"phpunit/phpunit": "^4.8.35 || ^5.7",
|
||||
"squizlabs/php_codesniffer": "^2.9.2"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.9-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Faker\\": "src/Faker/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "François Zaninotto"
|
||||
}
|
||||
],
|
||||
"description": "Faker is a PHP library that generates fake data for you.",
|
||||
"keywords": [
|
||||
"data",
|
||||
"faker",
|
||||
"fixtures"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/fzaninotto/Faker/issues",
|
||||
"source": "https://github.com/fzaninotto/Faker/tree/v1.9.2"
|
||||
},
|
||||
"abandoned": true,
|
||||
"time": "2020-12-11T09:56:16+00:00"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/guzzle",
|
||||
"version": "7.2.0",
|
||||
|
|
@ -4460,16 +4491,16 @@
|
|||
},
|
||||
{
|
||||
"name": "phpstan/phpstan",
|
||||
"version": "0.12.68",
|
||||
"version": "0.12.70",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpstan/phpstan.git",
|
||||
"reference": "ddbe01af0706ee094c3f1ce9730b35aebb508d3d"
|
||||
"reference": "07f0ef37f5f876e8cee44cc8ea0ec3fe80d499ee"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/ddbe01af0706ee094c3f1ce9730b35aebb508d3d",
|
||||
"reference": "ddbe01af0706ee094c3f1ce9730b35aebb508d3d",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/07f0ef37f5f876e8cee44cc8ea0ec3fe80d499ee",
|
||||
"reference": "07f0ef37f5f876e8cee44cc8ea0ec3fe80d499ee",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -4500,7 +4531,7 @@
|
|||
"description": "PHPStan - PHP Static Analysis Tool",
|
||||
"support": {
|
||||
"issues": "https://github.com/phpstan/phpstan/issues",
|
||||
"source": "https://github.com/phpstan/phpstan/tree/0.12.68"
|
||||
"source": "https://github.com/phpstan/phpstan/tree/0.12.70"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -4516,7 +4547,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-01-18T12:29:17+00:00"
|
||||
"time": "2021-01-27T17:06:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan-deprecation-rules",
|
||||
|
|
@ -6008,16 +6039,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/browser-kit",
|
||||
"version": "v5.2.1",
|
||||
"version": "v5.2.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/browser-kit.git",
|
||||
"reference": "87d6f0a7436b03a57d4cf9a6a9cd0c83a355c49a"
|
||||
"reference": "b03b2057ed53ee4eab2e8f372084d7722b7b8ffd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/browser-kit/zipball/87d6f0a7436b03a57d4cf9a6a9cd0c83a355c49a",
|
||||
"reference": "87d6f0a7436b03a57d4cf9a6a9cd0c83a355c49a",
|
||||
"url": "https://api.github.com/repos/symfony/browser-kit/zipball/b03b2057ed53ee4eab2e8f372084d7722b7b8ffd",
|
||||
"reference": "b03b2057ed53ee4eab2e8f372084d7722b7b8ffd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -6056,10 +6087,10 @@
|
|||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony BrowserKit Component",
|
||||
"description": "Simulates the behavior of a web browser, allowing you to make requests, click on links and submit forms programmatically",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/browser-kit/tree/v5.2.1"
|
||||
"source": "https://github.com/symfony/browser-kit/tree/v5.2.2"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -6075,20 +6106,20 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2020-12-18T08:03:05+00:00"
|
||||
"time": "2021-01-27T12:56:27+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/css-selector",
|
||||
"version": "v5.2.1",
|
||||
"version": "v5.2.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/css-selector.git",
|
||||
"reference": "f789e7ead4c79e04ca9a6d6162fc629c89bd8054"
|
||||
"reference": "f65f217b3314504a1ec99c2d6ef69016bb13490f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/css-selector/zipball/f789e7ead4c79e04ca9a6d6162fc629c89bd8054",
|
||||
"reference": "f789e7ead4c79e04ca9a6d6162fc629c89bd8054",
|
||||
"url": "https://api.github.com/repos/symfony/css-selector/zipball/f65f217b3314504a1ec99c2d6ef69016bb13490f",
|
||||
"reference": "f65f217b3314504a1ec99c2d6ef69016bb13490f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -6121,10 +6152,10 @@
|
|||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony CssSelector Component",
|
||||
"description": "Converts CSS selectors to XPath expressions",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/css-selector/tree/v5.2.1"
|
||||
"source": "https://github.com/symfony/css-selector/tree/v5.2.2"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -6140,20 +6171,20 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2020-12-08T17:02:38+00:00"
|
||||
"time": "2021-01-27T10:01:46+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/dom-crawler",
|
||||
"version": "v5.2.1",
|
||||
"version": "v5.2.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/dom-crawler.git",
|
||||
"reference": "ee7cf316fb0de786cfe5ae32ee79502b290c81ea"
|
||||
"reference": "5d89ceb53ec65e1973a555072fac8ed5ecad3384"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/ee7cf316fb0de786cfe5ae32ee79502b290c81ea",
|
||||
"reference": "ee7cf316fb0de786cfe5ae32ee79502b290c81ea",
|
||||
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/5d89ceb53ec65e1973a555072fac8ed5ecad3384",
|
||||
"reference": "5d89ceb53ec65e1973a555072fac8ed5ecad3384",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -6195,10 +6226,10 @@
|
|||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony DomCrawler Component",
|
||||
"description": "Eases DOM navigation for HTML and XML documents",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/dom-crawler/tree/v5.2.1"
|
||||
"source": "https://github.com/symfony/dom-crawler/tree/v5.2.2"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -6214,20 +6245,20 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2020-12-18T08:02:46+00:00"
|
||||
"time": "2021-01-27T10:01:46+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/finder",
|
||||
"version": "v5.2.1",
|
||||
"version": "v5.2.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/finder.git",
|
||||
"reference": "0b9231a5922fd7287ba5b411893c0ecd2733e5ba"
|
||||
"reference": "196f45723b5e618bf0e23b97e96d11652696ea9e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/finder/zipball/0b9231a5922fd7287ba5b411893c0ecd2733e5ba",
|
||||
"reference": "0b9231a5922fd7287ba5b411893c0ecd2733e5ba",
|
||||
"url": "https://api.github.com/repos/symfony/finder/zipball/196f45723b5e618bf0e23b97e96d11652696ea9e",
|
||||
"reference": "196f45723b5e618bf0e23b97e96d11652696ea9e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -6256,10 +6287,10 @@
|
|||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Finder Component",
|
||||
"description": "Finds files and directories via an intuitive fluent interface",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/finder/tree/v5.2.1"
|
||||
"source": "https://github.com/symfony/finder/tree/v5.2.2"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -6275,7 +6306,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2020-12-08T17:02:38+00:00"
|
||||
"time": "2021-01-27T10:01:46+00:00"
|
||||
},
|
||||
{
|
||||
"name": "theseer/tokenizer",
|
||||
|
|
@ -6379,12 +6410,12 @@
|
|||
"version": "1.9.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/webmozart/assert.git",
|
||||
"url": "https://github.com/webmozarts/assert.git",
|
||||
"reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/webmozart/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389",
|
||||
"url": "https://api.github.com/repos/webmozarts/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389",
|
||||
"reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389",
|
||||
"shasum": ""
|
||||
},
|
||||
|
|
@ -6422,8 +6453,8 @@
|
|||
"validate"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/webmozart/assert/issues",
|
||||
"source": "https://github.com/webmozart/assert/tree/master"
|
||||
"issues": "https://github.com/webmozarts/assert/issues",
|
||||
"source": "https://github.com/webmozarts/assert/tree/1.9.1"
|
||||
},
|
||||
"time": "2020-07-08T17:02:28+00:00"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
// Some standard defines
|
||||
define('GRAV', true);
|
||||
define('GRAV_VERSION', '1.7.3');
|
||||
define('GRAV_VERSION', '1.7.4');
|
||||
define('GRAV_SCHEMA', '1.7.0_2020-11-20_1');
|
||||
define('GRAV_TESTING', false);
|
||||
|
||||
|
|
|
|||
|
|
@ -362,6 +362,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
|
|||
$locale = setlocale(LC_COLLATE, '0'); //`setlocale` with a '0' param returns the current locale set
|
||||
$col = Collator::create($locale);
|
||||
if ($col) {
|
||||
$col->setAttribute(Collator::NUMERIC_COLLATION, Collator::ON);
|
||||
if (($sort_flags & SORT_NATURAL) === SORT_NATURAL) {
|
||||
$list = preg_replace_callback('~([0-9]+)\.~', static function ($number) {
|
||||
return sprintf('%032d.', $number[0]);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ abstract class AbstractCollection extends Iterator
|
|||
*/
|
||||
public function toJson()
|
||||
{
|
||||
return json_encode($this->toArray());
|
||||
return json_encode($this->toArray(), JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ abstract class AbstractPackageCollection extends Iterator
|
|||
$items[$name] = $package->toArray();
|
||||
}
|
||||
|
||||
return json_encode($items);
|
||||
return json_encode($items, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ class Package
|
|||
/**
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
public function __set($key, $value)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,10 +32,9 @@ class GPM extends Iterator
|
|||
{
|
||||
/** @var Local\Packages Local installed Packages */
|
||||
private $installed;
|
||||
/** @var Remote\Packages Remote available Packages */
|
||||
/** @var Remote\Packages|null Remote available Packages */
|
||||
private $repository;
|
||||
|
||||
/** @var Remote\GravCore */
|
||||
/** @var Remote\GravCore|null Remove Grav Packages */
|
||||
public $grav;
|
||||
|
||||
/** @var array Internal cache */
|
||||
|
|
@ -93,6 +92,7 @@ class GPM extends Iterator
|
|||
$items[$type] = $to_install;
|
||||
$items['total'] += count($to_install);
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
|
@ -116,15 +116,7 @@ class GPM extends Iterator
|
|||
*/
|
||||
public function getInstalledPackage($slug)
|
||||
{
|
||||
if (isset($this->installed['plugins'][$slug])) {
|
||||
return $this->installed['plugins'][$slug];
|
||||
}
|
||||
|
||||
if (isset($this->installed['themes'][$slug])) {
|
||||
return $this->installed['themes'][$slug];
|
||||
}
|
||||
|
||||
return null;
|
||||
return $this->getInstalledPlugin($slug) ?? $this->getInstalledTheme($slug);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -135,7 +127,7 @@ class GPM extends Iterator
|
|||
*/
|
||||
public function getInstalledPlugin($slug)
|
||||
{
|
||||
return $this->installed['plugins'][$slug];
|
||||
return $this->installed['plugins'][$slug] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -164,7 +156,9 @@ class GPM extends Iterator
|
|||
*/
|
||||
public function isPluginInstalledAsSymlink($slug)
|
||||
{
|
||||
return $this->installed['plugins'][$slug]->symlink;
|
||||
$plugin = $this->getInstalledPlugin($slug);
|
||||
|
||||
return (bool)($plugin->symlink ?? false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -175,7 +169,7 @@ class GPM extends Iterator
|
|||
*/
|
||||
public function getInstalledTheme($slug)
|
||||
{
|
||||
return $this->installed['themes'][$slug];
|
||||
return $this->installed['themes'][$slug] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -206,12 +200,7 @@ class GPM extends Iterator
|
|||
*/
|
||||
public function countUpdates()
|
||||
{
|
||||
$count = 0;
|
||||
|
||||
$count += count($this->getUpdatablePlugins());
|
||||
$count += count($this->getUpdatableThemes());
|
||||
|
||||
return $count;
|
||||
return count($this->getUpdatablePlugins()) + count($this->getUpdatableThemes());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -248,7 +237,7 @@ class GPM extends Iterator
|
|||
{
|
||||
$items = [];
|
||||
|
||||
if (!$this->repository) {
|
||||
if (null === $this->repository) {
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
|
@ -264,7 +253,7 @@ class GPM extends Iterator
|
|||
continue;
|
||||
}
|
||||
|
||||
$local_version = $plugin->version ?: 'Unknown';
|
||||
$local_version = $plugin->version ?? 'Unknown';
|
||||
$remote_version = $repository[$slug]->version;
|
||||
|
||||
if (version_compare($local_version, $remote_version) < 0) {
|
||||
|
|
@ -288,6 +277,10 @@ class GPM extends Iterator
|
|||
*/
|
||||
public function getLatestVersionOfPackage($package_name)
|
||||
{
|
||||
if (null === $this->repository) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$repository = $this->repository['plugins'];
|
||||
if (isset($repository[$package_name])) {
|
||||
return $repository[$package_name]->available ?: $repository[$package_name]->version;
|
||||
|
|
@ -334,7 +327,7 @@ class GPM extends Iterator
|
|||
{
|
||||
$items = [];
|
||||
|
||||
if (!$this->repository) {
|
||||
if (null === $this->repository) {
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
|
@ -350,7 +343,7 @@ class GPM extends Iterator
|
|||
continue;
|
||||
}
|
||||
|
||||
$local_version = $plugin->version ?: 'Unknown';
|
||||
$local_version = $plugin->version ?? 'Unknown';
|
||||
$remote_version = $repository[$slug]->version;
|
||||
|
||||
if (version_compare($local_version, $remote_version) < 0) {
|
||||
|
|
@ -385,7 +378,7 @@ class GPM extends Iterator
|
|||
*/
|
||||
public function getReleaseType($package_name)
|
||||
{
|
||||
if (!$this->repository) {
|
||||
if (null === $this->repository) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -422,8 +415,8 @@ class GPM extends Iterator
|
|||
*/
|
||||
public function isTestingRelease($package_name)
|
||||
{
|
||||
$hasTesting = isset($this->getInstalledPackage($package_name)->testing);
|
||||
$testing = $hasTesting ? $this->getInstalledPackage($package_name)->testing : false;
|
||||
$package = $this->getInstalledPackage($package_name);
|
||||
$testing = $package->testing ?? false;
|
||||
|
||||
return $this->getReleaseType($package_name) === 'testing' || $testing;
|
||||
}
|
||||
|
|
@ -432,17 +425,19 @@ class GPM extends Iterator
|
|||
* Returns a Plugin from the repository
|
||||
*
|
||||
* @param string $slug The slug of the Plugin
|
||||
* @return mixed Package if found, NULL if not
|
||||
* @return Remote\Package|null Package if found, NULL if not
|
||||
*/
|
||||
public function getRepositoryPlugin($slug)
|
||||
{
|
||||
return $this->repository['plugins'][$slug] ?? null;
|
||||
$packages = $this->getRepositoryPlugins();
|
||||
|
||||
return $packages ? ($packages[$slug] ?? null) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of Plugins available in the repository
|
||||
*
|
||||
* @return Iterator The Plugins remotely available
|
||||
* @return Iterator|null The Plugins remotely available
|
||||
*/
|
||||
public function getRepositoryPlugins()
|
||||
{
|
||||
|
|
@ -453,17 +448,19 @@ class GPM extends Iterator
|
|||
* Returns a Theme from the repository
|
||||
*
|
||||
* @param string $slug The slug of the Theme
|
||||
* @return mixed Package if found, NULL if not
|
||||
* @return Remote\Package|null Package if found, NULL if not
|
||||
*/
|
||||
public function getRepositoryTheme($slug)
|
||||
{
|
||||
return $this->repository['themes'][$slug] ?? null;
|
||||
$packages = $this->getRepositoryThemes();
|
||||
|
||||
return $packages ? ($packages[$slug] ?? null) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of Themes available in the repository
|
||||
*
|
||||
* @return Iterator The Themes remotely available
|
||||
* @return Iterator|null The Themes remotely available
|
||||
*/
|
||||
public function getRepositoryThemes()
|
||||
{
|
||||
|
|
@ -473,7 +470,7 @@ class GPM extends Iterator
|
|||
/**
|
||||
* Returns the list of Plugins and Themes available in the repository
|
||||
*
|
||||
* @return Remote\Packages Available Plugins and Themes
|
||||
* @return Remote\Packages|null Available Plugins and Themes
|
||||
* Format: ['plugins' => array, 'themes' => array]
|
||||
*/
|
||||
public function getRepository()
|
||||
|
|
@ -492,12 +489,7 @@ class GPM extends Iterator
|
|||
{
|
||||
$search = strtolower($search);
|
||||
|
||||
$found = $this->getRepositoryTheme($search);
|
||||
if ($found) {
|
||||
return $found;
|
||||
}
|
||||
|
||||
$found = $this->getRepositoryPlugin($search);
|
||||
$found = $this->getRepositoryPlugin($search) ?? $this->getRepositoryTheme($search);
|
||||
if ($found) {
|
||||
return $found;
|
||||
}
|
||||
|
|
@ -505,31 +497,27 @@ class GPM extends Iterator
|
|||
$themes = $this->getRepositoryThemes();
|
||||
$plugins = $this->getRepositoryPlugins();
|
||||
|
||||
if (!$themes && !$plugins) {
|
||||
if (null === $themes || null === $plugins) {
|
||||
if (!is_writable(ROOT_DIR . '/cache/gpm')) {
|
||||
throw new RuntimeException("The cache/gpm folder is not writable. Please check the folder permissions.");
|
||||
throw new RuntimeException('The cache/gpm folder is not writable. Please check the folder permissions.');
|
||||
}
|
||||
|
||||
if ($ignore_exception) {
|
||||
return false;
|
||||
}
|
||||
|
||||
throw new RuntimeException("GPM not reachable. Please check your internet connection or check the Grav site is reachable");
|
||||
throw new RuntimeException('GPM not reachable. Please check your internet connection or check the Grav site is reachable');
|
||||
}
|
||||
|
||||
if ($themes) {
|
||||
foreach ($themes as $slug => $theme) {
|
||||
if ($search == $slug || $search == $theme->name) {
|
||||
return $theme;
|
||||
}
|
||||
foreach ($themes as $slug => $theme) {
|
||||
if ($search === $slug || $search === $theme->name) {
|
||||
return $theme;
|
||||
}
|
||||
}
|
||||
|
||||
if ($plugins) {
|
||||
foreach ($plugins as $slug => $plugin) {
|
||||
if ($search == $slug || $search == $plugin->name) {
|
||||
return $plugin;
|
||||
}
|
||||
foreach ($plugins as $slug => $plugin) {
|
||||
if ($search === $slug || $search === $plugin->name) {
|
||||
return $plugin;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -546,9 +534,13 @@ class GPM extends Iterator
|
|||
public static function downloadPackage($package_file, $tmp)
|
||||
{
|
||||
$package = parse_url($package_file);
|
||||
$filename = basename($package['path']);
|
||||
if (!is_array($package)) {
|
||||
throw new \RuntimeException("Malformed GPM URL: {$package_file}");
|
||||
}
|
||||
|
||||
if (Grav::instance()['config']->get('system.gpm.official_gpm_only') && $package['host'] !== 'getgrav.org') {
|
||||
$filename = basename($package['path'] ?? '');
|
||||
|
||||
if (Grav::instance()['config']->get('system.gpm.official_gpm_only') && ($package['host'] ?? null) !== 'getgrav.org') {
|
||||
throw new RuntimeException('Only official GPM URLs are allowed. You can modify this behavior in the System configuration.');
|
||||
}
|
||||
|
||||
|
|
@ -574,10 +566,10 @@ class GPM extends Iterator
|
|||
{
|
||||
$package_file = realpath($package_file);
|
||||
|
||||
if (file_exists($package_file)) {
|
||||
if ($package_file && file_exists($package_file)) {
|
||||
$filename = basename($package_file);
|
||||
Folder::create($tmp);
|
||||
copy(realpath($package_file), $tmp . DS . $filename);
|
||||
copy($package_file, $tmp . DS . $filename);
|
||||
return $tmp . DS . $filename;
|
||||
}
|
||||
|
||||
|
|
@ -614,8 +606,13 @@ class GPM extends Iterator
|
|||
if (Utils::contains($name, 'plugin')) {
|
||||
return 'plugin';
|
||||
}
|
||||
foreach (glob($source . '*.php') as $filename) {
|
||||
|
||||
$glob = glob($source . '*.php') ?: [];
|
||||
foreach ($glob as $filename) {
|
||||
$contents = file_get_contents($filename);
|
||||
if (!$contents) {
|
||||
continue;
|
||||
}
|
||||
if (preg_match($theme_regex, $contents)) {
|
||||
return 'theme';
|
||||
}
|
||||
|
|
@ -638,13 +635,16 @@ class GPM extends Iterator
|
|||
{
|
||||
$ignore_yaml_files = ['blueprints', 'languages'];
|
||||
|
||||
foreach (glob($source . '*.yaml') as $filename) {
|
||||
$glob = glob($source . '*.yaml') ?: [];
|
||||
foreach ($glob as $filename) {
|
||||
$name = strtolower(basename($filename, '.yaml'));
|
||||
if (in_array($name, $ignore_yaml_files)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -684,6 +684,7 @@ class GPM extends Iterator
|
|||
} else {
|
||||
$install_path = $locator->findResource('plugins://', false) . DS . $name;
|
||||
}
|
||||
|
||||
return $install_path;
|
||||
}
|
||||
|
||||
|
|
@ -754,23 +755,21 @@ class GPM extends Iterator
|
|||
$themes = $this->getInstalledThemes();
|
||||
$packages = array_merge($plugins->toArray(), $themes->toArray());
|
||||
|
||||
$dependent_packages = [];
|
||||
|
||||
$list = [];
|
||||
foreach ($packages as $package_name => $package) {
|
||||
if (isset($package['dependencies'])) {
|
||||
foreach ($package['dependencies'] as $dependency) {
|
||||
if (is_array($dependency) && isset($dependency['name'])) {
|
||||
$dependency = $dependency['name'];
|
||||
}
|
||||
$dependencies = $package['dependencies'] ?? [];
|
||||
foreach ($dependencies as $dependency) {
|
||||
if (is_array($dependency) && isset($dependency['name'])) {
|
||||
$dependency = $dependency['name'];
|
||||
}
|
||||
|
||||
if ($dependency === $slug) {
|
||||
$dependent_packages[] = $package_name;
|
||||
}
|
||||
if ($dependency === $slug) {
|
||||
$list[] = $package_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $dependent_packages;
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -783,7 +782,7 @@ class GPM extends Iterator
|
|||
*/
|
||||
public function getVersionOfDependencyRequiredByPackage($package_slug, $dependency_slug)
|
||||
{
|
||||
$dependencies = $this->getInstalledPackage($package_slug)->dependencies;
|
||||
$dependencies = $this->getInstalledPackage($package_slug)->dependencies ?? [];
|
||||
foreach ($dependencies as $dependency) {
|
||||
if (isset($dependency[$dependency_slug])) {
|
||||
return $dependency[$dependency_slug];
|
||||
|
|
@ -803,37 +802,25 @@ class GPM extends Iterator
|
|||
* @return bool
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function checkNoOtherPackageNeedsThisDependencyInALowerVersion(
|
||||
$slug,
|
||||
$version_with_operator,
|
||||
$ignore_packages_list
|
||||
) {
|
||||
|
||||
public function checkNoOtherPackageNeedsThisDependencyInALowerVersion($slug, $version_with_operator, $ignore_packages_list)
|
||||
{
|
||||
// check if any of the currently installed package need this in a lower version than the one we need. In case, abort and tell which package
|
||||
$dependent_packages = $this->getPackagesThatDependOnPackage($slug);
|
||||
$version = $this->calculateVersionNumberFromDependencyVersion($version_with_operator);
|
||||
|
||||
if (count($dependent_packages)) {
|
||||
foreach ($dependent_packages as $dependent_package) {
|
||||
$other_dependency_version_with_operator = $this->getVersionOfDependencyRequiredByPackage(
|
||||
$dependent_package,
|
||||
$slug
|
||||
);
|
||||
$other_dependency_version_with_operator = $this->getVersionOfDependencyRequiredByPackage($dependent_package, $slug);
|
||||
$other_dependency_version = $this->calculateVersionNumberFromDependencyVersion($other_dependency_version_with_operator);
|
||||
|
||||
// check version is compatible with the one needed by the current package
|
||||
if ($this->versionFormatIsNextSignificantRelease($other_dependency_version_with_operator)) {
|
||||
$compatible = $this->checkNextSignificantReleasesAreCompatible(
|
||||
$version,
|
||||
$other_dependency_version
|
||||
);
|
||||
if (!$compatible) {
|
||||
if (!in_array($dependent_package, $ignore_packages_list, true)) {
|
||||
throw new RuntimeException(
|
||||
"Package <cyan>$slug</cyan> is required in an older version by package <cyan>$dependent_package</cyan>. This package needs a newer version, and because of this it cannot be installed. The <cyan>$dependent_package</cyan> package must be updated to use a newer release of <cyan>$slug</cyan>.",
|
||||
2
|
||||
);
|
||||
}
|
||||
$compatible = $this->checkNextSignificantReleasesAreCompatible($version, $other_dependency_version);
|
||||
if (!$compatible && !in_array($dependent_package, $ignore_packages_list, true)) {
|
||||
throw new RuntimeException(
|
||||
"Package <cyan>$slug</cyan> is required in an older version by package <cyan>$dependent_package</cyan>. This package needs a newer version, and because of this it cannot be installed. The <cyan>$dependent_package</cyan> package must be updated to use a newer release of <cyan>$slug</cyan>.",
|
||||
2
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -852,11 +839,8 @@ class GPM extends Iterator
|
|||
public function checkPackagesCanBeInstalled($packages_names_list)
|
||||
{
|
||||
foreach ($packages_names_list as $package_name) {
|
||||
$this->checkNoOtherPackageNeedsThisDependencyInALowerVersion(
|
||||
$package_name,
|
||||
$this->getLatestVersionOfPackage($package_name),
|
||||
$packages_names_list
|
||||
);
|
||||
$latest = $this->getLatestVersionOfPackage($package_name);
|
||||
$this->checkNoOtherPackageNeedsThisDependencyInALowerVersion($package_name, $latest, $packages_names_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -876,6 +860,7 @@ class GPM extends Iterator
|
|||
{
|
||||
$dependencies = $this->calculateMergedDependenciesOfPackages($packages);
|
||||
foreach ($dependencies as $dependency_slug => $dependencyVersionWithOperator) {
|
||||
$dependency_slug = (string)$dependency_slug;
|
||||
if (in_array($dependency_slug, $packages, true)) {
|
||||
unset($dependencies[$dependency_slug]);
|
||||
continue;
|
||||
|
|
@ -883,12 +868,8 @@ class GPM extends Iterator
|
|||
|
||||
// Check PHP version
|
||||
if ($dependency_slug === 'php') {
|
||||
$current_php_version = phpversion();
|
||||
if (version_compare(
|
||||
$this->calculateVersionNumberFromDependencyVersion($dependencyVersionWithOperator),
|
||||
$current_php_version
|
||||
) === 1
|
||||
) {
|
||||
$testVersion = $this->calculateVersionNumberFromDependencyVersion($dependencyVersionWithOperator);
|
||||
if (version_compare($testVersion, PHP_VERSION) === 1) {
|
||||
//Needs a Grav update first
|
||||
throw new RuntimeException("<red>One of the packages require PHP {$dependencies['php']}. Please update PHP to resolve this");
|
||||
}
|
||||
|
|
@ -899,11 +880,8 @@ class GPM extends Iterator
|
|||
|
||||
//First, check for Grav dependency. If a dependency requires Grav > the current version, abort and tell.
|
||||
if ($dependency_slug === 'grav') {
|
||||
if (version_compare(
|
||||
$this->calculateVersionNumberFromDependencyVersion($dependencyVersionWithOperator),
|
||||
GRAV_VERSION
|
||||
) === 1
|
||||
) {
|
||||
$testVersion = $this->calculateVersionNumberFromDependencyVersion($dependencyVersionWithOperator);
|
||||
if (version_compare($testVersion, GRAV_VERSION) === 1) {
|
||||
//Needs a Grav update first
|
||||
throw new RuntimeException("<red>One of the packages require Grav {$dependencies['grav']}. Please update Grav to the latest release.");
|
||||
}
|
||||
|
|
@ -929,19 +907,15 @@ class GPM extends Iterator
|
|||
$currentlyInstalledVersion = $package_yaml['version'];
|
||||
|
||||
// if requirement is next significant release, check is compatible with currently installed version, might not be
|
||||
if ($this->versionFormatIsNextSignificantRelease($dependencyVersionWithOperator)) {
|
||||
if ($this->firstVersionIsLower($dependencyVersion, $currentlyInstalledVersion)) {
|
||||
$compatible = $this->checkNextSignificantReleasesAreCompatible(
|
||||
$dependencyVersion,
|
||||
$currentlyInstalledVersion
|
||||
);
|
||||
if ($this->versionFormatIsNextSignificantRelease($dependencyVersionWithOperator)
|
||||
&& $this->firstVersionIsLower($dependencyVersion, $currentlyInstalledVersion)) {
|
||||
$compatible = $this->checkNextSignificantReleasesAreCompatible($dependencyVersion, $currentlyInstalledVersion);
|
||||
|
||||
if (!$compatible) {
|
||||
throw new RuntimeException(
|
||||
'Dependency <cyan>' . $dependency_slug . '</cyan> is required in an older version than the one installed. This package must be updated. Please get in touch with its developer.',
|
||||
2
|
||||
);
|
||||
}
|
||||
if (!$compatible) {
|
||||
throw new RuntimeException(
|
||||
'Dependency <cyan>' . $dependency_slug . '</cyan> is required in an older version than the one installed. This package must be updated. Please get in touch with its developer.',
|
||||
2
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -958,13 +932,11 @@ class GPM extends Iterator
|
|||
|
||||
if ($this->firstVersionIsLower($currentlyInstalledVersion, $dependencyVersion)) {
|
||||
$dependencies[$dependency_slug] = 'update';
|
||||
} elseif ($currentlyInstalledVersion === $latestRelease) {
|
||||
unset($dependencies[$dependency_slug]);
|
||||
} else {
|
||||
if ($currentlyInstalledVersion == $latestRelease) {
|
||||
unset($dependencies[$dependency_slug]);
|
||||
} else {
|
||||
// an update is not strictly required mark as 'ignore'
|
||||
$dependencies[$dependency_slug] = 'ignore';
|
||||
}
|
||||
// an update is not strictly required mark as 'ignore'
|
||||
$dependencies[$dependency_slug] = 'ignore';
|
||||
}
|
||||
} else {
|
||||
$dependencyVersion = $this->calculateVersionNumberFromDependencyVersion($dependencyVersionWithOperator);
|
||||
|
|
@ -1028,86 +1000,68 @@ class GPM extends Iterator
|
|||
* @param string $packageName The package information
|
||||
* @param array $dependencies The dependencies array
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
private function calculateMergedDependenciesOfPackage($packageName, $dependencies)
|
||||
{
|
||||
$packageData = $this->findPackage($packageName);
|
||||
|
||||
//Check for dependencies
|
||||
if (isset($packageData->dependencies)) {
|
||||
foreach ($packageData->dependencies as $dependency) {
|
||||
$current_package_name = $dependency['name'];
|
||||
if (isset($dependency['version'])) {
|
||||
$current_package_version_information = $dependency['version'];
|
||||
if (empty($packageData->dependencies)) {
|
||||
return $dependencies;
|
||||
}
|
||||
|
||||
foreach ($packageData->dependencies as $dependency) {
|
||||
$dependencyName = $dependency['name'] ?? null;
|
||||
if (!$dependencyName) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$dependencyVersion = $dependency['version'] ?? '*';
|
||||
|
||||
if (!isset($dependencies[$dependencyName])) {
|
||||
// Dependency added for the first time
|
||||
$dependencies[$dependencyName] = $dependencyVersion;
|
||||
|
||||
//Factor in the package dependencies too
|
||||
$dependencies = $this->calculateMergedDependenciesOfPackage($dependencyName, $dependencies);
|
||||
|
||||
} elseif ($dependencyVersion !== '*') {
|
||||
// Dependency already added by another package
|
||||
// If this package requires a version higher than the currently stored one, store this requirement instead
|
||||
$currentDependencyVersion = $dependencies[$dependencyName];
|
||||
$currently_stored_version_number = $this->calculateVersionNumberFromDependencyVersion($currentDependencyVersion);
|
||||
|
||||
$currently_stored_version_is_in_next_significant_release_format = false;
|
||||
if ($this->versionFormatIsNextSignificantRelease($currentDependencyVersion)) {
|
||||
$currently_stored_version_is_in_next_significant_release_format = true;
|
||||
}
|
||||
|
||||
if (!isset($dependencies[$current_package_name])) {
|
||||
// Dependency added for the first time
|
||||
if (!$currently_stored_version_number) {
|
||||
$currently_stored_version_number = '*';
|
||||
}
|
||||
|
||||
if (!isset($current_package_version_information)) {
|
||||
$dependencies[$current_package_name] = '*';
|
||||
} else {
|
||||
$dependencies[$current_package_name] = $current_package_version_information;
|
||||
$current_package_version_number = $this->calculateVersionNumberFromDependencyVersion($dependencyVersion);
|
||||
if (!$current_package_version_number) {
|
||||
throw new RuntimeException("Bad format for version of dependency {$dependencyName} for package {$packageName}", 1);
|
||||
}
|
||||
|
||||
$current_package_version_is_in_next_significant_release_format = false;
|
||||
if ($this->versionFormatIsNextSignificantRelease($dependencyVersion)) {
|
||||
$current_package_version_is_in_next_significant_release_format = true;
|
||||
}
|
||||
|
||||
//If I had stored '*', change right away with the more specific version required
|
||||
if ($currently_stored_version_number === '*') {
|
||||
$dependencies[$dependencyName] = $dependencyVersion;
|
||||
} elseif (!$currently_stored_version_is_in_next_significant_release_format && !$current_package_version_is_in_next_significant_release_format) {
|
||||
//Comparing versions equals or higher, a simple version_compare is enough
|
||||
if (version_compare($currently_stored_version_number, $current_package_version_number) === -1) {
|
||||
//Current package version is higher
|
||||
$dependencies[$dependencyName] = $dependencyVersion;
|
||||
}
|
||||
|
||||
//Factor in the package dependencies too
|
||||
$dependencies = $this->calculateMergedDependenciesOfPackage($current_package_name, $dependencies);
|
||||
} else {
|
||||
// Dependency already added by another package
|
||||
//if this package requires a version higher than the currently stored one, store this requirement instead
|
||||
if (isset($current_package_version_information) && $current_package_version_information !== '*') {
|
||||
$currently_stored_version_information = $dependencies[$current_package_name];
|
||||
$currently_stored_version_number = $this->calculateVersionNumberFromDependencyVersion($currently_stored_version_information);
|
||||
|
||||
$currently_stored_version_is_in_next_significant_release_format = false;
|
||||
if ($this->versionFormatIsNextSignificantRelease($currently_stored_version_information)) {
|
||||
$currently_stored_version_is_in_next_significant_release_format = true;
|
||||
}
|
||||
|
||||
if (!$currently_stored_version_number) {
|
||||
$currently_stored_version_number = '*';
|
||||
}
|
||||
|
||||
$current_package_version_number = $this->calculateVersionNumberFromDependencyVersion($current_package_version_information);
|
||||
if (!$current_package_version_number) {
|
||||
throw new RuntimeException(
|
||||
'Bad format for version of dependency ' . $current_package_name . ' for package ' . $packageName,
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
$current_package_version_is_in_next_significant_release_format = false;
|
||||
if ($this->versionFormatIsNextSignificantRelease($current_package_version_information)) {
|
||||
$current_package_version_is_in_next_significant_release_format = true;
|
||||
}
|
||||
|
||||
//If I had stored '*', change right away with the more specific version required
|
||||
if ($currently_stored_version_number === '*') {
|
||||
$dependencies[$current_package_name] = $current_package_version_information;
|
||||
} else {
|
||||
if (!$currently_stored_version_is_in_next_significant_release_format && !$current_package_version_is_in_next_significant_release_format) {
|
||||
//Comparing versions equals or higher, a simple version_compare is enough
|
||||
if (version_compare(
|
||||
$currently_stored_version_number,
|
||||
$current_package_version_number
|
||||
) === -1
|
||||
) { //Current package version is higher
|
||||
$dependencies[$current_package_name] = $current_package_version_information;
|
||||
}
|
||||
} else {
|
||||
$compatible = $this->checkNextSignificantReleasesAreCompatible(
|
||||
$currently_stored_version_number,
|
||||
$current_package_version_number
|
||||
);
|
||||
if (!$compatible) {
|
||||
throw new RuntimeException(
|
||||
'Dependency ' . $current_package_name . ' is required in two incompatible versions',
|
||||
2
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
$compatible = $this->checkNextSignificantReleasesAreCompatible($currently_stored_version_number,$current_package_version_number);
|
||||
if (!$compatible) {
|
||||
throw new RuntimeException("Dependency {$dependencyName} is required in two incompatible versions", 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1212,7 +1166,7 @@ class GPM extends Iterator
|
|||
|
||||
$i = 0;
|
||||
while ($i < count($version1array) - 1) {
|
||||
if ($version1array[$i] != $version2array[$i]) {
|
||||
if ($version1array[$i] !== $version2array[$i]) {
|
||||
return false;
|
||||
}
|
||||
$i++;
|
||||
|
|
|
|||
|
|
@ -187,7 +187,11 @@ class Installer
|
|||
return false;
|
||||
}
|
||||
|
||||
$package_folder_name = preg_replace('#\./$#', '', $zip->getNameIndex(0));
|
||||
$package_folder_name = $zip->getNameIndex(0);
|
||||
if ($package_folder_name === false) {
|
||||
throw new \RuntimeException('Bad package file: ' . basename($zip_file));
|
||||
}
|
||||
$package_folder_name = preg_replace('#\./$#', '', $package_folder_name);
|
||||
$zip->close();
|
||||
|
||||
return $destination . '/' . $package_folder_name;
|
||||
|
|
@ -208,8 +212,6 @@ class Installer
|
|||
*/
|
||||
private static function loadInstaller($installer_file_folder, $is_install)
|
||||
{
|
||||
$installer = null;
|
||||
|
||||
$installer_file_folder = rtrim($installer_file_folder, DS);
|
||||
|
||||
$install_file = $installer_file_folder . DS . 'install.php';
|
||||
|
|
@ -242,13 +244,13 @@ class Installer
|
|||
return $class_name;
|
||||
}
|
||||
|
||||
$class_name_alphanumeric = preg_replace('/[^a-zA-Z0-9]+/', '', $class_name);
|
||||
$class_name_alphanumeric = preg_replace('/[^a-zA-Z0-9]+/', '', $class_name) ?? $class_name;
|
||||
|
||||
if (class_exists($class_name_alphanumeric)) {
|
||||
return $class_name_alphanumeric;
|
||||
}
|
||||
|
||||
return $installer;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -308,7 +310,8 @@ class Installer
|
|||
}
|
||||
|
||||
if ($file->getFilename() === 'bin') {
|
||||
foreach (glob($path . DS . '*') as $bin_file) {
|
||||
$glob = glob($path . DS . '*') ?: [];
|
||||
foreach ($glob as $bin_file) {
|
||||
@chmod($bin_file, 0755);
|
||||
}
|
||||
}
|
||||
|
|
@ -528,6 +531,7 @@ class Installer
|
|||
* Allows to manually set an error
|
||||
*
|
||||
* @param int|string $error the Error code
|
||||
* @return void
|
||||
*/
|
||||
public static function setError($error)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -70,12 +70,13 @@ class Licenses
|
|||
$licenses = self::getLicenseFile();
|
||||
$data = (array)$licenses->content();
|
||||
$licenses->free();
|
||||
$slug = strtolower($slug);
|
||||
|
||||
if (!$slug) {
|
||||
if (null === $slug) {
|
||||
return $data['licenses'] ?? [];
|
||||
}
|
||||
|
||||
$slug = strtolower($slug);
|
||||
|
||||
return $data['licenses'][$slug] ?? '';
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +93,7 @@ class Licenses
|
|||
return false;
|
||||
}
|
||||
|
||||
return preg_match('#' . self::$regex. '#', $license);
|
||||
return (bool)preg_match('#' . self::$regex. '#', $license);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -127,14 +127,15 @@ class GravCore extends AbstractPackageCollection
|
|||
/**
|
||||
* Returns the minimum PHP version
|
||||
*
|
||||
* @return null|string
|
||||
* @return string
|
||||
*/
|
||||
public function getMinPHPVersion()
|
||||
{
|
||||
// If non min set, assume current PHP version
|
||||
if (null === $this->min_php) {
|
||||
$this->min_php = phpversion();
|
||||
$this->min_php = PHP_VERSION;
|
||||
}
|
||||
|
||||
return $this->min_php;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class Package extends BasePackage implements \JsonSerializable
|
|||
|
||||
$diffLog = [];
|
||||
foreach ((array)$this->data['changelog'] as $version => $changelog) {
|
||||
preg_match("/[\w\-\.]+/", $version, $cleanVersion);
|
||||
preg_match("/[\w\-.]+/", $version, $cleanVersion);
|
||||
|
||||
if (!$cleanVersion || version_compare($diff, $cleanVersion[0], '>=')) {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class Response
|
|||
{
|
||||
/** @var callable The callback for the progress, either a function or callback in array notation */
|
||||
public static $callback = null;
|
||||
|
||||
/** @var string[] */
|
||||
private static $headers = [
|
||||
'User-Agent' => 'Grav CMS'
|
||||
];
|
||||
|
|
@ -80,7 +80,7 @@ class Response
|
|||
// Use callback if provided
|
||||
if ($callback) {
|
||||
self::$callback = $callback;
|
||||
$options->setOnProgress(['Grav\Common\GPM\Response', 'progress']);
|
||||
$options->setOnProgress([Response::class, 'progress']);
|
||||
}
|
||||
|
||||
$preferred_method = $config->get('system.gpm.method', 'auto');
|
||||
|
|
|
|||
|
|
@ -95,8 +95,7 @@ class Upgrader
|
|||
*/
|
||||
public function meetsRequirements()
|
||||
{
|
||||
$current_php_version = phpversion();
|
||||
if (version_compare($current_php_version, $this->minPHPVersion(), '<')) {
|
||||
if (version_compare(PHP_VERSION, $this->minPHPVersion(), '<')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -113,6 +112,7 @@ class Upgrader
|
|||
if (null === $this->min_php) {
|
||||
$this->min_php = $this->remote->getMinPHPVersion();
|
||||
}
|
||||
|
||||
return $this->min_php;
|
||||
}
|
||||
|
||||
|
|
@ -131,7 +131,6 @@ class Upgrader
|
|||
*
|
||||
* @return bool True if Grav is symlinked, False otherwise.
|
||||
*/
|
||||
|
||||
public function isSymlink()
|
||||
{
|
||||
return $this->remote->isSymlink();
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class LanguageCodes
|
|||
'la' => [ 'name' => 'Latin', 'nativeName' => 'Latina' ],
|
||||
'lb' => [ 'name' => 'Luxembourgish', 'nativeName' => 'Lëtzebuergesch' ],
|
||||
'lg' => [ 'name' => 'Luganda', 'nativeName' => 'Luganda' ],
|
||||
'lt' => [ 'name' => 'Lithuanian', 'nativeName' => 'Lietuvių kalba' ],
|
||||
'lt' => [ 'name' => 'Lithuanian', 'nativeName' => 'Lietuvių' ],
|
||||
'lv' => [ 'name' => 'Latvian', 'nativeName' => 'Latviešu' ],
|
||||
'mai' => [ 'name' => 'Maithili', 'nativeName' => 'मैथिली মৈথিলী' ],
|
||||
'mg' => [ 'name' => 'Malagasy', 'nativeName' => 'Malagasy' ],
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ trait ImageLoadingTrait
|
|||
public function loading($value = null)
|
||||
{
|
||||
if (null === $value) {
|
||||
$value = Grav::instance()['config']->get('images.defaults.loading', 'auto');
|
||||
$value = Grav::instance()['config']->get('system.images.defaults.loading', 'auto');
|
||||
}
|
||||
if ($value && $value !== 'auto') {
|
||||
$this->attributes['loading'] = $value;
|
||||
|
|
|
|||
|
|
@ -383,8 +383,10 @@ trait ImageMediaTrait
|
|||
return $this->result;
|
||||
}
|
||||
|
||||
$extension = strtolower($this->get('extension'));
|
||||
$this->format($extension);
|
||||
if ($this->format === 'guess') {
|
||||
$extension = strtolower($this->get('extension'));
|
||||
$this->format($extension);
|
||||
}
|
||||
|
||||
if (!$this->debug_watermarked && $this->get('debug')) {
|
||||
$ratio = $this->get('ratio');
|
||||
|
|
|
|||
|
|
@ -59,9 +59,9 @@ class Pages
|
|||
|
||||
/** @var Grav */
|
||||
protected $grav;
|
||||
/** @var array<PageInterface|string> */
|
||||
/** @var array<PageInterface> */
|
||||
protected $instances = [];
|
||||
/** @var array */
|
||||
/** @var array<PageInterface|string> */
|
||||
protected $index = [];
|
||||
/** @var array */
|
||||
protected $children;
|
||||
|
|
@ -339,14 +339,15 @@ class Pages
|
|||
*/
|
||||
public function instances()
|
||||
{
|
||||
// Make sure we load all the instances.
|
||||
$instances = [];
|
||||
foreach ($this->index as $path => $instance) {
|
||||
if ($instance && !$instance instanceof PageInterface) {
|
||||
$this->get($path);
|
||||
$page = $this->get($path);
|
||||
if ($page) {
|
||||
$instances[$path] = $page;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->instances;
|
||||
return $instances;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -886,7 +887,7 @@ class Pages
|
|||
// fall back and check site based redirects
|
||||
if (!$page || !$page->routable()) {
|
||||
// Redirect to the first child (placeholder page)
|
||||
if ($redirect && $page && count($children = $page->children()->visible()) > 0) {
|
||||
if ($redirect && $page && count($children = $page->children()->visible()->routable()->published()) > 0) {
|
||||
$this->grav->redirectLangSafe($children->first()->route());
|
||||
}
|
||||
|
||||
|
|
@ -1750,8 +1751,9 @@ class Pages
|
|||
$path = $directory . DS . $filename;
|
||||
$child = $this->recurse($path, $page);
|
||||
|
||||
if (Utils::startsWith($filename, '_')) {
|
||||
if (preg_match('/^(\d+\.)_/', $filename)) {
|
||||
$child->routable(false);
|
||||
$child->modularTwig(true);
|
||||
}
|
||||
|
||||
$this->children[$page->path()][$child->path()] = ['slug' => $child->slug()];
|
||||
|
|
@ -1954,6 +1956,7 @@ class Pages
|
|||
$locale = setlocale(LC_COLLATE, '0'); //`setlocale` with a '0' param returns the current locale set
|
||||
$col = Collator::create($locale);
|
||||
if ($col) {
|
||||
$col->setAttribute(Collator::NUMERIC_COLLATION, Collator::ON);
|
||||
if (($sort_flags & SORT_NATURAL) === SORT_NATURAL) {
|
||||
$list = preg_replace_callback('~([0-9]+)\.~', static function ($number) {
|
||||
return sprintf('%032d.', $number[0]);
|
||||
|
|
|
|||
|
|
@ -64,6 +64,11 @@ class CleanCommand extends Command
|
|||
'user/plugins/email/vendor/swiftmailer/swiftmailer/doc',
|
||||
'user/themes/antimatter/.sass-cache',
|
||||
'vendor/antoligy/dom-string-iterators/composer.json',
|
||||
'vendor/composer/ca-bundle/composer.json',
|
||||
'vendor/composer/ca-bundle/phpstan.neon.dist',
|
||||
'vendor/composer/semver/CHANGELOG.md',
|
||||
'vendor/composer/semver/composer.json',
|
||||
'vendor/composer/semver/phpstan.neon.dist',
|
||||
'vendor/doctrine/cache/.travis.yml',
|
||||
'vendor/doctrine/cache/build.properties',
|
||||
'vendor/doctrine/cache/build.xml',
|
||||
|
|
@ -73,20 +78,35 @@ class CleanCommand extends Command
|
|||
'vendor/doctrine/cache/.gitignore',
|
||||
'vendor/doctrine/cache/.git',
|
||||
'vendor/doctrine/cache/tests',
|
||||
'vendor/doctrine/cache/UPGRADE.md',
|
||||
'vendor/doctrine/collections/docs',
|
||||
'vendor/doctrine/collections/.doctrine-project.json',
|
||||
'vendor/doctrine/collections/CONTRIBUTING.md',
|
||||
'vendor/doctrine/collections/psalm.xml.dist',
|
||||
'vendor/doctrine/collections/composer.json',
|
||||
'vendor/doctrine/collections/phpunit.xml.dist',
|
||||
'vendor/doctrine/collections/tests',
|
||||
'vendor/donatj/phpuseragentparser/.git',
|
||||
'vendor/donatj/phpuseragentparser/.github',
|
||||
'vendor/donatj/phpuseragentparser/.gitignore',
|
||||
'vendor/donatj/phpuseragentparser/.editorconfig',
|
||||
'vendor/donatj/phpuseragentparser/.travis.yml',
|
||||
'vendor/donatj/phpuseragentparser/composer.json',
|
||||
'vendor/donatj/phpuseragentparser/phpunit.xml.dist',
|
||||
'vendor/donatj/phpuseragentparser/Tests',
|
||||
'vendor/donatj/phpuseragentparser/tests',
|
||||
'vendor/donatj/phpuseragentparser/Tools',
|
||||
'vendor/donatj/phpuseragentparser/CONTRIBUTING.md',
|
||||
'vendor/donatj/phpuseragentparser/Makefile',
|
||||
'vendor/donatj/phpuseragentparser/.mddoc.xml',
|
||||
'vendor/dragonmantank/cron-expression/.editorconfig',
|
||||
'vendor/dragonmantank/cron-expression/composer.json',
|
||||
'vendor/dragonmantank/cron-expression/tests',
|
||||
'vendor/dragonmantank/cron-expression/CHANGELOG.md',
|
||||
'vendor/enshrined/svg-sanitize/tests',
|
||||
'vendor/enshrined/svg-sanitize/.gitignore',
|
||||
'vendor/enshrined/svg-sanitize/.travis.yml',
|
||||
'vendor/enshrined/svg-sanitize/composer.json',
|
||||
'vendor/enshrined/svg-sanitize/phpunit.xml',
|
||||
'vendor/erusev/parsedown/composer.json',
|
||||
'vendor/erusev/parsedown/phpunit.xml.dist',
|
||||
'vendor/erusev/parsedown/.travis.yml',
|
||||
|
|
@ -102,10 +122,12 @@ class CleanCommand extends Command
|
|||
'vendor/filp/whoops/examples',
|
||||
'vendor/filp/whoops/tests',
|
||||
'vendor/filp/whoops/.git',
|
||||
'vendor/filp/whoops/.github',
|
||||
'vendor/filp/whoops/.gitignore',
|
||||
'vendor/filp/whoops/.scrutinizer.yml',
|
||||
'vendor/filp/whoops/.travis.yml',
|
||||
'vendor/filp/whoops/phpunit.xml.dist',
|
||||
'vendor/filp/whoops/CHANGELOG.md',
|
||||
'vendor/gregwar/image/Gregwar/Image/composer.json',
|
||||
'vendor/gregwar/image/Gregwar/Image/phpunit.xml',
|
||||
'vendor/gregwar/image/Gregwar/Image/phpunit.xml.dist',
|
||||
|
|
@ -128,20 +150,25 @@ class CleanCommand extends Command
|
|||
'vendor/gregwar/cache/Gregwar/Cache/tests',
|
||||
'vendor/guzzlehttp/psr7/composer.json',
|
||||
'vendor/guzzlehttp/psr7/.editorconfig',
|
||||
'vendor/guzzlehttp/psr7/CHANGELOG.md',
|
||||
'vendor/itsgoingd/clockwork/.gitattributes',
|
||||
'vendor/itsgoingd/clockwork/CHANGELOG.md',
|
||||
'vendor/itsgoingd/clockwork/composer.json',
|
||||
'vendor/kodus/psr7-server/composer.json',
|
||||
'vendor/ircmaxell/password-compat/composer.json',
|
||||
'vendor/ircmaxell/password-compat/phpunit.xml.dist',
|
||||
'vendor/ircmaxell/password-compat/version-test.php',
|
||||
'vendor/ircmaxell/password-compat/.travis.yml',
|
||||
'vendor/ircmaxell/password-compat/test',
|
||||
'vendor/kodus/psr7-server/CHANGELOG.md',
|
||||
'vendor/league/climate/composer.json',
|
||||
'vendor/league/climate/CHANGELOG.md',
|
||||
'vendor/league/climate/CONTRIBUTING.md',
|
||||
'vendor/league/climate/Dockerfile',
|
||||
'vendor/league/climate/CODE_OF_CONDUCT.md',
|
||||
'vendor/matthiasmullie/minify/.github',
|
||||
'vendor/matthiasmullie/minify/bin',
|
||||
'vendor/matthiasmullie/minify/composer.json',
|
||||
'vendor/matthiasmullie/minify/docker-compose.yml',
|
||||
'vendor/matthiasmullie/minify/Dockerfile',
|
||||
'vendor/matthiasmullie/minify/CONTRIBUTING.md',
|
||||
'vendor/matthiasmullie/path-converter/composer.json',
|
||||
'vendor/maximebf/debugbar/.github',
|
||||
'vendor/maximebf/debugbar/bower.json',
|
||||
'vendor/maximebf/debugbar/composer.json',
|
||||
'vendor/maximebf/debugbar/.bowerrc',
|
||||
|
|
@ -158,13 +185,18 @@ class CleanCommand extends Command
|
|||
'vendor/miljar/php-exif/phpunit.xml.dist',
|
||||
'vendor/miljar/php-exif/Resources',
|
||||
'vendor/miljar/php-exif/tests',
|
||||
'vendor/miljar/php-exif/CHANGELOG.rst',
|
||||
'vendor/monolog/monolog/composer.json',
|
||||
'vendor/monolog/monolog/doc',
|
||||
'vendor/monolog/monolog/phpunit.xml.dist',
|
||||
'vendor/monolog/monolog/.php_cs',
|
||||
'vendor/monolog/monolog/tests',
|
||||
'vendor/monolog/monolog/CHANGELOG.md',
|
||||
'vendor/monolog/monolog/phpstan.neon.dist',
|
||||
'vendor/nyholm/psr7/composer.json',
|
||||
'vendor/nyholm/psr7/phpstan.neon.dist',
|
||||
'vendor/nyholm/psr7/CHANGELOG.md',
|
||||
'vendor/nyholm/psr7/psalm.xml',
|
||||
'vendor/phive/twig-extensions-deferred/.gitignore',
|
||||
'vendor/phive/twig-extensions-deferred/.travis.yml',
|
||||
'vendor/phive/twig-extensions-deferred/composer.json',
|
||||
|
|
@ -172,18 +204,24 @@ class CleanCommand extends Command
|
|||
'vendor/phive/twig-extensions-deferred/tests',
|
||||
'vendor/php-http/message-factory/composer.json',
|
||||
'vendor/php-http/message-factory/puli.json',
|
||||
'vendor/php-http/message-factory/CHANGELOG.md',
|
||||
'vendor/pimple/pimple/.gitignore',
|
||||
'vendor/pimple/pimple/.travis.yml',
|
||||
'vendor/pimple/pimple/composer.json',
|
||||
'vendor/pimple/pimple/ext',
|
||||
'vendor/pimple/pimple/phpunit.xml.dist',
|
||||
'vendor/pimple/pimple/src/Pimple/Tests',
|
||||
'vendor/pimple/pimple/.php_cs.dist',
|
||||
'vendor/pimple/pimple/CHANGELOG',
|
||||
'vendor/psr/cache/CHANGELOG.md',
|
||||
'vendor/psr/cache/composer.json',
|
||||
'vendor/psr/container/composer.json',
|
||||
'vendor/psr/container/.gitignore',
|
||||
'vendor/psr/http-factory/.gitignore',
|
||||
'vendor/psr/http-factory/.pullapprove.yml',
|
||||
'vendor/psr/http-factory/composer.json',
|
||||
'vendor/psr/http-message/composer.json',
|
||||
'vendor/psr/http-message/CHANGELOG.md',
|
||||
'vendor/psr/http-server-handler/composer.json',
|
||||
'vendor/psr/http-server-middleware/composer.json',
|
||||
'vendor/psr/simple-cache/.editorconfig',
|
||||
|
|
@ -201,25 +239,47 @@ class CleanCommand extends Command
|
|||
'vendor/rockettheme/toolbox/.travis.yml',
|
||||
'vendor/rockettheme/toolbox/composer.json',
|
||||
'vendor/rockettheme/toolbox/phpunit.xml',
|
||||
'vendor/rockettheme/toolbox/CHANGELOG.md',
|
||||
'vendor/rockettheme/toolbox/Blueprints/tests',
|
||||
'vendor/rockettheme/toolbox/ResourceLocator/tests',
|
||||
'vendor/rockettheme/toolbox/Session/tests',
|
||||
'vendor/rockettheme/toolbox/tests',
|
||||
'vendor/seld/cli-prompt/composer.json',
|
||||
'vendor/seld/cli-prompt/.gitignore',
|
||||
'vendor/seld/cli-prompt/.github',
|
||||
'vendor/seld/cli-prompt/phpstan.neon.dist',
|
||||
'vendor/symfony/console/composer.json',
|
||||
'vendor/symfony/console/phpunit.xml.dist',
|
||||
'vendor/symfony/console/.gitignore',
|
||||
'vendor/symfony/console/.git',
|
||||
'vendor/symfony/console/Tester',
|
||||
'vendor/symfony/console/Tests',
|
||||
'vendor/symfony/debug/.gitignore',
|
||||
'vendor/symfony/debug/.git',
|
||||
'vendor/symfony/debug/phpunit.xml.dist',
|
||||
'vendor/symfony/debug/composer.json',
|
||||
'vendor/symfony/debug/Tests',
|
||||
'vendor/symfony/debug/Resources',
|
||||
'vendor/symfony/console/CHANGELOG.md',
|
||||
'vendor/symfony/contracts/Cache/.gitignore',
|
||||
'vendor/symfony/contracts/Cache/composer.json',
|
||||
'vendor/symfony/contracts/EventDispatcher/.gitignore',
|
||||
'vendor/symfony/contracts/EventDispatcher/composer.json',
|
||||
'vendor/symfony/contracts/HttpClient/.gitignore',
|
||||
'vendor/symfony/contracts/HttpClient/composer.json',
|
||||
'vendor/symfony/contracts/HttpClient/Test',
|
||||
'vendor/symfony/contracts/Service/.gitignore',
|
||||
'vendor/symfony/contracts/Service/composer.json',
|
||||
'vendor/symfony/contracts/Service/Test',
|
||||
'vendor/symfony/contracts/Tests',
|
||||
'vendor/symfony/contracts/Translation/.gitignore',
|
||||
'vendor/symfony/contracts/Translation/composer.json',
|
||||
'vendor/symfony/contracts/Translation/Test',
|
||||
'vendor/symfony/contracts/.gitignore',
|
||||
'vendor/symfony/contracts/composer.json',
|
||||
'vendor/symfony/contracts/phpunit.xml.dist',
|
||||
'vendor/symfony/event-dispatcher/.git',
|
||||
'vendor/symfony/event-dispatcher/.gitignore',
|
||||
'vendor/symfony/event-dispatcher/composer.json',
|
||||
'vendor/symfony/event-dispatcher/phpunit.xml.dist',
|
||||
'vendor/symfony/event-dispatcher/Tests',
|
||||
'vendor/symfony/event-dispatcher/CHANGELOG.md',
|
||||
'vendor/symfony/http-client/CHANGELOG.md',
|
||||
'vendor/symfony/http-client/composer.json',
|
||||
'vendor/symfony/polyfill-ctype/composer.json',
|
||||
'vendor/symfony/polyfill-iconv/.git',
|
||||
'vendor/symfony/polyfill-iconv/.gitignore',
|
||||
|
|
@ -233,33 +293,41 @@ class CleanCommand extends Command
|
|||
'vendor/symfony/process/composer.json',
|
||||
'vendor/symfony/process/phpunit.xml.dist',
|
||||
'vendor/symfony/process/Tests',
|
||||
'vendor/symfony/process/CHANGELOG.md',
|
||||
'vendor/symfony/var-dumper/.git',
|
||||
'vendor/symfony/var-dumper/.gitignore',
|
||||
'vendor/symfony/var-dumper/composer.json',
|
||||
'vendor/symfony/var-dumper/phpunit.xml.dist',
|
||||
'vendor/symfony/var-dumper/Test',
|
||||
'vendor/symfony/var-dumper/Tests',
|
||||
'vendor/symfony/var-dumper/CHANGELOG.md',
|
||||
'vendor/symfony/yaml/composer.json',
|
||||
'vendor/symfony/yaml/phpunit.xml.dist',
|
||||
'vendor/symfony/yaml/.gitignore',
|
||||
'vendor/symfony/yaml/.git',
|
||||
'vendor/symfony/yaml/Tests',
|
||||
'vendor/symfony/yaml/CHANGELOG.md',
|
||||
'vendor/twig/twig/.editorconfig',
|
||||
'vendor/twig/twig/.php_cs.dist',
|
||||
'vendor/twig/twig/.travis.yml',
|
||||
'vendor/twig/twig/.gitignore',
|
||||
'vendor/twig/twig/.git',
|
||||
'vendor/twig/twig/.github',
|
||||
'vendor/twig/twig/composer.json',
|
||||
'vendor/twig/twig/phpunit.xml.dist',
|
||||
'vendor/twig/twig/doc',
|
||||
'vendor/twig/twig/ext',
|
||||
'vendor/twig/twig/test',
|
||||
'vendor/twig/twig/.gitattributes',
|
||||
'vendor/twig/twig/CHANGELOG',
|
||||
'vendor/twig/twig/drupal_test.sh',
|
||||
'vendor/willdurand/negotiation/.gitignore',
|
||||
'vendor/willdurand/negotiation/.travis.yml',
|
||||
'vendor/willdurand/negotiation/appveyor.yml',
|
||||
'vendor/willdurand/negotiation/composer.json',
|
||||
'vendor/willdurand/negotiation/phpunit.xml.dist',
|
||||
'vendor/willdurand/negotiation/tests',
|
||||
'vendor/willdurand/negotiation/CONTRIBUTING.md',
|
||||
'user/config/security.yaml',
|
||||
'cache/compiled/',
|
||||
];
|
||||
|
|
@ -298,7 +366,7 @@ class CleanCommand extends Command
|
|||
$this->io->writeln('<red>DELETING</red>');
|
||||
$anything = false;
|
||||
foreach ($this->paths_to_remove as $path) {
|
||||
$path = GRAV_ROOT . $path;
|
||||
$path = GRAV_ROOT . DS . $path;
|
||||
try {
|
||||
if (is_dir($path) && Folder::delete($path)) {
|
||||
$anything = true;
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ class DirectInstallCommand extends GpmCommand
|
|||
$io->newLine();
|
||||
$io->writeln("Preparing to install <cyan>{$package_file}</cyan>");
|
||||
|
||||
$zip = null;
|
||||
if (Response::isRemote($package_file)) {
|
||||
$io->write(' |- Downloading package... 0%');
|
||||
try {
|
||||
|
|
@ -140,7 +141,7 @@ class DirectInstallCommand extends GpmCommand
|
|||
}
|
||||
}
|
||||
|
||||
if (file_exists($zip)) {
|
||||
if ($zip && file_exists($zip)) {
|
||||
$tmp_source = $tmp_dir . uniqid('/Grav-', false);
|
||||
|
||||
$io->write(' |- Extracting package... ');
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Grav\Console\Gpm;
|
|||
|
||||
use Grav\Common\GPM\GPM;
|
||||
use Grav\Common\GPM\Installer;
|
||||
use Grav\Common\GPM\Remote\Package;
|
||||
use Grav\Common\GPM\Local\Package;
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Console\GpmCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
|
@ -110,6 +110,13 @@ class UninstallCommand extends GpmCommand
|
|||
|
||||
unset($this->data['not_found'], $this->data['total']);
|
||||
|
||||
// Plugins need to be initialized in order to make clear-cache to work.
|
||||
try {
|
||||
$this->initializePlugins();
|
||||
} catch (\Throwable $e) {
|
||||
$io->writeln("<red>Some plugins failed to initialize: {$e->getMessage()}</red>");
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
foreach ($this->data as $slug => $package) {
|
||||
$io->writeln("Preparing to uninstall <cyan>{$package->name}</cyan> [v{$package->version}]");
|
||||
|
|
@ -145,7 +152,7 @@ class UninstallCommand extends GpmCommand
|
|||
* @param bool $is_dependency
|
||||
* @return bool
|
||||
*/
|
||||
private function uninstallPackage($slug, $package, $is_dependency = false): bool
|
||||
private function uninstallPackage($slug, Package $package, $is_dependency = false): bool
|
||||
{
|
||||
$io = $this->getIO();
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ class FlexForm implements FlexObjectFormInterface, JsonSerializable
|
|||
private $object;
|
||||
/** @var string */
|
||||
private $flexName;
|
||||
/** @var callable|null */
|
||||
private $submitMethod;
|
||||
|
||||
/**
|
||||
* @param array $options Options to initialize the form instance:
|
||||
|
|
@ -213,6 +215,14 @@ class FlexForm implements FlexObjectFormInterface, JsonSerializable
|
|||
return $this->flexName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param callable|null $submitMethod
|
||||
*/
|
||||
public function setSubmitMethod(?callable $submitMethod): void
|
||||
{
|
||||
$this->submitMethod = $submitMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param string $name
|
||||
|
|
@ -504,8 +514,13 @@ class FlexForm implements FlexObjectFormInterface, JsonSerializable
|
|||
/** @var FlexObject $object */
|
||||
$object = clone $this->getObject();
|
||||
|
||||
$object->update($data, $files);
|
||||
$object->save();
|
||||
$method = $this->submitMethod;
|
||||
if ($method) {
|
||||
$method($data, $files, $object);
|
||||
} else {
|
||||
$object->update($data, $files);
|
||||
$object->save();
|
||||
}
|
||||
|
||||
$this->setObject($object);
|
||||
$this->reset();
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
private $_flexDirectory;
|
||||
/** @var FlexFormInterface[] */
|
||||
private $_forms = [];
|
||||
/** @var Blueprint[] */
|
||||
private $_blueprint = [];
|
||||
/** @var array */
|
||||
private $_meta;
|
||||
/** @var array */
|
||||
|
|
@ -769,11 +771,15 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
|||
*/
|
||||
public function getBlueprint(string $name = '')
|
||||
{
|
||||
$blueprint = $this->doGetBlueprint($name);
|
||||
$blueprint->setScope('object');
|
||||
$blueprint->setObject($this);
|
||||
if (!isset($this->_blueprint[$name])) {
|
||||
$blueprint = $this->doGetBlueprint($name);
|
||||
$blueprint->setScope('object');
|
||||
$blueprint->setObject($this);
|
||||
|
||||
return $blueprint->init();
|
||||
$this->_blueprint[$name] = $blueprint->init();
|
||||
}
|
||||
|
||||
return $this->_blueprint[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -354,8 +354,8 @@ class FlexPageObject extends FlexObject implements PageInterface, FlexTranslateI
|
|||
*/
|
||||
public function setNestedProperty($property, $value, $separator = null)
|
||||
{
|
||||
if (strpos($property, 'header.') === 0) {
|
||||
$this->getProperty('header')->set(str_replace('header.', '', $property), $value, $separator);
|
||||
if (strpos($property, 'header' . $separator) === 0) {
|
||||
$this->getProperty('header')->set(str_replace('header' . $separator, '', $property), $value, $separator);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -372,8 +372,8 @@ class FlexPageObject extends FlexObject implements PageInterface, FlexTranslateI
|
|||
*/
|
||||
public function unsetNestedProperty($property, $separator = null)
|
||||
{
|
||||
if (strpos($property, 'header.') === 0) {
|
||||
$this->getProperty('header')->undef(str_replace('header.', '', $property), $separator);
|
||||
if (strpos($property, 'header' . $separator) === 0) {
|
||||
$this->getProperty('header')->undef(str_replace('header' . $separator, '', $property), $separator);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -396,7 +396,7 @@ class FlexPageObject extends FlexObject implements PageInterface, FlexTranslateI
|
|||
unset($elements['content']);
|
||||
}
|
||||
|
||||
// RAW frontmatter support.
|
||||
// TODO: Remove: RAW frontmatter support has been moved to Flex-Objects v1.0.2 controller.
|
||||
if (isset($elements['frontmatter'])) {
|
||||
$formatter = new YamlFormatter();
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -92,8 +92,11 @@ trait PageLegacyTrait
|
|||
public function frontmatter($var = null): string
|
||||
{
|
||||
if (null !== $var) {
|
||||
// TODO:
|
||||
throw new RuntimeException(__METHOD__ . '(string): Not Implemented');
|
||||
$formatter = new YamlFormatter();
|
||||
$this->setProperty('frontmatter', $var);
|
||||
$this->setProperty('header', $formatter->decode($var));
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
||||
$storage = $this->getFlexDirectory()->getStorage();
|
||||
|
|
|
|||
|
|
@ -29,6 +29,3 @@ $grav = function () {
|
|||
};
|
||||
|
||||
Fixtures::add('grav', $grav);
|
||||
|
||||
$fake = Factory::create();
|
||||
Fixtures::add('fake', $fake);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class DirectInstallCommandTest extends \Codeception\TestCase\Test
|
|||
protected $directInstall;
|
||||
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$this->grav = Fixtures::get('grav');
|
||||
$this->directInstallCommand = new DirectInstallCommand();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Common\Plugin;
|
||||
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
|
||||
|
||||
\define('GRAV_CLI', true);
|
||||
|
|
@ -21,7 +22,7 @@ if (!file_exists(GRAV_ROOT . '/index.php')) {
|
|||
exit('FATAL: Must be run from ROOT directory of Grav!');
|
||||
}
|
||||
|
||||
$grav = Grav::instance(array('loader' => $autoload));
|
||||
$grav = Grav::instance(['loader' => $autoload]);
|
||||
$grav->setup('tests');
|
||||
$grav['config']->init();
|
||||
|
||||
|
|
@ -30,13 +31,31 @@ $grav['config']->init();
|
|||
/** @var UniformResourceLocator $locator */
|
||||
$locator = Grav::instance()['locator'];
|
||||
$iterator = $locator->getIterator('plugins://');
|
||||
/** @var DirectoryIterator $directory */
|
||||
foreach ($iterator as $directory) {
|
||||
if (!$directory->isDir()) {
|
||||
continue;
|
||||
}
|
||||
$autoloader = $directory->getPathname() . '/vendor/autoload.php';
|
||||
if (file_exists($autoloader)) {
|
||||
require $autoloader;
|
||||
$plugin = $directory->getBasename();
|
||||
$file = $directory->getPathname() . '/' . $plugin . '.php';
|
||||
$classloader = null;
|
||||
if (file_exists($file)) {
|
||||
require_once $file;
|
||||
|
||||
$pluginClass = "\\Grav\\Plugin\\{$plugin}Plugin";
|
||||
|
||||
if (is_subclass_of($pluginClass, Plugin::class, true)) {
|
||||
$class = new $pluginClass($plugin, $grav);
|
||||
if (is_callable([$class, 'autoload'])) {
|
||||
$classloader = $class->autoload();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null === $classloader) {
|
||||
$autoloader = $directory->getPathname() . '/vendor/autoload.php';
|
||||
if (file_exists($autoloader)) {
|
||||
require $autoloader;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,24 +15,24 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
/** @var Assets $assets */
|
||||
protected $assets;
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$grav = Fixtures::get('grav');
|
||||
$this->grav = $grav();
|
||||
$this->assets = $this->grav['assets'];
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
protected function _after(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testAddingAssets()
|
||||
public function testAddingAssets(): void
|
||||
{
|
||||
//test add()
|
||||
$this->assets->add('test.css');
|
||||
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
$array = $this->assets->getCss();
|
||||
|
||||
|
|
@ -57,11 +57,11 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
"query":""
|
||||
}
|
||||
}';
|
||||
$this->assertJsonStringEqualsJsonString($expected, $actual);
|
||||
self::assertJsonStringEqualsJsonString($expected, $actual);
|
||||
|
||||
$this->assets->add('test.js');
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame('<script src="/test.js"></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/test.js"></script>' . PHP_EOL, $js);
|
||||
|
||||
$array = $this->assets->getJs();
|
||||
|
||||
|
|
@ -85,13 +85,13 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
"query":""
|
||||
}
|
||||
}';
|
||||
$this->assertJsonStringEqualsJsonString($expected, $actual);
|
||||
self::assertJsonStringEqualsJsonString($expected, $actual);
|
||||
|
||||
//test addCss(). Test adding asset to a separate group
|
||||
$this->assets->reset();
|
||||
$this->assets->addCSS('test.css');
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
$array = $this->assets->getCss();
|
||||
/** @var Assets\BaseAsset $item */
|
||||
|
|
@ -115,13 +115,13 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
"query":""
|
||||
}
|
||||
}';
|
||||
$this->assertJsonStringEqualsJsonString($expected, $actual);
|
||||
self::assertJsonStringEqualsJsonString($expected, $actual);
|
||||
|
||||
//test addCss(). Testing with remote URL
|
||||
$this->assets->reset();
|
||||
$this->assets->addCSS('http://www.somesite.com/test.css');
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="http://www.somesite.com/test.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="http://www.somesite.com/test.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
$array = $this->assets->getCss();
|
||||
/** @var Assets\BaseAsset $item */
|
||||
|
|
@ -144,19 +144,19 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
"query":""
|
||||
}
|
||||
}';
|
||||
$this->assertJsonStringEqualsJsonString($expected, $actual);
|
||||
self::assertJsonStringEqualsJsonString($expected, $actual);
|
||||
|
||||
//test addCss() adding asset to a separate group, and with an alternate rel attribute
|
||||
$this->assets->reset();
|
||||
$this->assets->addCSS('test.css', ['group' => 'alternate', 'rel' => 'alternate']);
|
||||
$css = $this->assets->css('alternate');
|
||||
$this->assertSame('<link href="/test.css" type="text/css" rel="alternate">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="/test.css" type="text/css" rel="alternate">' . PHP_EOL, $css);
|
||||
|
||||
//test addJs()
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs('test.js');
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame('<script src="/test.js"></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/test.js"></script>' . PHP_EOL, $js);
|
||||
|
||||
$array = $this->assets->getJs();
|
||||
/** @var Assets\BaseAsset $item */
|
||||
|
|
@ -177,15 +177,15 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
"query":""
|
||||
}
|
||||
}';
|
||||
$this->assertJsonStringEqualsJsonString($expected, $actual);
|
||||
self::assertJsonStringEqualsJsonString($expected, $actual);
|
||||
|
||||
//Test CSS Groups
|
||||
$this->assets->reset();
|
||||
$this->assets->addCSS('test.css', ['group' => 'footer']);
|
||||
$css = $this->assets->css();
|
||||
$this->assertEmpty($css);
|
||||
self::assertEmpty($css);
|
||||
$css = $this->assets->css('footer');
|
||||
$this->assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
$array = $this->assets->getCss();
|
||||
/** @var Assets\BaseAsset $item */
|
||||
|
|
@ -210,15 +210,15 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
}
|
||||
}
|
||||
';
|
||||
$this->assertJsonStringEqualsJsonString($expected, $actual);
|
||||
self::assertJsonStringEqualsJsonString($expected, $actual);
|
||||
|
||||
//Test JS Groups
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs('test.js', ['group' => 'footer']);
|
||||
$js = $this->assets->js();
|
||||
$this->assertEmpty($js);
|
||||
self::assertEmpty($js);
|
||||
$js = $this->assets->js('footer');
|
||||
$this->assertSame('<script src="/test.js"></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/test.js"></script>' . PHP_EOL, $js);
|
||||
|
||||
$array = $this->assets->getJs();
|
||||
/** @var Assets\BaseAsset $item */
|
||||
|
|
@ -239,13 +239,13 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
"query": ""
|
||||
}
|
||||
}';
|
||||
$this->assertJsonStringEqualsJsonString($expected, $actual);
|
||||
self::assertJsonStringEqualsJsonString($expected, $actual);
|
||||
|
||||
//Test async / defer
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs('test.js', ['loading' => 'async']);
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame('<script src="/test.js" async></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/test.js" async></script>' . PHP_EOL, $js);
|
||||
|
||||
$array = $this->assets->getJs();
|
||||
/** @var Assets\BaseAsset $item */
|
||||
|
|
@ -268,12 +268,12 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
"query": ""
|
||||
}
|
||||
}';
|
||||
$this->assertJsonStringEqualsJsonString($expected, $actual);
|
||||
self::assertJsonStringEqualsJsonString($expected, $actual);
|
||||
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs('test.js', ['loading' => 'defer']);
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame('<script src="/test.js" defer></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/test.js" defer></script>' . PHP_EOL, $js);
|
||||
|
||||
$array = $this->assets->getJs();
|
||||
/** @var Assets\BaseAsset $item */
|
||||
|
|
@ -296,58 +296,58 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
"query": ""
|
||||
}
|
||||
}';
|
||||
$this->assertJsonStringEqualsJsonString($expected, $actual);
|
||||
self::assertJsonStringEqualsJsonString($expected, $actual);
|
||||
|
||||
//Test inline
|
||||
$this->assets->reset();
|
||||
$this->assets->setJsPipeline(true);
|
||||
$this->assets->addJs('/system/assets/jquery/jquery-3.x.min.js');
|
||||
$js = $this->assets->js('head', ['loading' => 'inline']);
|
||||
$this->assertStringContainsString('"jquery",[],function()', $js);
|
||||
self::assertStringContainsString('"jquery",[],function()', $js);
|
||||
|
||||
$this->assets->reset();
|
||||
$this->assets->setCssPipeline(true);
|
||||
$this->assets->addCss('/system/assets/debugger/phpdebugbar.css');
|
||||
$css = $this->assets->css('head', ['loading' => 'inline']);
|
||||
$this->assertStringContainsString('div.phpdebugbar', $css);
|
||||
self::assertStringContainsString('div.phpdebugbar', $css);
|
||||
|
||||
$this->assets->reset();
|
||||
$this->assets->setCssPipeline(true);
|
||||
$this->assets->addCss('https://fonts.googleapis.com/css?family=Roboto');
|
||||
$css = $this->assets->css('head', ['loading' => 'inline']);
|
||||
$this->assertStringContainsString('font-family:\'Roboto\';', $css);
|
||||
self::assertStringContainsString('font-family:\'Roboto\';', $css);
|
||||
|
||||
//Test adding media queries
|
||||
$this->assets->reset();
|
||||
$this->assets->add('test.css', ['media' => 'only screen and (min-width: 640px)']);
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="/test.css" type="text/css" rel="stylesheet" media="only screen and (min-width: 640px)">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="/test.css" type="text/css" rel="stylesheet" media="only screen and (min-width: 640px)">' . PHP_EOL, $css);
|
||||
}
|
||||
|
||||
public function testAddingAssetPropertiesWithArray()
|
||||
public function testAddingAssetPropertiesWithArray(): void
|
||||
{
|
||||
//Test adding assets with object to define properties
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs('test.js', ['loading' => 'async']);
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame('<script src="/test.js" async></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/test.js" async></script>' . PHP_EOL, $js);
|
||||
$this->assets->reset();
|
||||
}
|
||||
|
||||
public function testAddingJSAssetPropertiesWithArrayFromCollection()
|
||||
public function testAddingJSAssetPropertiesWithArrayFromCollection(): void
|
||||
{
|
||||
//Test adding properties with array
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs('jquery', ['loading' => 'async']);
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame('<script src="/system/assets/jquery/jquery-2.x.min.js" async></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/system/assets/jquery/jquery-2.x.min.js" async></script>' . PHP_EOL, $js);
|
||||
|
||||
//Test priority too
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs('jquery', ['loading' => 'async', 'priority' => 1]);
|
||||
$this->assets->addJs('test.js', ['loading' => 'async', 'priority' => 2]);
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame('<script src="/test.js" async></script>' . PHP_EOL .
|
||||
self::assertSame('<script src="/test.js" async></script>' . PHP_EOL .
|
||||
'<script src="/system/assets/jquery/jquery-2.x.min.js" async></script>' . PHP_EOL, $js);
|
||||
|
||||
//Test multiple groups
|
||||
|
|
@ -355,9 +355,9 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
$this->assets->addJs('jquery', ['loading' => 'async', 'priority' => 1, 'group' => 'footer']);
|
||||
$this->assets->addJs('test.js', ['loading' => 'async', 'priority' => 2]);
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame('<script src="/test.js" async></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/test.js" async></script>' . PHP_EOL, $js);
|
||||
$js = $this->assets->js('footer');
|
||||
$this->assertSame('<script src="/system/assets/jquery/jquery-2.x.min.js" async></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/system/assets/jquery/jquery-2.x.min.js" async></script>' . PHP_EOL, $js);
|
||||
|
||||
//Test adding array of assets
|
||||
//Test priority too
|
||||
|
|
@ -365,18 +365,18 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
$this->assets->addJs(['jquery', 'test.js'], ['loading' => 'async']);
|
||||
$js = $this->assets->js();
|
||||
|
||||
$this->assertSame('<script src="/system/assets/jquery/jquery-2.x.min.js" async></script>' . PHP_EOL .
|
||||
self::assertSame('<script src="/system/assets/jquery/jquery-2.x.min.js" async></script>' . PHP_EOL .
|
||||
'<script src="/test.js" async></script>' . PHP_EOL, $js);
|
||||
}
|
||||
|
||||
public function testAddingLegacyFormat()
|
||||
public function testAddingLegacyFormat(): void
|
||||
{
|
||||
// regular CSS add
|
||||
//test addCss(). Test adding asset to a separate group
|
||||
$this->assets->reset();
|
||||
$this->assets->addCSS('test.css', 15, true, 'bottom', 'async');
|
||||
$css = $this->assets->css('bottom');
|
||||
$this->assertSame('<link href="/test.css" type="text/css" rel="stylesheet" async>' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="/test.css" type="text/css" rel="stylesheet" async>' . PHP_EOL, $css);
|
||||
|
||||
$array = $this->assets->getCss();
|
||||
/** @var Assets\BaseAsset $item */
|
||||
|
|
@ -401,12 +401,12 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
"query":""
|
||||
}
|
||||
}';
|
||||
$this->assertJsonStringEqualsJsonString($expected, $actual);
|
||||
self::assertJsonStringEqualsJsonString($expected, $actual);
|
||||
|
||||
$this->assets->reset();
|
||||
$this->assets->addJs('test.js', 15, false, 'defer', 'bottom');
|
||||
$js = $this->assets->js('bottom');
|
||||
$this->assertSame('<script src="/test.js" defer></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/test.js" defer></script>' . PHP_EOL, $js);
|
||||
|
||||
$array = $this->assets->getJs();
|
||||
/** @var Assets\BaseAsset $item */
|
||||
|
|
@ -429,21 +429,21 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
"query": ""
|
||||
}
|
||||
}';
|
||||
$this->assertJsonStringEqualsJsonString($expected, $actual);
|
||||
self::assertJsonStringEqualsJsonString($expected, $actual);
|
||||
|
||||
|
||||
$this->assets->reset();
|
||||
$this->assets->addInlineCss('body { color: black }', 15, 'bottom');
|
||||
$css = $this->assets->css('bottom');
|
||||
$this->assertSame('<style>' . PHP_EOL . 'body { color: black }' . PHP_EOL . '</style>' . PHP_EOL, $css);
|
||||
self::assertSame('<style>' . PHP_EOL . 'body { color: black }' . PHP_EOL . '</style>' . PHP_EOL, $css);
|
||||
|
||||
$this->assets->reset();
|
||||
$this->assets->addInlineJs('alert("test")', 15, 'bottom', ['id' => 'foo']);
|
||||
$js = $this->assets->js('bottom');
|
||||
$this->assertSame('<script id="foo">' . PHP_EOL . 'alert("test")' . PHP_EOL . '</script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script id="foo">' . PHP_EOL . 'alert("test")' . PHP_EOL . '</script>' . PHP_EOL, $js);
|
||||
}
|
||||
|
||||
public function testAddingCSSAssetPropertiesWithArrayFromCollection()
|
||||
public function testAddingCSSAssetPropertiesWithArrayFromCollection(): void
|
||||
{
|
||||
$this->assets->registerCollection('test', ['/system/assets/whoops.css']);
|
||||
|
||||
|
|
@ -452,7 +452,7 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
$this->assets->addCss('test', ['priority' => 1]);
|
||||
$this->assets->addCss('test.css', ['priority' => 2]);
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL .
|
||||
self::assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL .
|
||||
'<link href="/system/assets/whoops.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
//Test multiple groups
|
||||
|
|
@ -460,27 +460,27 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
$this->assets->addCss('test', ['priority' => 1, 'group' => 'footer']);
|
||||
$this->assets->addCss('test.css', ['priority' => 2]);
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
$css = $this->assets->css('footer');
|
||||
$this->assertSame('<link href="/system/assets/whoops.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="/system/assets/whoops.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
//Test adding array of assets
|
||||
//Test priority too
|
||||
$this->assets->reset();
|
||||
$this->assets->addCss(['test', 'test.css'], ['loading' => 'async']);
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="/system/assets/whoops.css" type="text/css" rel="stylesheet" async>' . PHP_EOL .
|
||||
self::assertSame('<link href="/system/assets/whoops.css" type="text/css" rel="stylesheet" async>' . PHP_EOL .
|
||||
'<link href="/test.css" type="text/css" rel="stylesheet" async>' . PHP_EOL, $css);
|
||||
}
|
||||
|
||||
public function testPriorityOfAssets()
|
||||
public function testPriorityOfAssets(): void
|
||||
{
|
||||
$this->assets->reset();
|
||||
$this->assets->add('test.css');
|
||||
$this->assets->add('test-after.css');
|
||||
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL .
|
||||
self::assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL .
|
||||
'<link href="/test-after.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
//----------------
|
||||
|
|
@ -489,7 +489,7 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
$this->assets->add('test.css', 2);
|
||||
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL .
|
||||
self::assertSame('<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL .
|
||||
'<link href="/test-after.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
//----------------
|
||||
|
|
@ -499,12 +499,12 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
$this->assets->add('test-before.css', 3);
|
||||
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="/test-before.css" type="text/css" rel="stylesheet">' . PHP_EOL .
|
||||
self::assertSame('<link href="/test-before.css" type="text/css" rel="stylesheet">' . PHP_EOL .
|
||||
'<link href="/test.css" type="text/css" rel="stylesheet">' . PHP_EOL .
|
||||
'<link href="/test-after.css" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
}
|
||||
|
||||
public function testPipeline()
|
||||
public function testPipeline(): void
|
||||
{
|
||||
$this->assets->reset();
|
||||
|
||||
|
|
@ -512,15 +512,15 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
$this->assets->add('test.css', null, true);
|
||||
$this->assets->setCssPipeline(true);
|
||||
$css = $this->assets->css();
|
||||
$this->assertRegExp('#<link href=\"\/assets\/(.*).css\" type=\"text\/css\" rel=\"stylesheet\">#', $css);
|
||||
self::assertRegExp('#<link href=\"\/assets\/(.*).css\" type=\"text\/css\" rel=\"stylesheet\">#', $css);
|
||||
|
||||
//Add a core Grav CSS file, which is found. Pipeline will now return a file
|
||||
$this->assets->add('/system/assets/debugger/phpdebugbar', null, true);
|
||||
$css = $this->assets->css();
|
||||
$this->assertRegExp('#<link href=\"\/assets\/(.*).css\" type=\"text\/css\" rel=\"stylesheet\">#', $css);
|
||||
self::assertRegExp('#<link href=\"\/assets\/(.*).css\" type=\"text\/css\" rel=\"stylesheet\">#', $css);
|
||||
}
|
||||
|
||||
public function testPipelineWithTimestamp()
|
||||
public function testPipelineWithTimestamp(): void
|
||||
{
|
||||
$this->assets->reset();
|
||||
$this->assets->setTimestamp('foo');
|
||||
|
|
@ -529,28 +529,28 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
//Add a core Grav CSS file, which is found. Pipeline will now return a file
|
||||
$this->assets->add('/system/assets/debugger.css', null, true);
|
||||
$css = $this->assets->css();
|
||||
$this->assertRegExp('#<link href=\"\/assets\/(.*).css\?foo\" type=\"text\/css\" rel=\"stylesheet\">#', $css);
|
||||
self::assertRegExp('#<link href=\"\/assets\/(.*).css\?foo\" type=\"text\/css\" rel=\"stylesheet\">#', $css);
|
||||
}
|
||||
|
||||
public function testInline()
|
||||
public function testInline(): void
|
||||
{
|
||||
$this->assets->reset();
|
||||
|
||||
//File not existing. Pipeline searches for that file without reaching it. Output is empty.
|
||||
$this->assets->add('test.css', ['loading' => 'inline']);
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame("<style>\n\n</style>\n", $css);
|
||||
self::assertSame("<style>\n\n</style>\n", $css);
|
||||
|
||||
$this->assets->reset();
|
||||
//Add a core Grav CSS file, which is found. Pipeline will now return its content.
|
||||
$this->assets->addCss('https://fonts.googleapis.com/css?family=Roboto', ['loading' => 'inline']);
|
||||
$this->assets->addCss('/system/assets/debugger/phpdebugbar.css', ['loading' => 'inline']);
|
||||
$css = $this->assets->css();
|
||||
$this->assertStringContainsString('font-family: \'Roboto\';', $css);
|
||||
$this->assertStringContainsString('div.phpdebugbar-header', $css);
|
||||
self::assertStringContainsString('font-family: \'Roboto\';', $css);
|
||||
self::assertStringContainsString('div.phpdebugbar-header', $css);
|
||||
}
|
||||
|
||||
public function testInlinePipeline()
|
||||
public function testInlinePipeline(): void
|
||||
{
|
||||
$this->assets->reset();
|
||||
$this->assets->setCssPipeline(true);
|
||||
|
|
@ -558,216 +558,216 @@ class AssetsTest extends \Codeception\TestCase\Test
|
|||
//File not existing. Pipeline searches for that file without reaching it. Output is empty.
|
||||
$this->assets->add('test.css');
|
||||
$css = $this->assets->css('head', ['loading' => 'inline']);
|
||||
$this->assertSame("<style>\n\n</style>\n", $css);
|
||||
self::assertSame("<style>\n\n</style>\n", $css);
|
||||
|
||||
//Add a core Grav CSS file, which is found. Pipeline will now return its content.
|
||||
$this->assets->addCss('https://fonts.googleapis.com/css?family=Roboto', null, true);
|
||||
$this->assets->add('/system/assets/debugger/phpdebugbar.css', null, true);
|
||||
$css = $this->assets->css('head', ['loading' => 'inline']);
|
||||
$this->assertStringContainsString('font-family:\'Roboto\';', $css);
|
||||
$this->assertStringContainsString('div.phpdebugbar', $css);
|
||||
self::assertStringContainsString('font-family:\'Roboto\';', $css);
|
||||
self::assertStringContainsString('div.phpdebugbar', $css);
|
||||
}
|
||||
|
||||
public function testAddAsyncJs()
|
||||
public function testAddAsyncJs(): void
|
||||
{
|
||||
$this->assets->reset();
|
||||
$this->assets->addAsyncJs('jquery');
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame('<script src="/system/assets/jquery/jquery-2.x.min.js" async></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/system/assets/jquery/jquery-2.x.min.js" async></script>' . PHP_EOL, $js);
|
||||
}
|
||||
|
||||
public function testAddDeferJs()
|
||||
public function testAddDeferJs(): void
|
||||
{
|
||||
$this->assets->reset();
|
||||
$this->assets->addDeferJs('jquery');
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame('<script src="/system/assets/jquery/jquery-2.x.min.js" defer></script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script src="/system/assets/jquery/jquery-2.x.min.js" defer></script>' . PHP_EOL, $js);
|
||||
}
|
||||
|
||||
public function testTimestamps()
|
||||
public function testTimestamps(): void
|
||||
{
|
||||
// local CSS nothing extra
|
||||
$this->assets->reset();
|
||||
$this->assets->setTimestamp('foo');
|
||||
$this->assets->addCSS('test.css');
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="/test.css?foo" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="/test.css?foo" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
// local CSS already with param
|
||||
$this->assets->reset();
|
||||
$this->assets->setTimestamp('foo');
|
||||
$this->assets->addCSS('test.css?bar');
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="/test.css?bar&foo" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="/test.css?bar&foo" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
// external CSS already
|
||||
$this->assets->reset();
|
||||
$this->assets->setTimestamp('foo');
|
||||
$this->assets->addCSS('http://somesite.com/test.css');
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="http://somesite.com/test.css?foo" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="http://somesite.com/test.css?foo" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
// external CSS already with param
|
||||
$this->assets->reset();
|
||||
$this->assets->setTimestamp('foo');
|
||||
$this->assets->addCSS('http://somesite.com/test.css?bar');
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<link href="http://somesite.com/test.css?bar&foo" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
self::assertSame('<link href="http://somesite.com/test.css?bar&foo" type="text/css" rel="stylesheet">' . PHP_EOL, $css);
|
||||
|
||||
// local JS nothing extra
|
||||
$this->assets->reset();
|
||||
$this->assets->setTimestamp('foo');
|
||||
$this->assets->addJs('test.js');
|
||||
$css = $this->assets->js();
|
||||
$this->assertSame('<script src="/test.js?foo"></script>' . PHP_EOL, $css);
|
||||
self::assertSame('<script src="/test.js?foo"></script>' . PHP_EOL, $css);
|
||||
|
||||
// local JS already with param
|
||||
$this->assets->reset();
|
||||
$this->assets->setTimestamp('foo');
|
||||
$this->assets->addJs('test.js?bar');
|
||||
$css = $this->assets->js();
|
||||
$this->assertSame('<script src="/test.js?bar&foo"></script>' . PHP_EOL, $css);
|
||||
self::assertSame('<script src="/test.js?bar&foo"></script>' . PHP_EOL, $css);
|
||||
|
||||
// external JS already
|
||||
$this->assets->reset();
|
||||
$this->assets->setTimestamp('foo');
|
||||
$this->assets->addJs('http://somesite.com/test.js');
|
||||
$css = $this->assets->js();
|
||||
$this->assertSame('<script src="http://somesite.com/test.js?foo"></script>' . PHP_EOL, $css);
|
||||
self::assertSame('<script src="http://somesite.com/test.js?foo"></script>' . PHP_EOL, $css);
|
||||
|
||||
// external JS already with param
|
||||
$this->assets->reset();
|
||||
$this->assets->setTimestamp('foo');
|
||||
$this->assets->addJs('http://somesite.com/test.js?bar');
|
||||
$css = $this->assets->js();
|
||||
$this->assertSame('<script src="http://somesite.com/test.js?bar&foo"></script>' . PHP_EOL, $css);
|
||||
self::assertSame('<script src="http://somesite.com/test.js?bar&foo"></script>' . PHP_EOL, $css);
|
||||
}
|
||||
|
||||
public function testAddInlineCss()
|
||||
public function testAddInlineCss(): void
|
||||
{
|
||||
$this->assets->reset();
|
||||
$this->assets->addInlineCss('body { color: black }');
|
||||
$css = $this->assets->css();
|
||||
$this->assertSame('<style>' . PHP_EOL . 'body { color: black }' . PHP_EOL . '</style>' . PHP_EOL, $css);
|
||||
self::assertSame('<style>' . PHP_EOL . 'body { color: black }' . PHP_EOL . '</style>' . PHP_EOL, $css);
|
||||
}
|
||||
|
||||
public function testAddInlineJs()
|
||||
public function testAddInlineJs(): void
|
||||
{
|
||||
$this->assets->reset();
|
||||
$this->assets->addInlineJs('alert("test")');
|
||||
$js = $this->assets->js();
|
||||
$this->assertSame('<script>' . PHP_EOL . 'alert("test")' . PHP_EOL . '</script>' . PHP_EOL, $js);
|
||||
self::assertSame('<script>' . PHP_EOL . 'alert("test")' . PHP_EOL . '</script>' . PHP_EOL, $js);
|
||||
}
|
||||
|
||||
public function testGetCollections()
|
||||
public function testGetCollections(): void
|
||||
{
|
||||
$this->assertIsArray($this->assets->getCollections());
|
||||
$this->assertContains('jquery', array_keys($this->assets->getCollections()));
|
||||
$this->assertContains('system://assets/jquery/jquery-2.x.min.js', $this->assets->getCollections());
|
||||
self::assertIsArray($this->assets->getCollections());
|
||||
self::assertContains('jquery', array_keys($this->assets->getCollections()));
|
||||
self::assertContains('system://assets/jquery/jquery-2.x.min.js', $this->assets->getCollections());
|
||||
}
|
||||
|
||||
public function testExists()
|
||||
public function testExists(): void
|
||||
{
|
||||
$this->assertTrue($this->assets->exists('jquery'));
|
||||
$this->assertFalse($this->assets->exists('another-unexisting-library'));
|
||||
self::assertTrue($this->assets->exists('jquery'));
|
||||
self::assertFalse($this->assets->exists('another-unexisting-library'));
|
||||
}
|
||||
|
||||
public function testRegisterCollection()
|
||||
public function testRegisterCollection(): void
|
||||
{
|
||||
$this->assets->registerCollection('debugger', ['/system/assets/debugger.css']);
|
||||
$this->assertTrue($this->assets->exists('debugger'));
|
||||
$this->assertContains('debugger', array_keys($this->assets->getCollections()));
|
||||
self::assertTrue($this->assets->exists('debugger'));
|
||||
self::assertContains('debugger', array_keys($this->assets->getCollections()));
|
||||
}
|
||||
|
||||
public function testReset()
|
||||
public function testReset(): void
|
||||
{
|
||||
$this->assets->addInlineJs('alert("test")');
|
||||
$this->assets->reset();
|
||||
$this->assertCount(0, (array) $this->assets->getJs());
|
||||
self::assertCount(0, (array) $this->assets->getJs());
|
||||
|
||||
$this->assets->addAsyncJs('jquery');
|
||||
$this->assets->reset();
|
||||
$this->assertCount(0, (array) $this->assets->getJs());
|
||||
self::assertCount(0, (array) $this->assets->getJs());
|
||||
|
||||
$this->assets->addInlineCss('body { color: black }');
|
||||
$this->assets->reset();
|
||||
$this->assertCount(0, (array) $this->assets->getCss());
|
||||
self::assertCount(0, (array) $this->assets->getCss());
|
||||
|
||||
$this->assets->add('/system/assets/debugger.css', null, true);
|
||||
$this->assets->reset();
|
||||
$this->assertCount(0, (array) $this->assets->getCss());
|
||||
self::assertCount(0, (array) $this->assets->getCss());
|
||||
}
|
||||
|
||||
public function testResetJs()
|
||||
public function testResetJs(): void
|
||||
{
|
||||
$this->assets->addInlineJs('alert("test")');
|
||||
$this->assets->resetJs();
|
||||
$this->assertCount(0, (array) $this->assets->getJs());
|
||||
self::assertCount(0, (array) $this->assets->getJs());
|
||||
|
||||
$this->assets->addAsyncJs('jquery');
|
||||
$this->assets->resetJs();
|
||||
$this->assertCount(0, (array) $this->assets->getJs());
|
||||
self::assertCount(0, (array) $this->assets->getJs());
|
||||
}
|
||||
|
||||
public function testResetCss()
|
||||
public function testResetCss(): void
|
||||
{
|
||||
$this->assets->addInlineCss('body { color: black }');
|
||||
$this->assets->resetCss();
|
||||
$this->assertCount(0, (array) $this->assets->getCss());
|
||||
self::assertCount(0, (array) $this->assets->getCss());
|
||||
|
||||
$this->assets->add('/system/assets/debugger.css', null, true);
|
||||
$this->assets->resetCss();
|
||||
$this->assertCount(0, (array) $this->assets->getCss());
|
||||
self::assertCount(0, (array) $this->assets->getCss());
|
||||
}
|
||||
|
||||
public function testAddDirCss()
|
||||
public function testAddDirCss(): void
|
||||
{
|
||||
$this->assets->addDirCss('/system');
|
||||
|
||||
$this->assertIsArray($this->assets->getCss());
|
||||
$this->assertGreaterThan(0, (array) $this->assets->getCss());
|
||||
$this->assertIsArray($this->assets->getJs());
|
||||
$this->assertCount(0, (array) $this->assets->getJs());
|
||||
self::assertIsArray($this->assets->getCss());
|
||||
self::assertGreaterThan(0, (array) $this->assets->getCss());
|
||||
self::assertIsArray($this->assets->getJs());
|
||||
self::assertCount(0, (array) $this->assets->getJs());
|
||||
|
||||
$this->assets->reset();
|
||||
$this->assets->addDirCss('/system/assets');
|
||||
|
||||
$this->assertIsArray($this->assets->getCss());
|
||||
$this->assertGreaterThan(0, (array) $this->assets->getCss());
|
||||
$this->assertIsArray($this->assets->getJs());
|
||||
$this->assertCount(0, (array) $this->assets->getJs());
|
||||
self::assertIsArray($this->assets->getCss());
|
||||
self::assertGreaterThan(0, (array) $this->assets->getCss());
|
||||
self::assertIsArray($this->assets->getJs());
|
||||
self::assertCount(0, (array) $this->assets->getJs());
|
||||
|
||||
$this->assets->reset();
|
||||
$this->assets->addDirJs('/system');
|
||||
|
||||
$this->assertIsArray($this->assets->getCss());
|
||||
$this->assertCount(0, (array) $this->assets->getCss());
|
||||
$this->assertIsArray($this->assets->getJs());
|
||||
$this->assertGreaterThan(0, (array) $this->assets->getJs());
|
||||
self::assertIsArray($this->assets->getCss());
|
||||
self::assertCount(0, (array) $this->assets->getCss());
|
||||
self::assertIsArray($this->assets->getJs());
|
||||
self::assertGreaterThan(0, (array) $this->assets->getJs());
|
||||
|
||||
$this->assets->reset();
|
||||
$this->assets->addDirJs('/system/assets');
|
||||
|
||||
$this->assertIsArray($this->assets->getCss());
|
||||
$this->assertCount(0, (array) $this->assets->getCss());
|
||||
$this->assertIsArray($this->assets->getJs());
|
||||
$this->assertGreaterThan(0, (array) $this->assets->getJs());
|
||||
self::assertIsArray($this->assets->getCss());
|
||||
self::assertCount(0, (array) $this->assets->getCss());
|
||||
self::assertIsArray($this->assets->getJs());
|
||||
self::assertGreaterThan(0, (array) $this->assets->getJs());
|
||||
|
||||
$this->assets->reset();
|
||||
$this->assets->addDir('/system/assets');
|
||||
|
||||
$this->assertIsArray($this->assets->getCss());
|
||||
$this->assertGreaterThan(0, (array) $this->assets->getCss());
|
||||
$this->assertIsArray($this->assets->getJs());
|
||||
$this->assertGreaterThan(0, (array) $this->assets->getJs());
|
||||
self::assertIsArray($this->assets->getCss());
|
||||
self::assertGreaterThan(0, (array) $this->assets->getCss());
|
||||
self::assertIsArray($this->assets->getJs());
|
||||
self::assertGreaterThan(0, (array) $this->assets->getJs());
|
||||
|
||||
//Use streams
|
||||
$this->assets->reset();
|
||||
$this->assets->addDir('system://assets');
|
||||
|
||||
$this->assertIsArray($this->assets->getCss());
|
||||
$this->assertGreaterThan(0, (array) $this->assets->getCss());
|
||||
$this->assertIsArray($this->assets->getJs());
|
||||
$this->assertGreaterThan(0, (array) $this->assets->getJs());
|
||||
self::assertIsArray($this->assets->getCss());
|
||||
self::assertGreaterThan(0, (array) $this->assets->getCss());
|
||||
self::assertIsArray($this->assets->getJs());
|
||||
self::assertGreaterThan(0, (array) $this->assets->getJs());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,41 +11,41 @@ class BrowserTest extends \Codeception\TestCase\Test
|
|||
/** @var Grav $grav */
|
||||
protected $grav;
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$grav = Fixtures::get('grav');
|
||||
$this->grav = $grav();
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
protected function _after(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testGetBrowser()
|
||||
public function testGetBrowser(): void
|
||||
{
|
||||
/* Already covered by PhpUserAgent tests */
|
||||
}
|
||||
|
||||
public function testGetPlatform()
|
||||
public function testGetPlatform(): void
|
||||
{
|
||||
/* Already covered by PhpUserAgent tests */
|
||||
}
|
||||
|
||||
public function testGetLongVersion()
|
||||
public function testGetLongVersion(): void
|
||||
{
|
||||
/* Already covered by PhpUserAgent tests */
|
||||
}
|
||||
|
||||
public function testGetVersion()
|
||||
public function testGetVersion(): void
|
||||
{
|
||||
/* Already covered by PhpUserAgent tests */
|
||||
}
|
||||
|
||||
public function testIsHuman()
|
||||
public function testIsHuman(): void
|
||||
{
|
||||
//Already Partially covered by PhpUserAgent tests
|
||||
|
||||
//Make sure it recognizes the test as not human
|
||||
$this->assertFalse($this->grav['browser']->isHuman());
|
||||
self::assertFalse($this->grav['browser']->isHuman());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,27 +5,27 @@ use Grav\Common\Composer;
|
|||
|
||||
class ComposerTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
protected function _after(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testGetComposerLocation()
|
||||
public function testGetComposerLocation(): void
|
||||
{
|
||||
$composerLocation = Composer::getComposerLocation();
|
||||
$this->assertIsString($composerLocation);
|
||||
$this->assertSame('/', $composerLocation[0]);
|
||||
self::assertIsString($composerLocation);
|
||||
self::assertSame('/', $composerLocation[0]);
|
||||
}
|
||||
|
||||
public function testGetComposerExecutor()
|
||||
public function testGetComposerExecutor(): void
|
||||
{
|
||||
$composerExecutor = Composer::getComposerExecutor();
|
||||
$this->assertIsString($composerExecutor);
|
||||
$this->assertSame('/', $composerExecutor[0]);
|
||||
$this->assertNotNull(strstr($composerExecutor, 'php'));
|
||||
$this->assertNotNull(strstr($composerExecutor, 'composer'));
|
||||
self::assertIsString($composerExecutor);
|
||||
self::assertSame('/', $composerExecutor[0]);
|
||||
self::assertNotNull(strstr($composerExecutor, 'php'));
|
||||
self::assertNotNull(strstr($composerExecutor, 'composer'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class BlueprintTest extends \Codeception\TestCase\Test
|
|||
{
|
||||
/**
|
||||
*/
|
||||
public function testValidateStrict()
|
||||
public function testValidateStrict(): void
|
||||
{
|
||||
$blueprint = $this->loadBlueprint('strict');
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ class BlueprintTest extends \Codeception\TestCase\Test
|
|||
/**
|
||||
* @depends testValidateStrict
|
||||
*/
|
||||
public function testValidateStrictRequired()
|
||||
public function testValidateStrictRequired(): void
|
||||
{
|
||||
$blueprint = $this->loadBlueprint('strict');
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ class BlueprintTest extends \Codeception\TestCase\Test
|
|||
/**
|
||||
* @depends testValidateStrict
|
||||
*/
|
||||
public function testValidateStrictExtra()
|
||||
public function testValidateStrictExtra(): void
|
||||
{
|
||||
$blueprint = $this->loadBlueprint('strict');
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ class BlueprintTest extends \Codeception\TestCase\Test
|
|||
/**
|
||||
* @depends testValidateStrict
|
||||
*/
|
||||
public function testValidateStrictExtraException()
|
||||
public function testValidateStrictExtraException(): void
|
||||
{
|
||||
$blueprint = $this->loadBlueprint('strict');
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ class BlueprintTest extends \Codeception\TestCase\Test
|
|||
* @param string $filename
|
||||
* @return Blueprint
|
||||
*/
|
||||
protected function loadBlueprint($filename)
|
||||
protected function loadBlueprint($filename): Blueprint
|
||||
{
|
||||
$blueprint = new Blueprint('strict');
|
||||
$blueprint->setContext(dirname(__DIR__, 3). '/data/blueprints');
|
||||
|
|
|
|||
|
|
@ -7,17 +7,25 @@ use Grav\Common\GPM\GPM;
|
|||
define('EXCEPTION_BAD_FORMAT', 1);
|
||||
define('EXCEPTION_INCOMPATIBLE_VERSIONS', 2);
|
||||
|
||||
/**
|
||||
* Class GpmStub
|
||||
*/
|
||||
class GpmStub extends GPM
|
||||
{
|
||||
/** @var array */
|
||||
public $data;
|
||||
|
||||
public function findPackage($packageName, $ignore_exception = false)
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function findPackage($search, $ignore_exception = false)
|
||||
{
|
||||
if (isset($this->data[$packageName])) {
|
||||
return $this->data[$packageName];
|
||||
}
|
||||
return $this->data[$search] ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function findPackages($searches = [])
|
||||
{
|
||||
return $this->data;
|
||||
|
|
@ -35,17 +43,17 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
/** @var GpmStub */
|
||||
protected $gpm;
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$this->grav = Fixtures::get('grav');
|
||||
$this->gpm = new GpmStub();
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
protected function _after(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testCalculateMergedDependenciesOfPackages()
|
||||
public function testCalculateMergedDependenciesOfPackages(): void
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// First working example
|
||||
|
|
@ -53,22 +61,22 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
$this->gpm->data = [
|
||||
'admin' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "grav", "version" => ">=1.0.10"],
|
||||
["name" => "form", "version" => "~2.0"],
|
||||
["name" => "login", "version" => ">=2.0"],
|
||||
["name" => "errors", "version" => "*"],
|
||||
["name" => "problems"],
|
||||
['name' => 'grav', 'version' => '>=1.0.10'],
|
||||
['name' => 'form', 'version' => '~2.0'],
|
||||
['name' => 'login', 'version' => '>=2.0'],
|
||||
['name' => 'errors', 'version' => '*'],
|
||||
['name' => 'problems'],
|
||||
]
|
||||
],
|
||||
'test' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "errors", "version" => ">=1.0"]
|
||||
['name' => 'errors', 'version' => '>=1.0']
|
||||
]
|
||||
],
|
||||
'grav',
|
||||
'form' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "errors", "version" => ">=3.2"]
|
||||
['name' => 'errors', 'version' => '>=3.2']
|
||||
]
|
||||
]
|
||||
|
||||
|
|
@ -79,12 +87,12 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
|
||||
$dependencies = $this->gpm->calculateMergedDependenciesOfPackages($packages);
|
||||
|
||||
$this->assertIsArray($dependencies);
|
||||
$this->assertCount(5, $dependencies);
|
||||
self::assertIsArray($dependencies);
|
||||
self::assertCount(5, $dependencies);
|
||||
|
||||
$this->assertSame('>=1.0.10', $dependencies['grav']);
|
||||
$this->assertArrayHasKey('errors', $dependencies);
|
||||
$this->assertArrayHasKey('problems', $dependencies);
|
||||
self::assertSame('>=1.0.10', $dependencies['grav']);
|
||||
self::assertArrayHasKey('errors', $dependencies);
|
||||
self::assertArrayHasKey('problems', $dependencies);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Second working example
|
||||
|
|
@ -92,9 +100,9 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
$packages = ['admin', 'form'];
|
||||
|
||||
$dependencies = $this->gpm->calculateMergedDependenciesOfPackages($packages);
|
||||
$this->assertIsArray($dependencies);
|
||||
$this->assertCount(5, $dependencies);
|
||||
$this->assertSame('>=3.2', $dependencies['errors']);
|
||||
self::assertIsArray($dependencies);
|
||||
self::assertCount(5, $dependencies);
|
||||
self::assertSame('>=3.2', $dependencies['errors']);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Third working example
|
||||
|
|
@ -103,17 +111,17 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
|
||||
'admin' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "errors", "version" => ">=4.0"],
|
||||
['name' => 'errors', 'version' => '>=4.0'],
|
||||
]
|
||||
],
|
||||
'test' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "errors", "version" => ">=1.0"]
|
||||
['name' => 'errors', 'version' => '>=1.0']
|
||||
]
|
||||
],
|
||||
'another' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "errors", "version" => ">=3.2"]
|
||||
['name' => 'errors', 'version' => '>=3.2']
|
||||
]
|
||||
]
|
||||
|
||||
|
|
@ -123,9 +131,9 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
|
||||
|
||||
$dependencies = $this->gpm->calculateMergedDependenciesOfPackages($packages);
|
||||
$this->assertIsArray($dependencies);
|
||||
$this->assertCount(1, $dependencies);
|
||||
$this->assertSame('>=4.0', $dependencies['errors']);
|
||||
self::assertIsArray($dependencies);
|
||||
self::assertCount(1, $dependencies);
|
||||
self::assertSame('>=4.0', $dependencies['errors']);
|
||||
|
||||
|
||||
|
||||
|
|
@ -135,23 +143,23 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
$this->gpm->data = [
|
||||
'admin' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "package1", "version" => ">=4.0.0-rc1"],
|
||||
["name" => "package4", "version" => ">=3.2.0"],
|
||||
['name' => 'package1', 'version' => '>=4.0.0-rc1'],
|
||||
['name' => 'package4', 'version' => '>=3.2.0'],
|
||||
]
|
||||
],
|
||||
'test' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "package1", "version" => ">=4.0.0-rc2"],
|
||||
["name" => "package2", "version" => ">=3.2.0-alpha"],
|
||||
["name" => "package3", "version" => ">=3.2.0-alpha.2"],
|
||||
["name" => "package4", "version" => ">=3.2.0-alpha"],
|
||||
['name' => 'package1', 'version' => '>=4.0.0-rc2'],
|
||||
['name' => 'package2', 'version' => '>=3.2.0-alpha'],
|
||||
['name' => 'package3', 'version' => '>=3.2.0-alpha.2'],
|
||||
['name' => 'package4', 'version' => '>=3.2.0-alpha'],
|
||||
]
|
||||
],
|
||||
'another' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "package2", "version" => ">=3.2.0-beta.11"],
|
||||
["name" => "package3", "version" => ">=3.2.0-alpha.1"],
|
||||
["name" => "package4", "version" => ">=3.2.0-beta"],
|
||||
['name' => 'package2', 'version' => '>=3.2.0-beta.11'],
|
||||
['name' => 'package3', 'version' => '>=3.2.0-alpha.1'],
|
||||
['name' => 'package4', 'version' => '>=3.2.0-beta'],
|
||||
]
|
||||
]
|
||||
];
|
||||
|
|
@ -160,10 +168,10 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
|
||||
|
||||
$dependencies = $this->gpm->calculateMergedDependenciesOfPackages($packages);
|
||||
$this->assertSame('>=4.0.0-rc2', $dependencies['package1']);
|
||||
$this->assertSame('>=3.2.0-beta.11', $dependencies['package2']);
|
||||
$this->assertSame('>=3.2.0-alpha.2', $dependencies['package3']);
|
||||
$this->assertSame('>=3.2.0', $dependencies['package4']);
|
||||
self::assertSame('>=4.0.0-rc2', $dependencies['package1']);
|
||||
self::assertSame('>=3.2.0-beta.11', $dependencies['package2']);
|
||||
self::assertSame('>=3.2.0-alpha.2', $dependencies['package3']);
|
||||
self::assertSame('>=3.2.0', $dependencies['package4']);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -173,12 +181,12 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
|
||||
'admin' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "errors", "version" => ">=4.0"],
|
||||
['name' => 'errors', 'version' => '>=4.0'],
|
||||
]
|
||||
],
|
||||
'test' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "errors", "version" => ">="]
|
||||
['name' => 'errors', 'version' => '>=']
|
||||
]
|
||||
],
|
||||
|
||||
|
|
@ -188,10 +196,10 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
|
||||
try {
|
||||
$this->gpm->calculateMergedDependenciesOfPackages($packages);
|
||||
$this->fail("Expected Exception not thrown");
|
||||
self::fail('Expected Exception not thrown');
|
||||
} catch (Exception $e) {
|
||||
$this->assertEquals(EXCEPTION_BAD_FORMAT, $e->getCode());
|
||||
$this->assertStringStartsWith("Bad format for version of dependency", $e->getMessage());
|
||||
self::assertEquals(EXCEPTION_BAD_FORMAT, $e->getCode());
|
||||
self::assertStringStartsWith('Bad format for version of dependency', $e->getMessage());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -200,12 +208,12 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
$this->gpm->data = [
|
||||
'admin' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "errors", "version" => "~4.0"],
|
||||
['name' => 'errors', 'version' => '~4.0'],
|
||||
]
|
||||
],
|
||||
'test' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "errors", "version" => "~3.0"]
|
||||
['name' => 'errors', 'version' => '~3.0']
|
||||
]
|
||||
],
|
||||
];
|
||||
|
|
@ -214,10 +222,10 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
|
||||
try {
|
||||
$this->gpm->calculateMergedDependenciesOfPackages($packages);
|
||||
$this->fail("Expected Exception not thrown");
|
||||
self::fail('Expected Exception not thrown');
|
||||
} catch (Exception $e) {
|
||||
$this->assertEquals(EXCEPTION_INCOMPATIBLE_VERSIONS, $e->getCode());
|
||||
$this->assertStringEndsWith("required in two incompatible versions", $e->getMessage());
|
||||
self::assertEquals(EXCEPTION_INCOMPATIBLE_VERSIONS, $e->getCode());
|
||||
self::assertStringEndsWith('required in two incompatible versions', $e->getMessage());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -226,22 +234,22 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
$this->gpm->data = [
|
||||
'admin' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "grav", "version" => ">=1.0.10"],
|
||||
["name" => "form", "version" => "~2.0"],
|
||||
["name" => "login", "version" => ">=2.0"],
|
||||
["name" => "errors", "version" => "*"],
|
||||
["name" => "problems"],
|
||||
['name' => 'grav', 'version' => '>=1.0.10'],
|
||||
['name' => 'form', 'version' => '~2.0'],
|
||||
['name' => 'login', 'version' => '>=2.0'],
|
||||
['name' => 'errors', 'version' => '*'],
|
||||
['name' => 'problems'],
|
||||
]
|
||||
],
|
||||
'login' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "antimatter", "version" => ">=1.0"]
|
||||
['name' => 'antimatter', 'version' => '>=1.0']
|
||||
]
|
||||
],
|
||||
'grav',
|
||||
'antimatter' => (object)[
|
||||
'dependencies' => [
|
||||
["name" => "something", "version" => ">=3.2"]
|
||||
['name' => 'something', 'version' => '>=3.2']
|
||||
]
|
||||
]
|
||||
|
||||
|
|
@ -252,71 +260,70 @@ class GpmTest extends \Codeception\TestCase\Test
|
|||
|
||||
$dependencies = $this->gpm->calculateMergedDependenciesOfPackages($packages);
|
||||
|
||||
$this->assertIsArray($dependencies);
|
||||
$this->assertCount(7, $dependencies);
|
||||
self::assertIsArray($dependencies);
|
||||
self::assertCount(7, $dependencies);
|
||||
|
||||
$this->assertSame('>=1.0.10', $dependencies['grav']);
|
||||
$this->assertArrayHasKey('errors', $dependencies);
|
||||
$this->assertArrayHasKey('problems', $dependencies);
|
||||
$this->assertArrayHasKey('antimatter', $dependencies);
|
||||
$this->assertArrayHasKey('something', $dependencies);
|
||||
$this->assertSame('>=3.2', $dependencies['something']);
|
||||
self::assertSame('>=1.0.10', $dependencies['grav']);
|
||||
self::assertArrayHasKey('errors', $dependencies);
|
||||
self::assertArrayHasKey('problems', $dependencies);
|
||||
self::assertArrayHasKey('antimatter', $dependencies);
|
||||
self::assertArrayHasKey('something', $dependencies);
|
||||
self::assertSame('>=3.2', $dependencies['something']);
|
||||
}
|
||||
|
||||
public function testVersionFormatIsNextSignificantRelease()
|
||||
public function testVersionFormatIsNextSignificantRelease(): void
|
||||
{
|
||||
$this->assertFalse($this->gpm->versionFormatIsNextSignificantRelease('>=1.0'));
|
||||
$this->assertFalse($this->gpm->versionFormatIsNextSignificantRelease('>=2.3.4'));
|
||||
$this->assertFalse($this->gpm->versionFormatIsNextSignificantRelease('>=2.3.x'));
|
||||
$this->assertFalse($this->gpm->versionFormatIsNextSignificantRelease('1.0'));
|
||||
$this->assertTrue($this->gpm->versionFormatIsNextSignificantRelease('~2.3.x'));
|
||||
$this->assertTrue($this->gpm->versionFormatIsNextSignificantRelease('~2.0'));
|
||||
self::assertFalse($this->gpm->versionFormatIsNextSignificantRelease('>=1.0'));
|
||||
self::assertFalse($this->gpm->versionFormatIsNextSignificantRelease('>=2.3.4'));
|
||||
self::assertFalse($this->gpm->versionFormatIsNextSignificantRelease('>=2.3.x'));
|
||||
self::assertFalse($this->gpm->versionFormatIsNextSignificantRelease('1.0'));
|
||||
self::assertTrue($this->gpm->versionFormatIsNextSignificantRelease('~2.3.x'));
|
||||
self::assertTrue($this->gpm->versionFormatIsNextSignificantRelease('~2.0'));
|
||||
}
|
||||
|
||||
public function testVersionFormatIsEqualOrHigher()
|
||||
public function testVersionFormatIsEqualOrHigher(): void
|
||||
{
|
||||
$this->assertTrue($this->gpm->versionFormatIsEqualOrHigher('>=1.0'));
|
||||
$this->assertTrue($this->gpm->versionFormatIsEqualOrHigher('>=2.3.4'));
|
||||
$this->assertTrue($this->gpm->versionFormatIsEqualOrHigher('>=2.3.x'));
|
||||
$this->assertFalse($this->gpm->versionFormatIsEqualOrHigher('~2.3.x'));
|
||||
$this->assertFalse($this->gpm->versionFormatIsEqualOrHigher('1.0'));
|
||||
self::assertTrue($this->gpm->versionFormatIsEqualOrHigher('>=1.0'));
|
||||
self::assertTrue($this->gpm->versionFormatIsEqualOrHigher('>=2.3.4'));
|
||||
self::assertTrue($this->gpm->versionFormatIsEqualOrHigher('>=2.3.x'));
|
||||
self::assertFalse($this->gpm->versionFormatIsEqualOrHigher('~2.3.x'));
|
||||
self::assertFalse($this->gpm->versionFormatIsEqualOrHigher('1.0'));
|
||||
}
|
||||
|
||||
public function testCheckNextSignificantReleasesAreCompatible()
|
||||
public function testCheckNextSignificantReleasesAreCompatible(): void
|
||||
{
|
||||
/*
|
||||
* ~1.0 is equivalent to >=1.0 < 2.0.0
|
||||
* ~1.2 is equivalent to >=1.2 <2.0.0
|
||||
* ~1.2.3 is equivalent to >=1.2.3 <1.3.0
|
||||
*/
|
||||
$this->assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.0', '1.2'));
|
||||
$this->assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.2', '1.0'));
|
||||
$this->assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.0', '1.0.10'));
|
||||
$this->assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.1', '1.1.10'));
|
||||
$this->assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('30.0', '30.10'));
|
||||
$this->assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.0', '1.1.10'));
|
||||
$this->assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.0', '1.8'));
|
||||
$this->assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.0.1', '1.1'));
|
||||
$this->assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('2.0.0-beta', '2.0'));
|
||||
$this->assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('2.0.0-rc.1', '2.0'));
|
||||
$this->assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('2.0', '2.0.0-alpha'));
|
||||
self::assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.0', '1.2'));
|
||||
self::assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.2', '1.0'));
|
||||
self::assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.0', '1.0.10'));
|
||||
self::assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.1', '1.1.10'));
|
||||
self::assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('30.0', '30.10'));
|
||||
self::assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.0', '1.1.10'));
|
||||
self::assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.0', '1.8'));
|
||||
self::assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('1.0.1', '1.1'));
|
||||
self::assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('2.0.0-beta', '2.0'));
|
||||
self::assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('2.0.0-rc.1', '2.0'));
|
||||
self::assertTrue($this->gpm->checkNextSignificantReleasesAreCompatible('2.0', '2.0.0-alpha'));
|
||||
|
||||
$this->assertFalse($this->gpm->checkNextSignificantReleasesAreCompatible('1.0', '2.2'));
|
||||
$this->assertFalse($this->gpm->checkNextSignificantReleasesAreCompatible('1.0.0-beta.1', '2.0'));
|
||||
$this->assertFalse($this->gpm->checkNextSignificantReleasesAreCompatible('0.9.99', '1.0.0'));
|
||||
$this->assertFalse($this->gpm->checkNextSignificantReleasesAreCompatible('0.9.99', '1.0.10'));
|
||||
$this->assertFalse($this->gpm->checkNextSignificantReleasesAreCompatible('0.9.99', '1.0.10.2'));
|
||||
self::assertFalse($this->gpm->checkNextSignificantReleasesAreCompatible('1.0', '2.2'));
|
||||
self::assertFalse($this->gpm->checkNextSignificantReleasesAreCompatible('1.0.0-beta.1', '2.0'));
|
||||
self::assertFalse($this->gpm->checkNextSignificantReleasesAreCompatible('0.9.99', '1.0.0'));
|
||||
self::assertFalse($this->gpm->checkNextSignificantReleasesAreCompatible('0.9.99', '1.0.10'));
|
||||
self::assertFalse($this->gpm->checkNextSignificantReleasesAreCompatible('0.9.99', '1.0.10.2'));
|
||||
}
|
||||
|
||||
|
||||
public function testCalculateVersionNumberFromDependencyVersion()
|
||||
public function testCalculateVersionNumberFromDependencyVersion(): void
|
||||
{
|
||||
$this->assertSame('2.0', $this->gpm->calculateVersionNumberFromDependencyVersion('>=2.0'));
|
||||
$this->assertSame('2.0.2', $this->gpm->calculateVersionNumberFromDependencyVersion('>=2.0.2'));
|
||||
$this->assertSame('2.0.2', $this->gpm->calculateVersionNumberFromDependencyVersion('~2.0.2'));
|
||||
$this->assertSame('1', $this->gpm->calculateVersionNumberFromDependencyVersion('~1'));
|
||||
$this->assertNull($this->gpm->calculateVersionNumberFromDependencyVersion(''));
|
||||
$this->assertNull($this->gpm->calculateVersionNumberFromDependencyVersion('*'));
|
||||
$this->assertSame('2.0.2', $this->gpm->calculateVersionNumberFromDependencyVersion('2.0.2'));
|
||||
self::assertSame('2.0', $this->gpm->calculateVersionNumberFromDependencyVersion('>=2.0'));
|
||||
self::assertSame('2.0.2', $this->gpm->calculateVersionNumberFromDependencyVersion('>=2.0.2'));
|
||||
self::assertSame('2.0.2', $this->gpm->calculateVersionNumberFromDependencyVersion('~2.0.2'));
|
||||
self::assertSame('1', $this->gpm->calculateVersionNumberFromDependencyVersion('~1'));
|
||||
self::assertNull($this->gpm->calculateVersionNumberFromDependencyVersion(''));
|
||||
self::assertNull($this->gpm->calculateVersionNumberFromDependencyVersion('*'));
|
||||
self::assertSame('2.0.2', $this->gpm->calculateVersionNumberFromDependencyVersion('2.0.2'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class ExcerptsTest extends \Codeception\TestCase\Test
|
|||
|
||||
protected $old_home;
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$grav = Fixtures::get('grav');
|
||||
$this->grav = $grav();
|
||||
|
|
@ -70,49 +70,49 @@ class ExcerptsTest extends \Codeception\TestCase\Test
|
|||
$this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
protected function _after(): void
|
||||
{
|
||||
$this->config->set('system.home.alias', $this->old_home);
|
||||
}
|
||||
|
||||
|
||||
public function testProcessImageHtml()
|
||||
public function testProcessImageHtml(): void
|
||||
{
|
||||
$this->assertRegexp(
|
||||
self::assertRegexp(
|
||||
'|<img alt="Sample Image" src="\/images\/.*-sample-image.jpe?g\" data-src="sample-image\.jpg\?cropZoom=300,300" \/>|',
|
||||
Excerpts::processImageHtml('<img src="sample-image.jpg?cropZoom=300,300" alt="Sample Image" />', $this->page)
|
||||
);
|
||||
$this->assertRegexp(
|
||||
self::assertRegexp(
|
||||
'|<img alt="Sample Image" class="foo" src="\/images\/.*-sample-image.jpe?g\" data-src="sample-image\.jpg\?classes=foo" \/>|',
|
||||
Excerpts::processImageHtml('<img src="sample-image.jpg?classes=foo" alt="Sample Image" />', $this->page)
|
||||
);
|
||||
}
|
||||
|
||||
public function testNoProcess()
|
||||
public function testNoProcess(): void
|
||||
{
|
||||
$this->assertStringStartsWith(
|
||||
self::assertStringStartsWith(
|
||||
'<a href="https://play.google.com/store/apps/details?hl=de" id="org.jitsi.meet" target="_blank"',
|
||||
Excerpts::processLinkHtml('<a href="https://play.google.com/store/apps/details?id=org.jitsi.meet&hl=de&target=_blank">regular process</a>')
|
||||
);
|
||||
|
||||
$this->assertStringStartsWith(
|
||||
self::assertStringStartsWith(
|
||||
'<a href="https://play.google.com/store/apps/details?id=org.jitsi.meet&hl=de&target=_blank"',
|
||||
Excerpts::processLinkHtml('<a href="https://play.google.com/store/apps/details?id=org.jitsi.meet&hl=de&target=_blank&noprocess">noprocess</a>')
|
||||
);
|
||||
|
||||
$this->assertStringStartsWith(
|
||||
self::assertStringStartsWith(
|
||||
'<a href="https://play.google.com/store/apps/details?id=org.jitsi.meet&hl=de" target="_blank"',
|
||||
Excerpts::processLinkHtml('<a href="https://play.google.com/store/apps/details?id=org.jitsi.meet&hl=de&target=_blank&noprocess=id">noprocess=id</a>')
|
||||
);
|
||||
}
|
||||
|
||||
public function testTarget()
|
||||
public function testTarget(): void
|
||||
{
|
||||
$this->assertStringStartsWith(
|
||||
self::assertStringStartsWith(
|
||||
'<a href="https://play.google.com/store/apps/details" target="_blank"',
|
||||
Excerpts::processLinkHtml('<a href="https://play.google.com/store/apps/details?target=_blank">only target</a>')
|
||||
);
|
||||
$this->assertStringStartsWith(
|
||||
self::assertStringStartsWith(
|
||||
'<a href="https://meet.weikamp.biz/Support" rel="nofollow" target="_blank"',
|
||||
Excerpts::processLinkHtml('<a href="https://meet.weikamp.biz/Support?rel=nofollow&target=_blank">target and rel</a>')
|
||||
);
|
||||
|
|
|
|||
|
|
@ -16,130 +16,130 @@ class InflectorTest extends \Codeception\TestCase\Test
|
|||
/** @var Inflector $uri */
|
||||
protected $inflector;
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$grav = Fixtures::get('grav');
|
||||
$this->grav = $grav();
|
||||
$this->inflector = $this->grav['inflector'];
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
protected function _after(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testPluralize()
|
||||
public function testPluralize(): void
|
||||
{
|
||||
$this->assertSame('words', $this->inflector->pluralize('word'));
|
||||
$this->assertSame('kisses', $this->inflector->pluralize('kiss'));
|
||||
$this->assertSame('volcanoes', $this->inflector->pluralize('volcanoe'));
|
||||
$this->assertSame('cherries', $this->inflector->pluralize('cherry'));
|
||||
$this->assertSame('days', $this->inflector->pluralize('day'));
|
||||
$this->assertSame('knives', $this->inflector->pluralize('knife'));
|
||||
self::assertSame('words', $this->inflector->pluralize('word'));
|
||||
self::assertSame('kisses', $this->inflector->pluralize('kiss'));
|
||||
self::assertSame('volcanoes', $this->inflector->pluralize('volcanoe'));
|
||||
self::assertSame('cherries', $this->inflector->pluralize('cherry'));
|
||||
self::assertSame('days', $this->inflector->pluralize('day'));
|
||||
self::assertSame('knives', $this->inflector->pluralize('knife'));
|
||||
}
|
||||
|
||||
public function testSingularize()
|
||||
public function testSingularize(): void
|
||||
{
|
||||
$this->assertSame('word', $this->inflector->singularize('words'));
|
||||
$this->assertSame('kiss', $this->inflector->singularize('kisses'));
|
||||
$this->assertSame('volcanoe', $this->inflector->singularize('volcanoe'));
|
||||
$this->assertSame('cherry', $this->inflector->singularize('cherries'));
|
||||
$this->assertSame('day', $this->inflector->singularize('days'));
|
||||
$this->assertSame('knife', $this->inflector->singularize('knives'));
|
||||
self::assertSame('word', $this->inflector->singularize('words'));
|
||||
self::assertSame('kiss', $this->inflector->singularize('kisses'));
|
||||
self::assertSame('volcanoe', $this->inflector->singularize('volcanoe'));
|
||||
self::assertSame('cherry', $this->inflector->singularize('cherries'));
|
||||
self::assertSame('day', $this->inflector->singularize('days'));
|
||||
self::assertSame('knife', $this->inflector->singularize('knives'));
|
||||
}
|
||||
|
||||
public function testTitleize()
|
||||
public function testTitleize(): void
|
||||
{
|
||||
$this->assertSame('This String Is Titleized', $this->inflector->titleize('ThisStringIsTitleized'));
|
||||
$this->assertSame('This String Is Titleized', $this->inflector->titleize('this string is titleized'));
|
||||
$this->assertSame('This String Is Titleized', $this->inflector->titleize('this_string_is_titleized'));
|
||||
$this->assertSame('This String Is Titleized', $this->inflector->titleize('this-string-is-titleized'));
|
||||
self::assertSame('This String Is Titleized', $this->inflector->titleize('ThisStringIsTitleized'));
|
||||
self::assertSame('This String Is Titleized', $this->inflector->titleize('this string is titleized'));
|
||||
self::assertSame('This String Is Titleized', $this->inflector->titleize('this_string_is_titleized'));
|
||||
self::assertSame('This String Is Titleized', $this->inflector->titleize('this-string-is-titleized'));
|
||||
|
||||
$this->assertSame('This string is titleized', $this->inflector->titleize('ThisStringIsTitleized', 'first'));
|
||||
$this->assertSame('This string is titleized', $this->inflector->titleize('this string is titleized', 'first'));
|
||||
$this->assertSame('This string is titleized', $this->inflector->titleize('this_string_is_titleized', 'first'));
|
||||
$this->assertSame('This string is titleized', $this->inflector->titleize('this-string-is-titleized', 'first'));
|
||||
self::assertSame('This string is titleized', $this->inflector->titleize('ThisStringIsTitleized', 'first'));
|
||||
self::assertSame('This string is titleized', $this->inflector->titleize('this string is titleized', 'first'));
|
||||
self::assertSame('This string is titleized', $this->inflector->titleize('this_string_is_titleized', 'first'));
|
||||
self::assertSame('This string is titleized', $this->inflector->titleize('this-string-is-titleized', 'first'));
|
||||
}
|
||||
|
||||
public function testCamelize()
|
||||
public function testCamelize(): void
|
||||
{
|
||||
$this->assertSame('ThisStringIsCamelized', $this->inflector->camelize('This String Is Camelized'));
|
||||
$this->assertSame('ThisStringIsCamelized', $this->inflector->camelize('thisStringIsCamelized'));
|
||||
$this->assertSame('ThisStringIsCamelized', $this->inflector->camelize('This_String_Is_Camelized'));
|
||||
$this->assertSame('ThisStringIsCamelized', $this->inflector->camelize('this string is camelized'));
|
||||
$this->assertSame('GravSPrettyCoolMy1', $this->inflector->camelize("Grav's Pretty Cool. My #1!"));
|
||||
self::assertSame('ThisStringIsCamelized', $this->inflector->camelize('This String Is Camelized'));
|
||||
self::assertSame('ThisStringIsCamelized', $this->inflector->camelize('thisStringIsCamelized'));
|
||||
self::assertSame('ThisStringIsCamelized', $this->inflector->camelize('This_String_Is_Camelized'));
|
||||
self::assertSame('ThisStringIsCamelized', $this->inflector->camelize('this string is camelized'));
|
||||
self::assertSame('GravSPrettyCoolMy1', $this->inflector->camelize("Grav's Pretty Cool. My #1!"));
|
||||
}
|
||||
|
||||
public function testUnderscorize()
|
||||
public function testUnderscorize(): void
|
||||
{
|
||||
$this->assertSame('this_string_is_underscorized', $this->inflector->underscorize('This String Is Underscorized'));
|
||||
$this->assertSame('this_string_is_underscorized', $this->inflector->underscorize('ThisStringIsUnderscorized'));
|
||||
$this->assertSame('this_string_is_underscorized', $this->inflector->underscorize('This_String_Is_Underscorized'));
|
||||
$this->assertSame('this_string_is_underscorized', $this->inflector->underscorize('This-String-Is-Underscorized'));
|
||||
self::assertSame('this_string_is_underscorized', $this->inflector->underscorize('This String Is Underscorized'));
|
||||
self::assertSame('this_string_is_underscorized', $this->inflector->underscorize('ThisStringIsUnderscorized'));
|
||||
self::assertSame('this_string_is_underscorized', $this->inflector->underscorize('This_String_Is_Underscorized'));
|
||||
self::assertSame('this_string_is_underscorized', $this->inflector->underscorize('This-String-Is-Underscorized'));
|
||||
}
|
||||
|
||||
public function testHyphenize()
|
||||
public function testHyphenize(): void
|
||||
{
|
||||
$this->assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('This String Is Hyphenized'));
|
||||
$this->assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('ThisStringIsHyphenized'));
|
||||
$this->assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('This-String-Is-Hyphenized'));
|
||||
$this->assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('This_String_Is_Hyphenized'));
|
||||
self::assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('This String Is Hyphenized'));
|
||||
self::assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('ThisStringIsHyphenized'));
|
||||
self::assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('This-String-Is-Hyphenized'));
|
||||
self::assertSame('this-string-is-hyphenized', $this->inflector->hyphenize('This_String_Is_Hyphenized'));
|
||||
}
|
||||
|
||||
public function testHumanize()
|
||||
public function testHumanize(): void
|
||||
{
|
||||
//$this->assertSame('This string is humanized', $this->inflector->humanize('ThisStringIsHumanized'));
|
||||
$this->assertSame('This string is humanized', $this->inflector->humanize('this_string_is_humanized'));
|
||||
//$this->assertSame('This string is humanized', $this->inflector->humanize('this-string-is-humanized'));
|
||||
//self::assertSame('This string is humanized', $this->inflector->humanize('ThisStringIsHumanized'));
|
||||
self::assertSame('This string is humanized', $this->inflector->humanize('this_string_is_humanized'));
|
||||
//self::assertSame('This string is humanized', $this->inflector->humanize('this-string-is-humanized'));
|
||||
|
||||
$this->assertSame('This String Is Humanized', $this->inflector->humanize('this_string_is_humanized', 'all'));
|
||||
//$this->assertSame('This String Is Humanized', $this->inflector->humanize('this-string-is-humanized'), 'all');
|
||||
self::assertSame('This String Is Humanized', $this->inflector->humanize('this_string_is_humanized', 'all'));
|
||||
//self::assertSame('This String Is Humanized', $this->inflector->humanize('this-string-is-humanized'), 'all');
|
||||
}
|
||||
|
||||
public function testVariablize()
|
||||
public function testVariablize(): void
|
||||
{
|
||||
$this->assertSame('thisStringIsVariablized', $this->inflector->variablize('This String Is Variablized'));
|
||||
$this->assertSame('thisStringIsVariablized', $this->inflector->variablize('ThisStringIsVariablized'));
|
||||
$this->assertSame('thisStringIsVariablized', $this->inflector->variablize('This_String_Is_Variablized'));
|
||||
$this->assertSame('thisStringIsVariablized', $this->inflector->variablize('this string is variablized'));
|
||||
$this->assertSame('gravSPrettyCoolMy1', $this->inflector->variablize("Grav's Pretty Cool. My #1!"));
|
||||
self::assertSame('thisStringIsVariablized', $this->inflector->variablize('This String Is Variablized'));
|
||||
self::assertSame('thisStringIsVariablized', $this->inflector->variablize('ThisStringIsVariablized'));
|
||||
self::assertSame('thisStringIsVariablized', $this->inflector->variablize('This_String_Is_Variablized'));
|
||||
self::assertSame('thisStringIsVariablized', $this->inflector->variablize('this string is variablized'));
|
||||
self::assertSame('gravSPrettyCoolMy1', $this->inflector->variablize("Grav's Pretty Cool. My #1!"));
|
||||
}
|
||||
|
||||
public function testTableize()
|
||||
public function testTableize(): void
|
||||
{
|
||||
$this->assertSame('people', $this->inflector->tableize('Person'));
|
||||
$this->assertSame('pages', $this->inflector->tableize('Page'));
|
||||
$this->assertSame('blog_pages', $this->inflector->tableize('BlogPage'));
|
||||
$this->assertSame('admin_dependencies', $this->inflector->tableize('adminDependency'));
|
||||
$this->assertSame('admin_dependencies', $this->inflector->tableize('admin-dependency'));
|
||||
$this->assertSame('admin_dependencies', $this->inflector->tableize('admin_dependency'));
|
||||
self::assertSame('people', $this->inflector->tableize('Person'));
|
||||
self::assertSame('pages', $this->inflector->tableize('Page'));
|
||||
self::assertSame('blog_pages', $this->inflector->tableize('BlogPage'));
|
||||
self::assertSame('admin_dependencies', $this->inflector->tableize('adminDependency'));
|
||||
self::assertSame('admin_dependencies', $this->inflector->tableize('admin-dependency'));
|
||||
self::assertSame('admin_dependencies', $this->inflector->tableize('admin_dependency'));
|
||||
}
|
||||
|
||||
public function testClassify()
|
||||
public function testClassify(): void
|
||||
{
|
||||
$this->assertSame('Person', $this->inflector->classify('people'));
|
||||
$this->assertSame('Page', $this->inflector->classify('pages'));
|
||||
$this->assertSame('BlogPage', $this->inflector->classify('blog_pages'));
|
||||
$this->assertSame('AdminDependency', $this->inflector->classify('admin_dependencies'));
|
||||
self::assertSame('Person', $this->inflector->classify('people'));
|
||||
self::assertSame('Page', $this->inflector->classify('pages'));
|
||||
self::assertSame('BlogPage', $this->inflector->classify('blog_pages'));
|
||||
self::assertSame('AdminDependency', $this->inflector->classify('admin_dependencies'));
|
||||
}
|
||||
|
||||
public function testOrdinalize()
|
||||
public function testOrdinalize(): void
|
||||
{
|
||||
$this->assertSame('1st', $this->inflector->ordinalize(1));
|
||||
$this->assertSame('2nd', $this->inflector->ordinalize(2));
|
||||
$this->assertSame('3rd', $this->inflector->ordinalize(3));
|
||||
$this->assertSame('4th', $this->inflector->ordinalize(4));
|
||||
$this->assertSame('5th', $this->inflector->ordinalize(5));
|
||||
$this->assertSame('16th', $this->inflector->ordinalize(16));
|
||||
$this->assertSame('51st', $this->inflector->ordinalize(51));
|
||||
$this->assertSame('111th', $this->inflector->ordinalize(111));
|
||||
$this->assertSame('123rd', $this->inflector->ordinalize(123));
|
||||
self::assertSame('1st', $this->inflector->ordinalize(1));
|
||||
self::assertSame('2nd', $this->inflector->ordinalize(2));
|
||||
self::assertSame('3rd', $this->inflector->ordinalize(3));
|
||||
self::assertSame('4th', $this->inflector->ordinalize(4));
|
||||
self::assertSame('5th', $this->inflector->ordinalize(5));
|
||||
self::assertSame('16th', $this->inflector->ordinalize(16));
|
||||
self::assertSame('51st', $this->inflector->ordinalize(51));
|
||||
self::assertSame('111th', $this->inflector->ordinalize(111));
|
||||
self::assertSame('123rd', $this->inflector->ordinalize(123));
|
||||
}
|
||||
|
||||
public function testMonthize()
|
||||
public function testMonthize(): void
|
||||
{
|
||||
$this->assertSame(0, $this->inflector->monthize(10));
|
||||
$this->assertSame(1, $this->inflector->monthize(33));
|
||||
$this->assertSame(1, $this->inflector->monthize(41));
|
||||
$this->assertSame(11, $this->inflector->monthize(364));
|
||||
self::assertSame(0, $this->inflector->monthize(10));
|
||||
self::assertSame(1, $this->inflector->monthize(33));
|
||||
self::assertSame(1, $this->inflector->monthize(41));
|
||||
self::assertSame(11, $this->inflector->monthize(364));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,21 +7,21 @@ use Grav\Common\Language\LanguageCodes;
|
|||
*/
|
||||
class LanguageCodesTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
public function testRtl()
|
||||
public function testRtl(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
self::assertSame(
|
||||
'ltr',
|
||||
LanguageCodes::getOrientation('en')
|
||||
);
|
||||
$this->assertSame(
|
||||
self::assertSame(
|
||||
'rtl',
|
||||
LanguageCodes::getOrientation('ar')
|
||||
);
|
||||
$this->assertSame(
|
||||
self::assertSame(
|
||||
'rtl',
|
||||
LanguageCodes::getOrientation('he')
|
||||
);
|
||||
$this->assertTrue(LanguageCodes::isRtl('ar'));
|
||||
$this->assertFalse(LanguageCodes::isRtl('fr'));
|
||||
self::assertTrue(LanguageCodes::isRtl('ar'));
|
||||
self::assertFalse(LanguageCodes::isRtl('fr'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -21,7 +21,7 @@ class PagesTest extends \Codeception\TestCase\Test
|
|||
/** @var PageInterface $root_page */
|
||||
protected $root_page;
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$grav = Fixtures::get('grav');
|
||||
$this->grav = $grav();
|
||||
|
|
@ -35,46 +35,46 @@ class PagesTest extends \Codeception\TestCase\Test
|
|||
$this->pages->init();
|
||||
}
|
||||
|
||||
public function testBase()
|
||||
public function testBase(): void
|
||||
{
|
||||
$this->assertSame('', $this->pages->base());
|
||||
self::assertSame('', $this->pages->base());
|
||||
$this->pages->base('/test');
|
||||
$this->assertSame('/test', $this->pages->base());
|
||||
self::assertSame('/test', $this->pages->base());
|
||||
$this->pages->base('');
|
||||
$this->assertSame($this->pages->base(), '');
|
||||
self::assertSame($this->pages->base(), '');
|
||||
}
|
||||
|
||||
public function testLastModified()
|
||||
public function testLastModified(): void
|
||||
{
|
||||
$this->assertNull($this->pages->lastModified());
|
||||
self::assertNull($this->pages->lastModified());
|
||||
$this->pages->lastModified('test');
|
||||
$this->assertSame('test', $this->pages->lastModified());
|
||||
self::assertSame('test', $this->pages->lastModified());
|
||||
}
|
||||
|
||||
public function testInstances()
|
||||
public function testInstances(): void
|
||||
{
|
||||
$this->assertIsArray($this->pages->instances());
|
||||
self::assertIsArray($this->pages->instances());
|
||||
foreach ($this->pages->instances() as $instance) {
|
||||
$this->assertInstanceOf(PageInterface::class, $instance);
|
||||
self::assertInstanceOf(PageInterface::class, $instance);
|
||||
}
|
||||
}
|
||||
|
||||
public function testRoutes()
|
||||
public function testRoutes(): void
|
||||
{
|
||||
/** @var UniformResourceLocator $locator */
|
||||
$locator = $this->grav['locator'];
|
||||
$folder = $locator->findResource('tests://');
|
||||
|
||||
$this->assertIsArray($this->pages->routes());
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/01.home', $this->pages->routes()['/']);
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/01.home', $this->pages->routes()['/home']);
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog', $this->pages->routes()['/blog']);
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-one', $this->pages->routes()['/blog/post-one']);
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-two', $this->pages->routes()['/blog/post-two']);
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/03.about', $this->pages->routes()['/about']);
|
||||
self::assertIsArray($this->pages->routes());
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/01.home', $this->pages->routes()['/']);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/01.home', $this->pages->routes()['/home']);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/02.blog', $this->pages->routes()['/blog']);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-one', $this->pages->routes()['/blog/post-one']);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-two', $this->pages->routes()['/blog/post-two']);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/03.about', $this->pages->routes()['/about']);
|
||||
}
|
||||
|
||||
public function testAddPage()
|
||||
public function testAddPage(): void
|
||||
{
|
||||
/** @var UniformResourceLocator $locator */
|
||||
$locator = $this->grav['locator'];
|
||||
|
|
@ -86,11 +86,11 @@ class PagesTest extends \Codeception\TestCase\Test
|
|||
|
||||
$this->pages->addPage($aPage, '/new-page');
|
||||
|
||||
$this->assertContains('/new-page', array_keys($this->pages->routes()));
|
||||
$this->assertSame($folder . '/fake/single-pages/01.simple-page', $this->pages->routes()['/new-page']);
|
||||
self::assertContains('/new-page', array_keys($this->pages->routes()));
|
||||
self::assertSame($folder . '/fake/single-pages/01.simple-page', $this->pages->routes()['/new-page']);
|
||||
}
|
||||
|
||||
public function testSort()
|
||||
public function testSort(): void
|
||||
{
|
||||
/** @var UniformResourceLocator $locator */
|
||||
$locator = $this->grav['locator'];
|
||||
|
|
@ -99,34 +99,34 @@ class PagesTest extends \Codeception\TestCase\Test
|
|||
$aPage = $this->pages->find('/blog');
|
||||
$subPagesSorted = $this->pages->sort($aPage);
|
||||
|
||||
$this->assertIsArray($subPagesSorted);
|
||||
$this->assertCount(2, $subPagesSorted);
|
||||
self::assertIsArray($subPagesSorted);
|
||||
self::assertCount(2, $subPagesSorted);
|
||||
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted)[0]);
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted)[1]);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted)[0]);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted)[1]);
|
||||
|
||||
$this->assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted));
|
||||
$this->assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted));
|
||||
self::assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted));
|
||||
self::assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted));
|
||||
|
||||
$this->assertSame(['slug' => 'post-one'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-one']);
|
||||
$this->assertSame(['slug' => 'post-two'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-two']);
|
||||
self::assertSame(['slug' => 'post-one'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-one']);
|
||||
self::assertSame(['slug' => 'post-two'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-two']);
|
||||
|
||||
$subPagesSorted = $this->pages->sort($aPage, null, 'desc');
|
||||
|
||||
$this->assertIsArray($subPagesSorted);
|
||||
$this->assertCount(2, $subPagesSorted);
|
||||
self::assertIsArray($subPagesSorted);
|
||||
self::assertCount(2, $subPagesSorted);
|
||||
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted)[0]);
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted)[1]);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted)[0]);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted)[1]);
|
||||
|
||||
$this->assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted));
|
||||
$this->assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted));
|
||||
self::assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted));
|
||||
self::assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted));
|
||||
|
||||
$this->assertSame(['slug' => 'post-one'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-one']);
|
||||
$this->assertSame(['slug' => 'post-two'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-two']);
|
||||
self::assertSame(['slug' => 'post-one'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-one']);
|
||||
self::assertSame(['slug' => 'post-two'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-two']);
|
||||
}
|
||||
|
||||
public function testSortCollection()
|
||||
public function testSortCollection(): void
|
||||
{
|
||||
/** @var UniformResourceLocator $locator */
|
||||
$locator = $this->grav['locator'];
|
||||
|
|
@ -135,34 +135,34 @@ class PagesTest extends \Codeception\TestCase\Test
|
|||
$aPage = $this->pages->find('/blog');
|
||||
$subPagesSorted = $this->pages->sortCollection($aPage->children(), $aPage->orderBy());
|
||||
|
||||
$this->assertIsArray($subPagesSorted);
|
||||
$this->assertCount(2, $subPagesSorted);
|
||||
self::assertIsArray($subPagesSorted);
|
||||
self::assertCount(2, $subPagesSorted);
|
||||
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted)[0]);
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted)[1]);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted)[0]);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted)[1]);
|
||||
|
||||
$this->assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted));
|
||||
$this->assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted));
|
||||
self::assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted));
|
||||
self::assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted));
|
||||
|
||||
$this->assertSame(['slug' => 'post-one'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-one']);
|
||||
$this->assertSame(['slug' => 'post-two'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-two']);
|
||||
self::assertSame(['slug' => 'post-one'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-one']);
|
||||
self::assertSame(['slug' => 'post-two'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-two']);
|
||||
|
||||
$subPagesSorted = $this->pages->sortCollection($aPage->children(), $aPage->orderBy(), 'desc');
|
||||
|
||||
$this->assertIsArray($subPagesSorted);
|
||||
$this->assertCount(2, $subPagesSorted);
|
||||
self::assertIsArray($subPagesSorted);
|
||||
self::assertCount(2, $subPagesSorted);
|
||||
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted)[0]);
|
||||
$this->assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted)[1]);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted)[0]);
|
||||
self::assertSame($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted)[1]);
|
||||
|
||||
$this->assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted));
|
||||
$this->assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted));
|
||||
self::assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-one', array_keys($subPagesSorted));
|
||||
self::assertContains($folder . '/fake/simple-site/user/pages/02.blog/post-two', array_keys($subPagesSorted));
|
||||
|
||||
$this->assertSame(['slug' => 'post-one'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-one']);
|
||||
$this->assertSame(['slug' => 'post-two'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-two']);
|
||||
self::assertSame(['slug' => 'post-one'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-one']);
|
||||
self::assertSame(['slug' => 'post-two'], $subPagesSorted[$folder . '/fake/simple-site/user/pages/02.blog/post-two']);
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
public function testGet(): void
|
||||
{
|
||||
/** @var UniformResourceLocator $locator */
|
||||
$locator = $this->grav['locator'];
|
||||
|
|
@ -170,14 +170,14 @@ class PagesTest extends \Codeception\TestCase\Test
|
|||
|
||||
//Page existing
|
||||
$aPage = $this->pages->get($folder . '/fake/simple-site/user/pages/03.about');
|
||||
$this->assertInstanceOf(PageInterface::class, $aPage);
|
||||
self::assertInstanceOf(PageInterface::class, $aPage);
|
||||
|
||||
//Page not existing
|
||||
$anotherPage = $this->pages->get($folder . '/fake/simple-site/user/pages/03.non-existing');
|
||||
$this->assertNull($anotherPage);
|
||||
self::assertNull($anotherPage);
|
||||
}
|
||||
|
||||
public function testChildren()
|
||||
public function testChildren(): void
|
||||
{
|
||||
/** @var UniformResourceLocator $locator */
|
||||
$locator = $this->grav['locator'];
|
||||
|
|
@ -185,90 +185,90 @@ class PagesTest extends \Codeception\TestCase\Test
|
|||
|
||||
//Page existing
|
||||
$children = $this->pages->children($folder . '/fake/simple-site/user/pages/02.blog');
|
||||
$this->assertInstanceOf('Grav\Common\Page\Collection', $children);
|
||||
self::assertInstanceOf('Grav\Common\Page\Collection', $children);
|
||||
|
||||
//Page not existing
|
||||
$children = $this->pages->children($folder . '/fake/whatever/non-existing');
|
||||
$this->assertSame([], $children->toArray());
|
||||
self::assertSame([], $children->toArray());
|
||||
}
|
||||
|
||||
public function testDispatch()
|
||||
public function testDispatch(): void
|
||||
{
|
||||
$aPage = $this->pages->dispatch('/blog');
|
||||
$this->assertInstanceOf(PageInterface::class, $aPage);
|
||||
self::assertInstanceOf(PageInterface::class, $aPage);
|
||||
|
||||
$aPage = $this->pages->dispatch('/about');
|
||||
$this->assertInstanceOf(PageInterface::class, $aPage);
|
||||
self::assertInstanceOf(PageInterface::class, $aPage);
|
||||
|
||||
$aPage = $this->pages->dispatch('/blog/post-one');
|
||||
$this->assertInstanceOf(PageInterface::class, $aPage);
|
||||
self::assertInstanceOf(PageInterface::class, $aPage);
|
||||
|
||||
//Page not existing
|
||||
$aPage = $this->pages->dispatch('/non-existing');
|
||||
$this->assertNull($aPage);
|
||||
self::assertNull($aPage);
|
||||
}
|
||||
|
||||
public function testRoot()
|
||||
public function testRoot(): void
|
||||
{
|
||||
$root = $this->pages->root();
|
||||
$this->assertInstanceOf(PageInterface::class, $root);
|
||||
$this->assertSame('pages', $root->folder());
|
||||
self::assertInstanceOf(PageInterface::class, $root);
|
||||
self::assertSame('pages', $root->folder());
|
||||
}
|
||||
|
||||
public function testBlueprints()
|
||||
public function testBlueprints(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testAll()
|
||||
{
|
||||
$this->assertIsObject($this->pages->all());
|
||||
$this->assertIsArray($this->pages->all()->toArray());
|
||||
self::assertIsObject($this->pages->all());
|
||||
self::assertIsArray($this->pages->all()->toArray());
|
||||
foreach ($this->pages->all() as $page) {
|
||||
$this->assertInstanceOf(PageInterface::class, $page);
|
||||
self::assertInstanceOf(PageInterface::class, $page);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetList()
|
||||
public function testGetList(): void
|
||||
{
|
||||
$list = $this->pages->getList();
|
||||
$this->assertIsArray($list);
|
||||
$this->assertSame('—-▸ Home', $list['/']);
|
||||
$this->assertSame('—-▸ Blog', $list['/blog']);
|
||||
self::assertIsArray($list);
|
||||
self::assertSame('—-▸ Home', $list['/']);
|
||||
self::assertSame('—-▸ Blog', $list['/blog']);
|
||||
}
|
||||
|
||||
public function testGetTypes()
|
||||
public function testGetTypes(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testTypes()
|
||||
public function testTypes(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testModularTypes()
|
||||
public function testModularTypes(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testPageTypes()
|
||||
public function testPageTypes(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testAccessLevels()
|
||||
public function testAccessLevels(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testParents()
|
||||
public function testParents(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testParentsRawRoutes()
|
||||
public function testParentsRawRoutes(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testGetHomeRoute()
|
||||
public function testGetHomeRoute(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testResetPages()
|
||||
public function testResetPages(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,44 +15,44 @@ class TwigExtensionTest extends \Codeception\TestCase\Test
|
|||
/** @var TwigExtension $twig_ext */
|
||||
protected $twig_ext;
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$this->grav = Fixtures::get('grav');
|
||||
$this->twig_ext = new TwigExtension();
|
||||
}
|
||||
|
||||
public function testInflectorFilter()
|
||||
public function testInflectorFilter(): void
|
||||
{
|
||||
$this->assertSame('people', $this->twig_ext->inflectorFilter('plural', 'person'));
|
||||
$this->assertSame('shoe', $this->twig_ext->inflectorFilter('singular', 'shoes'));
|
||||
$this->assertSame('Welcome Page', $this->twig_ext->inflectorFilter('title', 'welcome page'));
|
||||
$this->assertSame('SendEmail', $this->twig_ext->inflectorFilter('camel', 'send_email'));
|
||||
$this->assertSame('camel_cased', $this->twig_ext->inflectorFilter('underscor', 'CamelCased'));
|
||||
$this->assertSame('something-text', $this->twig_ext->inflectorFilter('hyphen', 'Something Text'));
|
||||
$this->assertSame('Something text to read', $this->twig_ext->inflectorFilter('human', 'something_text_to_read'));
|
||||
$this->assertSame(5, $this->twig_ext->inflectorFilter('month', '175'));
|
||||
$this->assertSame('10th', $this->twig_ext->inflectorFilter('ordinal', '10'));
|
||||
self::assertSame('people', $this->twig_ext->inflectorFilter('plural', 'person'));
|
||||
self::assertSame('shoe', $this->twig_ext->inflectorFilter('singular', 'shoes'));
|
||||
self::assertSame('Welcome Page', $this->twig_ext->inflectorFilter('title', 'welcome page'));
|
||||
self::assertSame('SendEmail', $this->twig_ext->inflectorFilter('camel', 'send_email'));
|
||||
self::assertSame('camel_cased', $this->twig_ext->inflectorFilter('underscor', 'CamelCased'));
|
||||
self::assertSame('something-text', $this->twig_ext->inflectorFilter('hyphen', 'Something Text'));
|
||||
self::assertSame('Something text to read', $this->twig_ext->inflectorFilter('human', 'something_text_to_read'));
|
||||
self::assertSame(5, $this->twig_ext->inflectorFilter('month', '175'));
|
||||
self::assertSame('10th', $this->twig_ext->inflectorFilter('ordinal', '10'));
|
||||
}
|
||||
|
||||
public function testMd5Filter()
|
||||
public function testMd5Filter(): void
|
||||
{
|
||||
$this->assertSame(md5('grav'), $this->twig_ext->md5Filter('grav'));
|
||||
$this->assertSame(md5('devs@getgrav.org'), $this->twig_ext->md5Filter('devs@getgrav.org'));
|
||||
self::assertSame(md5('grav'), $this->twig_ext->md5Filter('grav'));
|
||||
self::assertSame(md5('devs@getgrav.org'), $this->twig_ext->md5Filter('devs@getgrav.org'));
|
||||
}
|
||||
|
||||
public function testKsortFilter()
|
||||
public function testKsortFilter(): void
|
||||
{
|
||||
$object = array("name"=>"Bob","age"=>8,"colour"=>"red");
|
||||
$this->assertSame(array("age"=>8,"colour"=>"red","name"=>"Bob"), $this->twig_ext->ksortFilter($object));
|
||||
self::assertSame(array("age"=>8,"colour"=>"red","name"=>"Bob"), $this->twig_ext->ksortFilter($object));
|
||||
}
|
||||
|
||||
public function testContainsFilter()
|
||||
public function testContainsFilter(): void
|
||||
{
|
||||
$this->assertTrue($this->twig_ext->containsFilter('grav', 'grav'));
|
||||
$this->assertTrue($this->twig_ext->containsFilter('So, I found this new cms, called grav, and it\'s pretty awesome guys', 'grav'));
|
||||
self::assertTrue($this->twig_ext->containsFilter('grav', 'grav'));
|
||||
self::assertTrue($this->twig_ext->containsFilter('So, I found this new cms, called grav, and it\'s pretty awesome guys', 'grav'));
|
||||
}
|
||||
|
||||
public function testNicetimeFilter()
|
||||
public function testNicetimeFilter(): void
|
||||
{
|
||||
$now = time();
|
||||
$threeMinutes = time() - (60*3);
|
||||
|
|
@ -62,121 +62,121 @@ class TwigExtensionTest extends \Codeception\TestCase\Test
|
|||
$threeYears = time() - (60*60*24*365*3);
|
||||
$measures = ['minutes','hours','days','months','years'];
|
||||
|
||||
$this->assertSame('No date provided', $this->twig_ext->nicetimeFunc(null));
|
||||
self::assertSame('No date provided', $this->twig_ext->nicetimeFunc(null));
|
||||
|
||||
for ($i=0; $i<count($measures); $i++) {
|
||||
$time = 'three' . ucfirst($measures[$i]);
|
||||
$this->assertSame('3 ' . $measures[$i] . ' ago', $this->twig_ext->nicetimeFunc($$time));
|
||||
self::assertSame('3 ' . $measures[$i] . ' ago', $this->twig_ext->nicetimeFunc($$time));
|
||||
}
|
||||
}
|
||||
|
||||
public function testRandomizeFilter()
|
||||
public function testRandomizeFilter(): void
|
||||
{
|
||||
$array = [1,2,3,4,5];
|
||||
$this->assertContains(2, $this->twig_ext->randomizeFilter($array));
|
||||
$this->assertSame($array, $this->twig_ext->randomizeFilter($array, 5));
|
||||
$this->assertSame($array[0], $this->twig_ext->randomizeFilter($array, 1)[0]);
|
||||
$this->assertSame($array[3], $this->twig_ext->randomizeFilter($array, 4)[3]);
|
||||
$this->assertSame($array[1], $this->twig_ext->randomizeFilter($array, 4)[1]);
|
||||
self::assertContains(2, $this->twig_ext->randomizeFilter($array));
|
||||
self::assertSame($array, $this->twig_ext->randomizeFilter($array, 5));
|
||||
self::assertSame($array[0], $this->twig_ext->randomizeFilter($array, 1)[0]);
|
||||
self::assertSame($array[3], $this->twig_ext->randomizeFilter($array, 4)[3]);
|
||||
self::assertSame($array[1], $this->twig_ext->randomizeFilter($array, 4)[1]);
|
||||
}
|
||||
|
||||
public function testModulusFilter()
|
||||
public function testModulusFilter(): void
|
||||
{
|
||||
$this->assertSame(3, $this->twig_ext->modulusFilter(3, 4));
|
||||
$this->assertSame(1, $this->twig_ext->modulusFilter(11, 2));
|
||||
$this->assertSame(0, $this->twig_ext->modulusFilter(10, 2));
|
||||
$this->assertSame(2, $this->twig_ext->modulusFilter(10, 4));
|
||||
self::assertSame(3, $this->twig_ext->modulusFilter(3, 4));
|
||||
self::assertSame(1, $this->twig_ext->modulusFilter(11, 2));
|
||||
self::assertSame(0, $this->twig_ext->modulusFilter(10, 2));
|
||||
self::assertSame(2, $this->twig_ext->modulusFilter(10, 4));
|
||||
}
|
||||
|
||||
public function testAbsoluteUrlFilter()
|
||||
public function testAbsoluteUrlFilter(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testMarkdownFilter()
|
||||
public function testMarkdownFilter(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testStartsWithFilter()
|
||||
public function testStartsWithFilter(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testEndsWithFilter()
|
||||
public function testEndsWithFilter(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testDefinedDefaultFilter()
|
||||
public function testDefinedDefaultFilter(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testRtrimFilter()
|
||||
public function testRtrimFilter(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testLtrimFilter()
|
||||
public function testLtrimFilter(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testRepeatFunc()
|
||||
public function testRepeatFunc(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testRegexReplace()
|
||||
public function testRegexReplace(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testUrlFunc()
|
||||
public function testUrlFunc(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testEvaluateFunc()
|
||||
public function testEvaluateFunc(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testDump()
|
||||
public function testDump(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testGistFunc()
|
||||
public function testGistFunc(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testRandomStringFunc()
|
||||
public function testRandomStringFunc(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testPadFilter()
|
||||
public function testPadFilter(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testArrayFunc()
|
||||
public function testArrayFunc(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
self::assertSame(
|
||||
'this is my text',
|
||||
$this->twig_ext->regexReplace('<p>this is my text</p>', '(<\/?p>)', '')
|
||||
);
|
||||
$this->assertSame(
|
||||
self::assertSame(
|
||||
'<i>this is my text</i>',
|
||||
$this->twig_ext->regexReplace('<p>this is my text</p>', ['(<p>)','(<\/p>)'], ['<i>','</i>'])
|
||||
);
|
||||
}
|
||||
|
||||
public function testArrayKeyValue()
|
||||
public function testArrayKeyValue(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
self::assertSame(
|
||||
['meat' => 'steak'],
|
||||
$this->twig_ext->arrayKeyValueFunc('meat', 'steak')
|
||||
);
|
||||
$this->assertSame(
|
||||
self::assertSame(
|
||||
['fruit' => 'apple', 'meat' => 'steak'],
|
||||
$this->twig_ext->arrayKeyValueFunc('meat', 'steak', ['fruit' => 'apple'])
|
||||
);
|
||||
}
|
||||
|
||||
public function stringFunc()
|
||||
public function stringFunc(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testRangeFunc()
|
||||
public function testRangeFunc(): void
|
||||
{
|
||||
$hundred = [];
|
||||
for ($i = 0; $i <= 100; $i++) {
|
||||
|
|
@ -184,19 +184,19 @@ class TwigExtensionTest extends \Codeception\TestCase\Test
|
|||
}
|
||||
|
||||
|
||||
$this->assertSame([0], $this->twig_ext->rangeFunc(0, 0));
|
||||
$this->assertSame([0, 1, 2], $this->twig_ext->rangeFunc(0, 2));
|
||||
self::assertSame([0], $this->twig_ext->rangeFunc(0, 0));
|
||||
self::assertSame([0, 1, 2], $this->twig_ext->rangeFunc(0, 2));
|
||||
|
||||
$this->assertSame([0, 5, 10, 15], $this->twig_ext->rangeFunc(0, 16, 5));
|
||||
self::assertSame([0, 5, 10, 15], $this->twig_ext->rangeFunc(0, 16, 5));
|
||||
|
||||
// default (min 0, max 100, step 1)
|
||||
$this->assertSame($hundred, $this->twig_ext->rangeFunc());
|
||||
self::assertSame($hundred, $this->twig_ext->rangeFunc());
|
||||
|
||||
// 95 items, starting from 5, (min 5, max 100, step 1)
|
||||
$this->assertSame(array_slice($hundred, 5), $this->twig_ext->rangeFunc(5));
|
||||
self::assertSame(array_slice($hundred, 5), $this->twig_ext->rangeFunc(5));
|
||||
|
||||
// reversed range
|
||||
$this->assertSame(array_reverse($hundred), $this->twig_ext->rangeFunc(100, 0));
|
||||
$this->assertSame([4, 2, 0], $this->twig_ext->rangeFunc(4, 0, 2));
|
||||
self::assertSame(array_reverse($hundred), $this->twig_ext->rangeFunc(100, 0));
|
||||
self::assertSame([4, 2, 0], $this->twig_ext->rangeFunc(4, 0, 2));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -854,18 +854,18 @@ class UriTest extends \Codeception\TestCase\Test
|
|||
],
|
||||
];
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$grav = Fixtures::get('grav');
|
||||
$this->grav = $grav();
|
||||
$this->uri = $this->grav['uri'];
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
protected function _after(): void
|
||||
{
|
||||
}
|
||||
|
||||
protected function runTestSet(array $tests, $method, $params = [])
|
||||
protected function runTestSet(array $tests, $method, $params = []): void
|
||||
{
|
||||
foreach ($tests as $url => $candidates) {
|
||||
if (!array_key_exists($method, $candidates) && $method !== 'toOriginalString') {
|
||||
|
|
@ -875,7 +875,7 @@ class UriTest extends \Codeception\TestCase\Test
|
|||
$nonce = Utils::getNonce('test-action');
|
||||
$expected = str_replace('{{nonce}}', $nonce, $candidates[$method]);
|
||||
|
||||
$this->assertSame($expected, Uri::addNonce($url, 'test-action'));
|
||||
self::assertSame($expected, Uri::addNonce($url, 'test-action'));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
|
@ -893,213 +893,213 @@ class UriTest extends \Codeception\TestCase\Test
|
|||
$result = $this->uri->{$method}();
|
||||
}
|
||||
|
||||
$this->assertSame($expected, $result, "Test \$url->{$method}() for {$url}");
|
||||
self::assertSame($expected, $result, "Test \$url->{$method}() for {$url}");
|
||||
// Deal with $url->query($key)
|
||||
if ($method === 'query') {
|
||||
parse_str($expected, $queryParams);
|
||||
foreach ($queryParams as $key => $value) {
|
||||
$this->assertSame($value, $this->uri->{$method}($key), "Test \$url->{$method}('{$key}') for {$url}");
|
||||
self::assertSame($value, $this->uri->{$method}($key), "Test \$url->{$method}('{$key}') for {$url}");
|
||||
}
|
||||
$this->assertNull($this->uri->{$method}('non-existing'), "Test \$url->{$method}('non-existing') for {$url}");
|
||||
self::assertNull($this->uri->{$method}('non-existing'), "Test \$url->{$method}('non-existing') for {$url}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testValidatingHostname()
|
||||
public function testValidatingHostname(): void
|
||||
{
|
||||
$this->assertTrue($this->uri->validateHostname('localhost'));
|
||||
$this->assertTrue($this->uri->validateHostname('google.com'));
|
||||
$this->assertTrue($this->uri->validateHostname('google.it'));
|
||||
$this->assertTrue($this->uri->validateHostname('goog.le'));
|
||||
$this->assertTrue($this->uri->validateHostname('goog.wine'));
|
||||
$this->assertTrue($this->uri->validateHostname('goog.localhost'));
|
||||
self::assertTrue($this->uri->validateHostname('localhost'));
|
||||
self::assertTrue($this->uri->validateHostname('google.com'));
|
||||
self::assertTrue($this->uri->validateHostname('google.it'));
|
||||
self::assertTrue($this->uri->validateHostname('goog.le'));
|
||||
self::assertTrue($this->uri->validateHostname('goog.wine'));
|
||||
self::assertTrue($this->uri->validateHostname('goog.localhost'));
|
||||
|
||||
$this->assertFalse($this->uri->validateHostname('localhost:80'));
|
||||
$this->assertFalse($this->uri->validateHostname('http://localhost'));
|
||||
$this->assertFalse($this->uri->validateHostname('localhost!'));
|
||||
self::assertFalse($this->uri->validateHostname('localhost:80'));
|
||||
self::assertFalse($this->uri->validateHostname('http://localhost'));
|
||||
self::assertFalse($this->uri->validateHostname('localhost!'));
|
||||
}
|
||||
|
||||
public function testToString()
|
||||
public function testToString(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'toOriginalString');
|
||||
}
|
||||
|
||||
public function testScheme()
|
||||
public function testScheme(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'scheme');
|
||||
}
|
||||
|
||||
public function testUser()
|
||||
public function testUser(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'user');
|
||||
}
|
||||
|
||||
public function testPassword()
|
||||
public function testPassword(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'password');
|
||||
}
|
||||
|
||||
public function testHost()
|
||||
public function testHost(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'host');
|
||||
}
|
||||
|
||||
public function testPort()
|
||||
public function testPort(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'port');
|
||||
}
|
||||
|
||||
public function testPath()
|
||||
public function testPath(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'path');
|
||||
}
|
||||
|
||||
public function testQuery()
|
||||
public function testQuery(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'query');
|
||||
}
|
||||
|
||||
public function testFragment()
|
||||
public function testFragment(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'fragment');
|
||||
|
||||
$this->uri->fragment('something-new');
|
||||
$this->assertSame('something-new', $this->uri->fragment());
|
||||
self::assertSame('something-new', $this->uri->fragment());
|
||||
}
|
||||
|
||||
public function testPaths()
|
||||
public function testPaths(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'paths');
|
||||
}
|
||||
|
||||
public function testRoute()
|
||||
public function testRoute(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'route');
|
||||
}
|
||||
|
||||
public function testParams()
|
||||
public function testParams(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'params');
|
||||
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init();
|
||||
$this->assertSame('/ueper:xxx', $this->uri->params('ueper'));
|
||||
self::assertSame('/ueper:xxx', $this->uri->params('ueper'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init();
|
||||
$this->assertSame('/ueper:xxx', $this->uri->params('ueper'));
|
||||
$this->assertSame('/test:yyy', $this->uri->params('test'));
|
||||
self::assertSame('/ueper:xxx', $this->uri->params('ueper'));
|
||||
self::assertSame('/test:yyy', $this->uri->params('test'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx++/test:yyy')->init();
|
||||
$this->assertSame('/ueper:xxx++/test:yyy', $this->uri->params());
|
||||
$this->assertSame('/ueper:xxx++', $this->uri->params('ueper'));
|
||||
$this->assertSame('/test:yyy', $this->uri->params('test'));
|
||||
self::assertSame('/ueper:xxx++/test:yyy', $this->uri->params());
|
||||
self::assertSame('/ueper:xxx++', $this->uri->params('ueper'));
|
||||
self::assertSame('/test:yyy', $this->uri->params('test'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx++/test:yyy#something')->init();
|
||||
$this->assertSame('/ueper:xxx++/test:yyy', $this->uri->params());
|
||||
$this->assertSame('/ueper:xxx++', $this->uri->params('ueper'));
|
||||
$this->assertSame('/test:yyy', $this->uri->params('test'));
|
||||
self::assertSame('/ueper:xxx++/test:yyy', $this->uri->params());
|
||||
self::assertSame('/ueper:xxx++', $this->uri->params('ueper'));
|
||||
self::assertSame('/test:yyy', $this->uri->params('test'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx++/test:yyy?foo=bar')->init();
|
||||
$this->assertSame('/ueper:xxx++/test:yyy', $this->uri->params());
|
||||
$this->assertSame('/ueper:xxx++', $this->uri->params('ueper'));
|
||||
$this->assertSame('/test:yyy', $this->uri->params('test'));
|
||||
self::assertSame('/ueper:xxx++/test:yyy', $this->uri->params());
|
||||
self::assertSame('/ueper:xxx++', $this->uri->params('ueper'));
|
||||
self::assertSame('/test:yyy', $this->uri->params('test'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x')->init();
|
||||
$this->assertNull($this->uri->params());
|
||||
$this->assertNull($this->uri->params('ueper'));
|
||||
self::assertNull($this->uri->params());
|
||||
self::assertNull($this->uri->params('ueper'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y')->init();
|
||||
$this->assertNull($this->uri->params());
|
||||
$this->assertNull($this->uri->params('ueper'));
|
||||
self::assertNull($this->uri->params());
|
||||
self::assertNull($this->uri->params('ueper'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y')->init();
|
||||
$this->assertNull($this->uri->params());
|
||||
$this->assertNull($this->uri->params('ueper'));
|
||||
self::assertNull($this->uri->params());
|
||||
self::assertNull($this->uri->params('ueper'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper?test=x&test2=y&test3=x&test4=y/test')->init();
|
||||
$this->assertNull($this->uri->params());
|
||||
$this->assertNull($this->uri->params('ueper'));
|
||||
self::assertNull($this->uri->params());
|
||||
self::assertNull($this->uri->params('ueper'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/a/b/c/d')->init();
|
||||
$this->assertNull($this->uri->params());
|
||||
$this->assertNull($this->uri->params('ueper'));
|
||||
self::assertNull($this->uri->params());
|
||||
self::assertNull($this->uri->params('ueper'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f')->init();
|
||||
$this->assertNull($this->uri->params());
|
||||
$this->assertNull($this->uri->params('ueper'));
|
||||
self::assertNull($this->uri->params());
|
||||
self::assertNull($this->uri->params('ueper'));
|
||||
}
|
||||
|
||||
public function testParam()
|
||||
public function testParam(): void
|
||||
{
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx')->init();
|
||||
$this->assertSame('xxx', $this->uri->param('ueper'));
|
||||
self::assertSame('xxx', $this->uri->param('ueper'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx/test:yyy')->init();
|
||||
$this->assertSame('xxx', $this->uri->param('ueper'));
|
||||
$this->assertSame('yyy', $this->uri->param('test'));
|
||||
self::assertSame('xxx', $this->uri->param('ueper'));
|
||||
self::assertSame('yyy', $this->uri->param('test'));
|
||||
$this->uri->initializeWithURL('http://localhost:8080/grav/it/ueper:xxx++/test:yy%20y/foo:bar_baz-bank')->init();
|
||||
$this->assertSame('xxx++', $this->uri->param('ueper'));
|
||||
$this->assertSame('yy y', $this->uri->param('test'));
|
||||
$this->assertSame('bar_baz-bank', $this->uri->param('foo'));
|
||||
self::assertSame('xxx++', $this->uri->param('ueper'));
|
||||
self::assertSame('yy y', $this->uri->param('test'));
|
||||
self::assertSame('bar_baz-bank', $this->uri->param('foo'));
|
||||
}
|
||||
|
||||
public function testUrl()
|
||||
public function testUrl(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'url');
|
||||
}
|
||||
|
||||
public function testExtension()
|
||||
public function testExtension(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'extension');
|
||||
|
||||
$this->uri->initializeWithURL('http://localhost/a-page')->init();
|
||||
$this->assertSame('x', $this->uri->extension('x'));
|
||||
self::assertSame('x', $this->uri->extension('x'));
|
||||
}
|
||||
|
||||
public function testEnvironment()
|
||||
public function testEnvironment(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'environment');
|
||||
}
|
||||
|
||||
public function testBasename()
|
||||
public function testBasename(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'basename');
|
||||
}
|
||||
|
||||
public function testBase()
|
||||
public function testBase(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'base');
|
||||
}
|
||||
|
||||
public function testRootUrl()
|
||||
public function testRootUrl(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'rootUrl', [true]);
|
||||
|
||||
$this->uri->initializeWithUrlAndRootPath('https://localhost/grav/page-foo', '/grav')->init();
|
||||
$this->assertSame('/grav', $this->uri->rootUrl());
|
||||
$this->assertSame('https://localhost/grav', $this->uri->rootUrl(true));
|
||||
self::assertSame('/grav', $this->uri->rootUrl());
|
||||
self::assertSame('https://localhost/grav', $this->uri->rootUrl(true));
|
||||
}
|
||||
|
||||
public function testCurrentPage()
|
||||
public function testCurrentPage(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'currentPage');
|
||||
|
||||
$this->uri->initializeWithURL('http://localhost:8080/a-page/page:2')->init();
|
||||
$this->assertSame(2, $this->uri->currentPage());
|
||||
self::assertSame(2, $this->uri->currentPage());
|
||||
}
|
||||
|
||||
public function testReferrer()
|
||||
public function testReferrer(): void
|
||||
{
|
||||
$this->uri->initializeWithURL('http://localhost/foo/page:test')->init();
|
||||
$this->assertSame('/foo', $this->uri->referrer());
|
||||
self::assertSame('/foo', $this->uri->referrer());
|
||||
$this->uri->initializeWithURL('http://localhost/foo/bar/page:test')->init();
|
||||
$this->assertSame('/foo/bar', $this->uri->referrer());
|
||||
self::assertSame('/foo/bar', $this->uri->referrer());
|
||||
}
|
||||
|
||||
public function testIp()
|
||||
public function testIp(): void
|
||||
{
|
||||
$this->uri->initializeWithURL('http://localhost/foo/page:test')->init();
|
||||
$this->assertSame('UNKNOWN', Uri::ip());
|
||||
self::assertSame('UNKNOWN', Uri::ip());
|
||||
}
|
||||
|
||||
public function testIsExternal()
|
||||
public function testIsExternal(): void
|
||||
{
|
||||
$this->uri->initializeWithURL('http://localhost/')->init();
|
||||
$this->assertFalse(Uri::isExternal('/test'));
|
||||
$this->assertFalse(Uri::isExternal('/foo/bar'));
|
||||
$this->assertTrue(Uri::isExternal('http://localhost/test'));
|
||||
$this->assertTrue(Uri::isExternal('http://google.it/test'));
|
||||
self::assertFalse(Uri::isExternal('/test'));
|
||||
self::assertFalse(Uri::isExternal('/foo/bar'));
|
||||
self::assertTrue(Uri::isExternal('http://localhost/test'));
|
||||
self::assertTrue(Uri::isExternal('http://google.it/test'));
|
||||
}
|
||||
|
||||
public function testBuildUrl()
|
||||
public function testBuildUrl(): void
|
||||
{
|
||||
$parsed_url = [
|
||||
'scheme' => 'http',
|
||||
|
|
@ -1107,7 +1107,7 @@ class UriTest extends \Codeception\TestCase\Test
|
|||
'port' => 8080,
|
||||
];
|
||||
|
||||
$this->assertSame('http://localhost:8080', Uri::buildUrl($parsed_url));
|
||||
self::assertSame('http://localhost:8080', Uri::buildUrl($parsed_url));
|
||||
|
||||
$parsed_url = [
|
||||
'scheme' => 'http',
|
||||
|
|
@ -1120,32 +1120,32 @@ class UriTest extends \Codeception\TestCase\Test
|
|||
'fragment' => 'xxx',
|
||||
];
|
||||
|
||||
$this->assertSame('http://foo:bar@localhost:8080/test?x=2#xxx', Uri::buildUrl($parsed_url));
|
||||
self::assertSame('http://foo:bar@localhost:8080/test?x=2#xxx', Uri::buildUrl($parsed_url));
|
||||
|
||||
/** @var Uri $uri */
|
||||
$uri = Grav::instance()['uri'];
|
||||
|
||||
$uri->initializeWithUrlAndRootPath('https://testing.dev/subdir/path1/path2/file.html', '/subdir')->init();
|
||||
$this->assertSame('https://testing.dev/subdir/path1/path2/file.html', Uri::buildUrl($uri->toArray(true)));
|
||||
self::assertSame('https://testing.dev/subdir/path1/path2/file.html', Uri::buildUrl($uri->toArray(true)));
|
||||
|
||||
$uri->initializeWithUrlAndRootPath('https://testing.dev/subdir/path1/path2/file.foo', '/subdir')->init();
|
||||
$this->assertSame('https://testing.dev/subdir/path1/path2/file.foo', Uri::buildUrl($uri->toArray(true)));
|
||||
self::assertSame('https://testing.dev/subdir/path1/path2/file.foo', Uri::buildUrl($uri->toArray(true)));
|
||||
|
||||
$uri->initializeWithUrlAndRootPath('https://testing.dev/subdir/path1/path2/file.html', '/subdir/path1')->init();
|
||||
$this->assertSame('https://testing.dev/subdir/path1/path2/file.html', Uri::buildUrl($uri->toArray(true)));
|
||||
self::assertSame('https://testing.dev/subdir/path1/path2/file.html', Uri::buildUrl($uri->toArray(true)));
|
||||
|
||||
$uri->initializeWithUrlAndRootPath('https://testing.dev/subdir/path1/path2/file.html/foo:blah/bang:boom', '/subdir')->init();
|
||||
$this->assertSame('https://testing.dev/subdir/path1/path2/file.html/foo:blah/bang:boom', Uri::buildUrl($uri->toArray(true)));
|
||||
self::assertSame('https://testing.dev/subdir/path1/path2/file.html/foo:blah/bang:boom', Uri::buildUrl($uri->toArray(true)));
|
||||
|
||||
$uri->initializeWithUrlAndRootPath('https://testing.dev/subdir/path1/path2/file.html/foo:blah/bang:boom?fig=something', '/subdir')->init();
|
||||
$this->assertSame('https://testing.dev/subdir/path1/path2/file.html/foo:blah/bang:boom?fig=something', Uri::buildUrl($uri->toArray(true)));
|
||||
self::assertSame('https://testing.dev/subdir/path1/path2/file.html/foo:blah/bang:boom?fig=something', Uri::buildUrl($uri->toArray(true)));
|
||||
}
|
||||
|
||||
public function testConvertUrl()
|
||||
public function testConvertUrl(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testAddNonce()
|
||||
public function testAddNonce(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'addNonce');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,113 +16,113 @@ class UtilsTest extends \Codeception\TestCase\Test
|
|||
/** @var Uri $uri */
|
||||
protected $uri;
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$grav = Fixtures::get('grav');
|
||||
$this->grav = $grav();
|
||||
$this->uri = $this->grav['uri'];
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
protected function _after(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testStartsWith()
|
||||
public function testStartsWith(): void
|
||||
{
|
||||
$this->assertTrue(Utils::startsWith('english', 'en'));
|
||||
$this->assertTrue(Utils::startsWith('English', 'En'));
|
||||
$this->assertTrue(Utils::startsWith('ENGLISH', 'EN'));
|
||||
$this->assertTrue(Utils::startsWith(
|
||||
self::assertTrue(Utils::startsWith('english', 'en'));
|
||||
self::assertTrue(Utils::startsWith('English', 'En'));
|
||||
self::assertTrue(Utils::startsWith('ENGLISH', 'EN'));
|
||||
self::assertTrue(Utils::startsWith(
|
||||
'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH',
|
||||
'EN'
|
||||
));
|
||||
|
||||
$this->assertFalse(Utils::startsWith('english', 'En'));
|
||||
$this->assertFalse(Utils::startsWith('English', 'EN'));
|
||||
$this->assertFalse(Utils::startsWith('ENGLISH', 'en'));
|
||||
$this->assertFalse(Utils::startsWith(
|
||||
self::assertFalse(Utils::startsWith('english', 'En'));
|
||||
self::assertFalse(Utils::startsWith('English', 'EN'));
|
||||
self::assertFalse(Utils::startsWith('ENGLISH', 'en'));
|
||||
self::assertFalse(Utils::startsWith(
|
||||
'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH',
|
||||
'e'
|
||||
));
|
||||
|
||||
$this->assertTrue(Utils::startsWith('english', 'En', false));
|
||||
$this->assertTrue(Utils::startsWith('English', 'EN', false));
|
||||
$this->assertTrue(Utils::startsWith('ENGLISH', 'en', false));
|
||||
$this->assertTrue(Utils::startsWith(
|
||||
self::assertTrue(Utils::startsWith('english', 'En', false));
|
||||
self::assertTrue(Utils::startsWith('English', 'EN', false));
|
||||
self::assertTrue(Utils::startsWith('ENGLISH', 'en', false));
|
||||
self::assertTrue(Utils::startsWith(
|
||||
'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH',
|
||||
'e',
|
||||
false
|
||||
));
|
||||
}
|
||||
|
||||
public function testEndsWith()
|
||||
public function testEndsWith(): void
|
||||
{
|
||||
$this->assertTrue(Utils::endsWith('english', 'sh'));
|
||||
$this->assertTrue(Utils::endsWith('EngliSh', 'Sh'));
|
||||
$this->assertTrue(Utils::endsWith('ENGLISH', 'SH'));
|
||||
$this->assertTrue(Utils::endsWith(
|
||||
self::assertTrue(Utils::endsWith('english', 'sh'));
|
||||
self::assertTrue(Utils::endsWith('EngliSh', 'Sh'));
|
||||
self::assertTrue(Utils::endsWith('ENGLISH', 'SH'));
|
||||
self::assertTrue(Utils::endsWith(
|
||||
'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH',
|
||||
'ENGLISH'
|
||||
));
|
||||
|
||||
$this->assertFalse(Utils::endsWith('english', 'de'));
|
||||
$this->assertFalse(Utils::endsWith('EngliSh', 'sh'));
|
||||
$this->assertFalse(Utils::endsWith('ENGLISH', 'Sh'));
|
||||
$this->assertFalse(Utils::endsWith(
|
||||
self::assertFalse(Utils::endsWith('english', 'de'));
|
||||
self::assertFalse(Utils::endsWith('EngliSh', 'sh'));
|
||||
self::assertFalse(Utils::endsWith('ENGLISH', 'Sh'));
|
||||
self::assertFalse(Utils::endsWith(
|
||||
'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH',
|
||||
'DEUSTCH'
|
||||
));
|
||||
|
||||
$this->assertTrue(Utils::endsWith('english', 'SH', false));
|
||||
$this->assertTrue(Utils::endsWith('EngliSh', 'sH', false));
|
||||
$this->assertTrue(Utils::endsWith('ENGLISH', 'sh', false));
|
||||
$this->assertTrue(Utils::endsWith(
|
||||
self::assertTrue(Utils::endsWith('english', 'SH', false));
|
||||
self::assertTrue(Utils::endsWith('EngliSh', 'sH', false));
|
||||
self::assertTrue(Utils::endsWith('ENGLISH', 'sh', false));
|
||||
self::assertTrue(Utils::endsWith(
|
||||
'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH',
|
||||
'english',
|
||||
false
|
||||
));
|
||||
}
|
||||
|
||||
public function testContains()
|
||||
public function testContains(): void
|
||||
{
|
||||
$this->assertTrue(Utils::contains('english', 'nglis'));
|
||||
$this->assertTrue(Utils::contains('EngliSh', 'gliSh'));
|
||||
$this->assertTrue(Utils::contains('ENGLISH', 'ENGLI'));
|
||||
$this->assertTrue(Utils::contains(
|
||||
self::assertTrue(Utils::contains('english', 'nglis'));
|
||||
self::assertTrue(Utils::contains('EngliSh', 'gliSh'));
|
||||
self::assertTrue(Utils::contains('ENGLISH', 'ENGLI'));
|
||||
self::assertTrue(Utils::contains(
|
||||
'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH',
|
||||
'ENGLISH'
|
||||
));
|
||||
|
||||
$this->assertFalse(Utils::contains('EngliSh', 'GLI'));
|
||||
$this->assertFalse(Utils::contains('EngliSh', 'English'));
|
||||
$this->assertFalse(Utils::contains('ENGLISH', 'SCH'));
|
||||
$this->assertFalse(Utils::contains(
|
||||
self::assertFalse(Utils::contains('EngliSh', 'GLI'));
|
||||
self::assertFalse(Utils::contains('EngliSh', 'English'));
|
||||
self::assertFalse(Utils::contains('ENGLISH', 'SCH'));
|
||||
self::assertFalse(Utils::contains(
|
||||
'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH',
|
||||
'DEUSTCH'
|
||||
));
|
||||
|
||||
$this->assertTrue(Utils::contains('EngliSh', 'GLI', false));
|
||||
$this->assertTrue(Utils::contains('EngliSh', 'ENGLISH', false));
|
||||
$this->assertTrue(Utils::contains('ENGLISH', 'ish', false));
|
||||
$this->assertTrue(Utils::contains(
|
||||
self::assertTrue(Utils::contains('EngliSh', 'GLI', false));
|
||||
self::assertTrue(Utils::contains('EngliSh', 'ENGLISH', false));
|
||||
self::assertTrue(Utils::contains('ENGLISH', 'ish', false));
|
||||
self::assertTrue(Utils::contains(
|
||||
'ENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISHENGLISH',
|
||||
'english',
|
||||
false
|
||||
));
|
||||
}
|
||||
|
||||
public function testSubstrToString()
|
||||
public function testSubstrToString(): void
|
||||
{
|
||||
$this->assertEquals('en', Utils::substrToString('english', 'glish'));
|
||||
$this->assertEquals('english', Utils::substrToString('english', 'test'));
|
||||
$this->assertNotEquals('en', Utils::substrToString('english', 'lish'));
|
||||
self::assertEquals('en', Utils::substrToString('english', 'glish'));
|
||||
self::assertEquals('english', Utils::substrToString('english', 'test'));
|
||||
self::assertNotEquals('en', Utils::substrToString('english', 'lish'));
|
||||
|
||||
$this->assertEquals('en', Utils::substrToString('english', 'GLISH', false));
|
||||
$this->assertEquals('english', Utils::substrToString('english', 'TEST', false));
|
||||
$this->assertNotEquals('en', Utils::substrToString('english', 'LISH', false));
|
||||
self::assertEquals('en', Utils::substrToString('english', 'GLISH', false));
|
||||
self::assertEquals('english', Utils::substrToString('english', 'TEST', false));
|
||||
self::assertNotEquals('en', Utils::substrToString('english', 'LISH', false));
|
||||
}
|
||||
|
||||
public function testMergeObjects()
|
||||
public function testMergeObjects(): void
|
||||
{
|
||||
$obj1 = new stdClass();
|
||||
$obj1->test1 = 'x';
|
||||
|
|
@ -131,150 +131,150 @@ class UtilsTest extends \Codeception\TestCase\Test
|
|||
|
||||
$objMerged = Utils::mergeObjects($obj1, $obj2);
|
||||
|
||||
$this->assertObjectHasAttribute('test1', $objMerged);
|
||||
$this->assertObjectHasAttribute('test2', $objMerged);
|
||||
self::assertObjectHasAttribute('test1', $objMerged);
|
||||
self::assertObjectHasAttribute('test2', $objMerged);
|
||||
}
|
||||
|
||||
public function testDateFormats()
|
||||
public function testDateFormats(): void
|
||||
{
|
||||
$dateFormats = Utils::dateFormats();
|
||||
$this->assertIsArray($dateFormats);
|
||||
$this->assertContainsOnly('string', $dateFormats);
|
||||
self::assertIsArray($dateFormats);
|
||||
self::assertContainsOnly('string', $dateFormats);
|
||||
|
||||
$default_format = $this->grav['config']->get('system.pages.dateformat.default');
|
||||
|
||||
if ($default_format !== null) {
|
||||
$this->assertArrayHasKey($default_format, $dateFormats);
|
||||
self::assertArrayHasKey($default_format, $dateFormats);
|
||||
}
|
||||
}
|
||||
|
||||
public function testTruncate()
|
||||
public function testTruncate(): void
|
||||
{
|
||||
$this->assertEquals('engli' . '…', Utils::truncate('english', 5));
|
||||
$this->assertEquals('english', Utils::truncate('english'));
|
||||
$this->assertEquals('This is a string to truncate', Utils::truncate('This is a string to truncate'));
|
||||
$this->assertEquals('Th' . '…', Utils::truncate('This is a string to truncate', 2));
|
||||
$this->assertEquals('engli' . '...', Utils::truncate('english', 5, true, " ", "..."));
|
||||
$this->assertEquals('english', Utils::truncate('english'));
|
||||
$this->assertEquals('This is a string to truncate', Utils::truncate('This is a string to truncate'));
|
||||
$this->assertEquals('This' . '…', Utils::truncate('This is a string to truncate', 3, true));
|
||||
$this->assertEquals('<input' . '…', Utils::truncate('<input type="file" id="file" multiple />', 6, true));
|
||||
self::assertEquals('engli' . '…', Utils::truncate('english', 5));
|
||||
self::assertEquals('english', Utils::truncate('english'));
|
||||
self::assertEquals('This is a string to truncate', Utils::truncate('This is a string to truncate'));
|
||||
self::assertEquals('Th' . '…', Utils::truncate('This is a string to truncate', 2));
|
||||
self::assertEquals('engli' . '...', Utils::truncate('english', 5, true, " ", "..."));
|
||||
self::assertEquals('english', Utils::truncate('english'));
|
||||
self::assertEquals('This is a string to truncate', Utils::truncate('This is a string to truncate'));
|
||||
self::assertEquals('This' . '…', Utils::truncate('This is a string to truncate', 3, true));
|
||||
self::assertEquals('<input' . '…', Utils::truncate('<input type="file" id="file" multiple />', 6, true));
|
||||
}
|
||||
|
||||
public function testSafeTruncate()
|
||||
public function testSafeTruncate(): void
|
||||
{
|
||||
$this->assertEquals('This' . '…', Utils::safeTruncate('This is a string to truncate', 1));
|
||||
$this->assertEquals('This' . '…', Utils::safeTruncate('This is a string to truncate', 4));
|
||||
$this->assertEquals('This is' . '…', Utils::safeTruncate('This is a string to truncate', 5));
|
||||
self::assertEquals('This' . '…', Utils::safeTruncate('This is a string to truncate', 1));
|
||||
self::assertEquals('This' . '…', Utils::safeTruncate('This is a string to truncate', 4));
|
||||
self::assertEquals('This is' . '…', Utils::safeTruncate('This is a string to truncate', 5));
|
||||
}
|
||||
|
||||
public function testTruncateHtml()
|
||||
public function testTruncateHtml(): void
|
||||
{
|
||||
$this->assertEquals('T...', Utils::truncateHtml('This is a string to truncate', 1));
|
||||
$this->assertEquals('This is...', Utils::truncateHtml('This is a string to truncate', 7));
|
||||
$this->assertEquals('<p>T...</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 1));
|
||||
$this->assertEquals('<p>This...</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 4));
|
||||
$this->assertEquals('<p>This is a...</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 10));
|
||||
$this->assertEquals('<p>This is a string to truncate</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 100));
|
||||
$this->assertEquals('<input type="file" id="file" multiple />', Utils::truncateHtml('<input type="file" id="file" multiple />', 6));
|
||||
$this->assertEquals('<ol><li>item 1 <i>so...</i></li></ol>', Utils::truncateHtml('<ol><li>item 1 <i>something</i></li><li>item 2 <strong>bold</strong></li></ol>', 10));
|
||||
$this->assertEquals("<p>This is a string.</p>\n<p>It splits two lines.</p>", Utils::truncateHtml("<p>This is a string.</p>\n<p>It splits two lines.</p>", 100));
|
||||
self::assertEquals('T...', Utils::truncateHtml('This is a string to truncate', 1));
|
||||
self::assertEquals('This is...', Utils::truncateHtml('This is a string to truncate', 7));
|
||||
self::assertEquals('<p>T...</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 1));
|
||||
self::assertEquals('<p>This...</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 4));
|
||||
self::assertEquals('<p>This is a...</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 10));
|
||||
self::assertEquals('<p>This is a string to truncate</p>', Utils::truncateHtml('<p>This is a string to truncate</p>', 100));
|
||||
self::assertEquals('<input type="file" id="file" multiple />', Utils::truncateHtml('<input type="file" id="file" multiple />', 6));
|
||||
self::assertEquals('<ol><li>item 1 <i>so...</i></li></ol>', Utils::truncateHtml('<ol><li>item 1 <i>something</i></li><li>item 2 <strong>bold</strong></li></ol>', 10));
|
||||
self::assertEquals("<p>This is a string.</p>\n<p>It splits two lines.</p>", Utils::truncateHtml("<p>This is a string.</p>\n<p>It splits two lines.</p>", 100));
|
||||
}
|
||||
|
||||
public function testSafeTruncateHtml()
|
||||
public function testSafeTruncateHtml(): void
|
||||
{
|
||||
$this->assertEquals('This...', Utils::safeTruncateHtml('This is a string to truncate', 1));
|
||||
$this->assertEquals('This is a...', Utils::safeTruncateHtml('This is a string to truncate', 3));
|
||||
$this->assertEquals('<p>This...</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 1));
|
||||
$this->assertEquals('<p>This is...</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 2));
|
||||
$this->assertEquals('<p>This is a string to...</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 5));
|
||||
$this->assertEquals('<p>This is a string to truncate</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 20));
|
||||
$this->assertEquals('<input type="file" id="file" multiple />', Utils::safeTruncateHtml('<input type="file" id="file" multiple />', 6));
|
||||
$this->assertEquals('<ol><li>item 1 <i>something</i></li><li>item 2...</li></ol>', Utils::safeTruncateHtml('<ol><li>item 1 <i>something</i></li><li>item 2 <strong>bold</strong></li></ol>', 5));
|
||||
self::assertEquals('This...', Utils::safeTruncateHtml('This is a string to truncate', 1));
|
||||
self::assertEquals('This is a...', Utils::safeTruncateHtml('This is a string to truncate', 3));
|
||||
self::assertEquals('<p>This...</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 1));
|
||||
self::assertEquals('<p>This is...</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 2));
|
||||
self::assertEquals('<p>This is a string to...</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 5));
|
||||
self::assertEquals('<p>This is a string to truncate</p>', Utils::safeTruncateHtml('<p>This is a string to truncate</p>', 20));
|
||||
self::assertEquals('<input type="file" id="file" multiple />', Utils::safeTruncateHtml('<input type="file" id="file" multiple />', 6));
|
||||
self::assertEquals('<ol><li>item 1 <i>something</i></li><li>item 2...</li></ol>', Utils::safeTruncateHtml('<ol><li>item 1 <i>something</i></li><li>item 2 <strong>bold</strong></li></ol>', 5));
|
||||
}
|
||||
|
||||
public function testGenerateRandomString()
|
||||
public function testGenerateRandomString(): void
|
||||
{
|
||||
$this->assertNotEquals(Utils::generateRandomString(), Utils::generateRandomString());
|
||||
$this->assertNotEquals(Utils::generateRandomString(20), Utils::generateRandomString(20));
|
||||
self::assertNotEquals(Utils::generateRandomString(), Utils::generateRandomString());
|
||||
self::assertNotEquals(Utils::generateRandomString(20), Utils::generateRandomString(20));
|
||||
}
|
||||
|
||||
public function download()
|
||||
public function download(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testGetMimeByExtension()
|
||||
public function testGetMimeByExtension(): void
|
||||
{
|
||||
$this->assertEquals('application/octet-stream', Utils::getMimeByExtension(''));
|
||||
$this->assertEquals('text/html', Utils::getMimeByExtension('html'));
|
||||
$this->assertEquals('application/json', Utils::getMimeByExtension('json'));
|
||||
$this->assertEquals('application/atom+xml', Utils::getMimeByExtension('atom'));
|
||||
$this->assertEquals('application/rss+xml', Utils::getMimeByExtension('rss'));
|
||||
$this->assertEquals('image/jpeg', Utils::getMimeByExtension('jpg'));
|
||||
$this->assertEquals('image/png', Utils::getMimeByExtension('png'));
|
||||
$this->assertEquals('text/plain', Utils::getMimeByExtension('txt'));
|
||||
$this->assertEquals('application/msword', Utils::getMimeByExtension('doc'));
|
||||
$this->assertEquals('application/octet-stream', Utils::getMimeByExtension('foo'));
|
||||
$this->assertEquals('foo/bar', Utils::getMimeByExtension('foo', 'foo/bar'));
|
||||
$this->assertEquals('text/html', Utils::getMimeByExtension('foo', 'text/html'));
|
||||
self::assertEquals('application/octet-stream', Utils::getMimeByExtension(''));
|
||||
self::assertEquals('text/html', Utils::getMimeByExtension('html'));
|
||||
self::assertEquals('application/json', Utils::getMimeByExtension('json'));
|
||||
self::assertEquals('application/atom+xml', Utils::getMimeByExtension('atom'));
|
||||
self::assertEquals('application/rss+xml', Utils::getMimeByExtension('rss'));
|
||||
self::assertEquals('image/jpeg', Utils::getMimeByExtension('jpg'));
|
||||
self::assertEquals('image/png', Utils::getMimeByExtension('png'));
|
||||
self::assertEquals('text/plain', Utils::getMimeByExtension('txt'));
|
||||
self::assertEquals('application/msword', Utils::getMimeByExtension('doc'));
|
||||
self::assertEquals('application/octet-stream', Utils::getMimeByExtension('foo'));
|
||||
self::assertEquals('foo/bar', Utils::getMimeByExtension('foo', 'foo/bar'));
|
||||
self::assertEquals('text/html', Utils::getMimeByExtension('foo', 'text/html'));
|
||||
}
|
||||
|
||||
public function testGetExtensionByMime()
|
||||
public function testGetExtensionByMime(): void
|
||||
{
|
||||
$this->assertEquals('html', Utils::getExtensionByMime('*/*'));
|
||||
$this->assertEquals('html', Utils::getExtensionByMime('text/*'));
|
||||
$this->assertEquals('html', Utils::getExtensionByMime('text/html'));
|
||||
$this->assertEquals('json', Utils::getExtensionByMime('application/json'));
|
||||
$this->assertEquals('atom', Utils::getExtensionByMime('application/atom+xml'));
|
||||
$this->assertEquals('rss', Utils::getExtensionByMime('application/rss+xml'));
|
||||
$this->assertEquals('jpg', Utils::getExtensionByMime('image/jpeg'));
|
||||
$this->assertEquals('png', Utils::getExtensionByMime('image/png'));
|
||||
$this->assertEquals('txt', Utils::getExtensionByMime('text/plain'));
|
||||
$this->assertEquals('doc', Utils::getExtensionByMime('application/msword'));
|
||||
$this->assertEquals('html', Utils::getExtensionByMime('foo/bar'));
|
||||
$this->assertEquals('baz', Utils::getExtensionByMime('foo/bar', 'baz'));
|
||||
self::assertEquals('html', Utils::getExtensionByMime('*/*'));
|
||||
self::assertEquals('html', Utils::getExtensionByMime('text/*'));
|
||||
self::assertEquals('html', Utils::getExtensionByMime('text/html'));
|
||||
self::assertEquals('json', Utils::getExtensionByMime('application/json'));
|
||||
self::assertEquals('atom', Utils::getExtensionByMime('application/atom+xml'));
|
||||
self::assertEquals('rss', Utils::getExtensionByMime('application/rss+xml'));
|
||||
self::assertEquals('jpg', Utils::getExtensionByMime('image/jpeg'));
|
||||
self::assertEquals('png', Utils::getExtensionByMime('image/png'));
|
||||
self::assertEquals('txt', Utils::getExtensionByMime('text/plain'));
|
||||
self::assertEquals('doc', Utils::getExtensionByMime('application/msword'));
|
||||
self::assertEquals('html', Utils::getExtensionByMime('foo/bar'));
|
||||
self::assertEquals('baz', Utils::getExtensionByMime('foo/bar', 'baz'));
|
||||
}
|
||||
|
||||
public function testNormalizePath()
|
||||
public function testNormalizePath(): void
|
||||
{
|
||||
$this->assertEquals('/test', Utils::normalizePath('/test'));
|
||||
$this->assertEquals('test', Utils::normalizePath('test'));
|
||||
$this->assertEquals('test', Utils::normalizePath('../test'));
|
||||
$this->assertEquals('/test', Utils::normalizePath('/../test'));
|
||||
$this->assertEquals('/test2', Utils::normalizePath('/test/../test2'));
|
||||
$this->assertEquals('/test3', Utils::normalizePath('/test/../test2/../test3'));
|
||||
self::assertEquals('/test', Utils::normalizePath('/test'));
|
||||
self::assertEquals('test', Utils::normalizePath('test'));
|
||||
self::assertEquals('test', Utils::normalizePath('../test'));
|
||||
self::assertEquals('/test', Utils::normalizePath('/../test'));
|
||||
self::assertEquals('/test2', Utils::normalizePath('/test/../test2'));
|
||||
self::assertEquals('/test3', Utils::normalizePath('/test/../test2/../test3'));
|
||||
|
||||
$this->assertEquals('//cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css', Utils::normalizePath('//cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css'));
|
||||
$this->assertEquals('//use.fontawesome.com/releases/v5.8.1/css/all.css', Utils::normalizePath('//use.fontawesome.com/releases/v5.8.1/css/all.css'));
|
||||
$this->assertEquals('//use.fontawesome.com/releases/v5.8.1/webfonts/fa-brands-400.eot', Utils::normalizePath('//use.fontawesome.com/releases/v5.8.1/css/../webfonts/fa-brands-400.eot'));
|
||||
self::assertEquals('//cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css', Utils::normalizePath('//cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css'));
|
||||
self::assertEquals('//use.fontawesome.com/releases/v5.8.1/css/all.css', Utils::normalizePath('//use.fontawesome.com/releases/v5.8.1/css/all.css'));
|
||||
self::assertEquals('//use.fontawesome.com/releases/v5.8.1/webfonts/fa-brands-400.eot', Utils::normalizePath('//use.fontawesome.com/releases/v5.8.1/css/../webfonts/fa-brands-400.eot'));
|
||||
|
||||
$this->assertEquals('http://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css', Utils::normalizePath('http://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css'));
|
||||
$this->assertEquals('http://use.fontawesome.com/releases/v5.8.1/css/all.css', Utils::normalizePath('http://use.fontawesome.com/releases/v5.8.1/css/all.css'));
|
||||
$this->assertEquals('http://use.fontawesome.com/releases/v5.8.1/webfonts/fa-brands-400.eot', Utils::normalizePath('http://use.fontawesome.com/releases/v5.8.1/css/../webfonts/fa-brands-400.eot'));
|
||||
self::assertEquals('http://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css', Utils::normalizePath('http://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css'));
|
||||
self::assertEquals('http://use.fontawesome.com/releases/v5.8.1/css/all.css', Utils::normalizePath('http://use.fontawesome.com/releases/v5.8.1/css/all.css'));
|
||||
self::assertEquals('http://use.fontawesome.com/releases/v5.8.1/webfonts/fa-brands-400.eot', Utils::normalizePath('http://use.fontawesome.com/releases/v5.8.1/css/../webfonts/fa-brands-400.eot'));
|
||||
|
||||
$this->assertEquals('https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css', Utils::normalizePath('https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css'));
|
||||
$this->assertEquals('https://use.fontawesome.com/releases/v5.8.1/css/all.css', Utils::normalizePath('https://use.fontawesome.com/releases/v5.8.1/css/all.css'));
|
||||
$this->assertEquals('https://use.fontawesome.com/releases/v5.8.1/webfonts/fa-brands-400.eot', Utils::normalizePath('https://use.fontawesome.com/releases/v5.8.1/css/../webfonts/fa-brands-400.eot'));
|
||||
self::assertEquals('https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css', Utils::normalizePath('https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css'));
|
||||
self::assertEquals('https://use.fontawesome.com/releases/v5.8.1/css/all.css', Utils::normalizePath('https://use.fontawesome.com/releases/v5.8.1/css/all.css'));
|
||||
self::assertEquals('https://use.fontawesome.com/releases/v5.8.1/webfonts/fa-brands-400.eot', Utils::normalizePath('https://use.fontawesome.com/releases/v5.8.1/css/../webfonts/fa-brands-400.eot'));
|
||||
}
|
||||
|
||||
public function testIsFunctionDisabled()
|
||||
public function testIsFunctionDisabled(): void
|
||||
{
|
||||
$disabledFunctions = explode(',', ini_get('disable_functions'));
|
||||
|
||||
if ($disabledFunctions[0]) {
|
||||
$this->assertEquals(Utils::isFunctionDisabled($disabledFunctions[0]), true);
|
||||
self::assertEquals(Utils::isFunctionDisabled($disabledFunctions[0]), true);
|
||||
}
|
||||
}
|
||||
|
||||
public function testTimezones()
|
||||
public function testTimezones(): void
|
||||
{
|
||||
$timezones = Utils::timezones();
|
||||
|
||||
$this->assertIsArray($timezones);
|
||||
$this->assertContainsOnly('string', $timezones);
|
||||
self::assertIsArray($timezones);
|
||||
self::assertContainsOnly('string', $timezones);
|
||||
}
|
||||
|
||||
public function testArrayFilterRecursive()
|
||||
public function testArrayFilterRecursive(): void
|
||||
{
|
||||
$array = [
|
||||
'test' => '',
|
||||
|
|
@ -285,13 +285,13 @@ class UtilsTest extends \Codeception\TestCase\Test
|
|||
return !(is_null($v) || $v === '');
|
||||
});
|
||||
|
||||
$this->assertContainsOnly('string', $array);
|
||||
$this->assertArrayNotHasKey('test', $array);
|
||||
$this->assertArrayHasKey('test2', $array);
|
||||
$this->assertEquals('test2', $array['test2']);
|
||||
self::assertContainsOnly('string', $array);
|
||||
self::assertArrayNotHasKey('test', $array);
|
||||
self::assertArrayHasKey('test2', $array);
|
||||
self::assertEquals('test2', $array['test2']);
|
||||
}
|
||||
|
||||
public function testPathPrefixedByLangCode()
|
||||
public function testPathPrefixedByLangCode(): void
|
||||
{
|
||||
$languagesEnabled = $this->grav['config']->get('system.languages.supported', []);
|
||||
$arrayOfLanguages = ['en', 'de', 'it', 'es', 'dk', 'el'];
|
||||
|
|
@ -299,24 +299,24 @@ class UtilsTest extends \Codeception\TestCase\Test
|
|||
$oneLanguageNotEnabled = reset($languagesNotEnabled);
|
||||
|
||||
if (count($languagesEnabled)) {
|
||||
$this->assertTrue(Utils::pathPrefixedByLangCode('/' . $languagesEnabled[0] . '/test'));
|
||||
self::assertTrue(Utils::pathPrefixedByLangCode('/' . $languagesEnabled[0] . '/test'));
|
||||
}
|
||||
|
||||
$this->assertFalse(Utils::pathPrefixedByLangCode('/' . $oneLanguageNotEnabled . '/test'));
|
||||
$this->assertFalse(Utils::pathPrefixedByLangCode('/test'));
|
||||
$this->assertFalse(Utils::pathPrefixedByLangCode('/xx'));
|
||||
$this->assertFalse(Utils::pathPrefixedByLangCode('/xx/'));
|
||||
$this->assertFalse(Utils::pathPrefixedByLangCode('/'));
|
||||
self::assertFalse(Utils::pathPrefixedByLangCode('/' . $oneLanguageNotEnabled . '/test'));
|
||||
self::assertFalse(Utils::pathPrefixedByLangCode('/test'));
|
||||
self::assertFalse(Utils::pathPrefixedByLangCode('/xx'));
|
||||
self::assertFalse(Utils::pathPrefixedByLangCode('/xx/'));
|
||||
self::assertFalse(Utils::pathPrefixedByLangCode('/'));
|
||||
}
|
||||
|
||||
public function testDate2timestamp()
|
||||
public function testDate2timestamp(): void
|
||||
{
|
||||
$timestamp = strtotime('10 September 2000');
|
||||
$this->assertSame($timestamp, Utils::date2timestamp('10 September 2000'));
|
||||
$this->assertSame($timestamp, Utils::date2timestamp('2000-09-10 00:00:00'));
|
||||
self::assertSame($timestamp, Utils::date2timestamp('10 September 2000'));
|
||||
self::assertSame($timestamp, Utils::date2timestamp('2000-09-10 00:00:00'));
|
||||
}
|
||||
|
||||
public function testResolve()
|
||||
public function testResolve(): void
|
||||
{
|
||||
$array = [
|
||||
'test' => [
|
||||
|
|
@ -324,10 +324,10 @@ class UtilsTest extends \Codeception\TestCase\Test
|
|||
]
|
||||
];
|
||||
|
||||
$this->assertEquals('test2Value', Utils::resolve($array, 'test.test2'));
|
||||
self::assertEquals('test2Value', Utils::resolve($array, 'test.test2'));
|
||||
}
|
||||
|
||||
public function testGetDotNotation()
|
||||
public function testGetDotNotation(): void
|
||||
{
|
||||
$array = [
|
||||
'test' => [
|
||||
|
|
@ -338,12 +338,12 @@ class UtilsTest extends \Codeception\TestCase\Test
|
|||
]
|
||||
];
|
||||
|
||||
$this->assertEquals('test2Value', Utils::getDotNotation($array, 'test.test2'));
|
||||
$this->assertEquals('test4Value', Utils::getDotNotation($array, 'test.test3.test4'));
|
||||
$this->assertEquals('defaultValue', Utils::getDotNotation($array, 'test.non_existent', 'defaultValue'));
|
||||
self::assertEquals('test2Value', Utils::getDotNotation($array, 'test.test2'));
|
||||
self::assertEquals('test4Value', Utils::getDotNotation($array, 'test.test3.test4'));
|
||||
self::assertEquals('defaultValue', Utils::getDotNotation($array, 'test.non_existent', 'defaultValue'));
|
||||
}
|
||||
|
||||
public function testSetDotNotation()
|
||||
public function testSetDotNotation(): void
|
||||
{
|
||||
$array = [
|
||||
'test' => [
|
||||
|
|
@ -359,201 +359,201 @@ class UtilsTest extends \Codeception\TestCase\Test
|
|||
];
|
||||
|
||||
Utils::setDotNotation($array, 'test.test3.test4', $new);
|
||||
$this->assertEquals('test1Value', $array['test']['test3']['test4']['test1']);
|
||||
self::assertEquals('test1Value', $array['test']['test3']['test4']['test1']);
|
||||
}
|
||||
|
||||
public function testIsPositive()
|
||||
public function testIsPositive(): void
|
||||
{
|
||||
$this->assertTrue(Utils::isPositive(true));
|
||||
$this->assertTrue(Utils::isPositive(1));
|
||||
$this->assertTrue(Utils::isPositive('1'));
|
||||
$this->assertTrue(Utils::isPositive('yes'));
|
||||
$this->assertTrue(Utils::isPositive('on'));
|
||||
$this->assertTrue(Utils::isPositive('true'));
|
||||
$this->assertFalse(Utils::isPositive(false));
|
||||
$this->assertFalse(Utils::isPositive(0));
|
||||
$this->assertFalse(Utils::isPositive('0'));
|
||||
$this->assertFalse(Utils::isPositive('no'));
|
||||
$this->assertFalse(Utils::isPositive('off'));
|
||||
$this->assertFalse(Utils::isPositive('false'));
|
||||
$this->assertFalse(Utils::isPositive('some'));
|
||||
$this->assertFalse(Utils::isPositive(2));
|
||||
self::assertTrue(Utils::isPositive(true));
|
||||
self::assertTrue(Utils::isPositive(1));
|
||||
self::assertTrue(Utils::isPositive('1'));
|
||||
self::assertTrue(Utils::isPositive('yes'));
|
||||
self::assertTrue(Utils::isPositive('on'));
|
||||
self::assertTrue(Utils::isPositive('true'));
|
||||
self::assertFalse(Utils::isPositive(false));
|
||||
self::assertFalse(Utils::isPositive(0));
|
||||
self::assertFalse(Utils::isPositive('0'));
|
||||
self::assertFalse(Utils::isPositive('no'));
|
||||
self::assertFalse(Utils::isPositive('off'));
|
||||
self::assertFalse(Utils::isPositive('false'));
|
||||
self::assertFalse(Utils::isPositive('some'));
|
||||
self::assertFalse(Utils::isPositive(2));
|
||||
}
|
||||
|
||||
public function testGetNonce()
|
||||
public function testGetNonce(): void
|
||||
{
|
||||
$this->assertIsString(Utils::getNonce('test-action'));
|
||||
$this->assertIsString(Utils::getNonce('test-action', true));
|
||||
$this->assertSame(Utils::getNonce('test-action'), Utils::getNonce('test-action'));
|
||||
$this->assertNotSame(Utils::getNonce('test-action'), Utils::getNonce('test-action2'));
|
||||
self::assertIsString(Utils::getNonce('test-action'));
|
||||
self::assertIsString(Utils::getNonce('test-action', true));
|
||||
self::assertSame(Utils::getNonce('test-action'), Utils::getNonce('test-action'));
|
||||
self::assertNotSame(Utils::getNonce('test-action'), Utils::getNonce('test-action2'));
|
||||
}
|
||||
|
||||
public function testVerifyNonce()
|
||||
public function testVerifyNonce(): void
|
||||
{
|
||||
$this->assertTrue(Utils::verifyNonce(Utils::getNonce('test-action'), 'test-action'));
|
||||
self::assertTrue(Utils::verifyNonce(Utils::getNonce('test-action'), 'test-action'));
|
||||
}
|
||||
|
||||
public function testUrl()
|
||||
public function testUrl(): void
|
||||
{
|
||||
$this->uri->initializeWithUrl('http://testing.dev/path1/path2')->init();
|
||||
|
||||
// Fail hard
|
||||
$this->assertSame(false, Utils::url('', true));
|
||||
$this->assertSame(false, Utils::url(''));
|
||||
$this->assertSame(false, Utils::url(new stdClass()));
|
||||
$this->assertSame(false, Utils::url(['foo','bar','baz']));
|
||||
$this->assertSame(false, Utils::url('user://does/not/exist'));
|
||||
self::assertSame(false, Utils::url('', true));
|
||||
self::assertSame(false, Utils::url(''));
|
||||
self::assertSame(false, Utils::url(new stdClass()));
|
||||
self::assertSame(false, Utils::url(['foo','bar','baz']));
|
||||
self::assertSame(false, Utils::url('user://does/not/exist'));
|
||||
|
||||
// Fail Gracefully
|
||||
$this->assertSame('/', Utils::url('/', false, true));
|
||||
$this->assertSame('/', Utils::url('', false, true));
|
||||
$this->assertSame('/', Utils::url(new stdClass(), false, true));
|
||||
$this->assertSame('/', Utils::url(['foo','bar','baz'], false, true));
|
||||
$this->assertSame('/user/does/not/exist', Utils::url('user://does/not/exist', false, true));
|
||||
self::assertSame('/', Utils::url('/', false, true));
|
||||
self::assertSame('/', Utils::url('', false, true));
|
||||
self::assertSame('/', Utils::url(new stdClass(), false, true));
|
||||
self::assertSame('/', Utils::url(['foo','bar','baz'], false, true));
|
||||
self::assertSame('/user/does/not/exist', Utils::url('user://does/not/exist', false, true));
|
||||
|
||||
// Simple paths
|
||||
$this->assertSame('/', Utils::url('/'));
|
||||
$this->assertSame('/path1', Utils::url('/path1'));
|
||||
$this->assertSame('/path1/path2', Utils::url('/path1/path2'));
|
||||
$this->assertSame('/random/path1/path2', Utils::url('/random/path1/path2'));
|
||||
$this->assertSame('/foobar.jpg', Utils::url('/foobar.jpg'));
|
||||
$this->assertSame('/path1/foobar.jpg', Utils::url('/path1/foobar.jpg'));
|
||||
$this->assertSame('/path1/path2/foobar.jpg', Utils::url('/path1/path2/foobar.jpg'));
|
||||
$this->assertSame('/random/path1/path2/foobar.jpg', Utils::url('/random/path1/path2/foobar.jpg'));
|
||||
self::assertSame('/', Utils::url('/'));
|
||||
self::assertSame('/path1', Utils::url('/path1'));
|
||||
self::assertSame('/path1/path2', Utils::url('/path1/path2'));
|
||||
self::assertSame('/random/path1/path2', Utils::url('/random/path1/path2'));
|
||||
self::assertSame('/foobar.jpg', Utils::url('/foobar.jpg'));
|
||||
self::assertSame('/path1/foobar.jpg', Utils::url('/path1/foobar.jpg'));
|
||||
self::assertSame('/path1/path2/foobar.jpg', Utils::url('/path1/path2/foobar.jpg'));
|
||||
self::assertSame('/random/path1/path2/foobar.jpg', Utils::url('/random/path1/path2/foobar.jpg'));
|
||||
|
||||
// Simple paths with domain
|
||||
$this->assertSame('http://testing.dev/', Utils::url('/', true));
|
||||
$this->assertSame('http://testing.dev/path1', Utils::url('/path1', true));
|
||||
$this->assertSame('http://testing.dev/path1/path2', Utils::url('/path1/path2', true));
|
||||
$this->assertSame('http://testing.dev/random/path1/path2', Utils::url('/random/path1/path2', true));
|
||||
$this->assertSame('http://testing.dev/foobar.jpg', Utils::url('/foobar.jpg', true));
|
||||
$this->assertSame('http://testing.dev/path1/foobar.jpg', Utils::url('/path1/foobar.jpg', true));
|
||||
$this->assertSame('http://testing.dev/path1/path2/foobar.jpg', Utils::url('/path1/path2/foobar.jpg', true));
|
||||
$this->assertSame('http://testing.dev/random/path1/path2/foobar.jpg', Utils::url('/random/path1/path2/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/', Utils::url('/', true));
|
||||
self::assertSame('http://testing.dev/path1', Utils::url('/path1', true));
|
||||
self::assertSame('http://testing.dev/path1/path2', Utils::url('/path1/path2', true));
|
||||
self::assertSame('http://testing.dev/random/path1/path2', Utils::url('/random/path1/path2', true));
|
||||
self::assertSame('http://testing.dev/foobar.jpg', Utils::url('/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/path1/foobar.jpg', Utils::url('/path1/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/path1/path2/foobar.jpg', Utils::url('/path1/path2/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/random/path1/path2/foobar.jpg', Utils::url('/random/path1/path2/foobar.jpg', true));
|
||||
|
||||
// Relative paths from Grav root.
|
||||
$this->assertSame('/subdir', Utils::url('subdir'));
|
||||
$this->assertSame('/subdir/path1', Utils::url('subdir/path1'));
|
||||
$this->assertSame('/subdir/path1/path2', Utils::url('subdir/path1/path2'));
|
||||
$this->assertSame('/path1', Utils::url('path1'));
|
||||
$this->assertSame('/path1/path2', Utils::url('path1/path2'));
|
||||
$this->assertSame('/foobar.jpg', Utils::url('foobar.jpg'));
|
||||
$this->assertSame('http://testing.dev/foobar.jpg', Utils::url('foobar.jpg', true));
|
||||
self::assertSame('/subdir', Utils::url('subdir'));
|
||||
self::assertSame('/subdir/path1', Utils::url('subdir/path1'));
|
||||
self::assertSame('/subdir/path1/path2', Utils::url('subdir/path1/path2'));
|
||||
self::assertSame('/path1', Utils::url('path1'));
|
||||
self::assertSame('/path1/path2', Utils::url('path1/path2'));
|
||||
self::assertSame('/foobar.jpg', Utils::url('foobar.jpg'));
|
||||
self::assertSame('http://testing.dev/foobar.jpg', Utils::url('foobar.jpg', true));
|
||||
|
||||
// Relative paths from Grav root with domain.
|
||||
$this->assertSame('http://testing.dev/foobar.jpg', Utils::url('foobar.jpg', true));
|
||||
$this->assertSame('http://testing.dev/foobar.jpg', Utils::url('/foobar.jpg', true));
|
||||
$this->assertSame('http://testing.dev/path1/foobar.jpg', Utils::url('/path1/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/foobar.jpg', Utils::url('foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/foobar.jpg', Utils::url('/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/path1/foobar.jpg', Utils::url('/path1/foobar.jpg', true));
|
||||
|
||||
// All Non-existing streams should be treated as external URI / protocol.
|
||||
$this->assertSame('http://domain.com/path', Utils::url('http://domain.com/path'));
|
||||
$this->assertSame('ftp://domain.com/path', Utils::url('ftp://domain.com/path'));
|
||||
$this->assertSame('sftp://domain.com/path', Utils::url('sftp://domain.com/path'));
|
||||
$this->assertSame('ssh://domain.com', Utils::url('ssh://domain.com'));
|
||||
$this->assertSame('pop://domain.com', Utils::url('pop://domain.com'));
|
||||
$this->assertSame('foo://bar/baz', Utils::url('foo://bar/baz'));
|
||||
$this->assertSame('foo://bar/baz', Utils::url('foo://bar/baz', true));
|
||||
// $this->assertSame('mailto:joe@domain.com', Utils::url('mailto:joe@domain.com', true)); // FIXME <-
|
||||
self::assertSame('http://domain.com/path', Utils::url('http://domain.com/path'));
|
||||
self::assertSame('ftp://domain.com/path', Utils::url('ftp://domain.com/path'));
|
||||
self::assertSame('sftp://domain.com/path', Utils::url('sftp://domain.com/path'));
|
||||
self::assertSame('ssh://domain.com', Utils::url('ssh://domain.com'));
|
||||
self::assertSame('pop://domain.com', Utils::url('pop://domain.com'));
|
||||
self::assertSame('foo://bar/baz', Utils::url('foo://bar/baz'));
|
||||
self::assertSame('foo://bar/baz', Utils::url('foo://bar/baz', true));
|
||||
// self::assertSame('mailto:joe@domain.com', Utils::url('mailto:joe@domain.com', true)); // FIXME <-
|
||||
}
|
||||
|
||||
public function testUrlWithRoot()
|
||||
public function testUrlWithRoot(): void
|
||||
{
|
||||
$this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/path1/path2', '/subdir')->init();
|
||||
|
||||
// Fail hard
|
||||
$this->assertSame(false, Utils::url('', true));
|
||||
$this->assertSame(false, Utils::url(''));
|
||||
$this->assertSame(false, Utils::url(new stdClass()));
|
||||
$this->assertSame(false, Utils::url(['foo','bar','baz']));
|
||||
$this->assertSame(false, Utils::url('user://does/not/exist'));
|
||||
self::assertSame(false, Utils::url('', true));
|
||||
self::assertSame(false, Utils::url(''));
|
||||
self::assertSame(false, Utils::url(new stdClass()));
|
||||
self::assertSame(false, Utils::url(['foo','bar','baz']));
|
||||
self::assertSame(false, Utils::url('user://does/not/exist'));
|
||||
|
||||
// Fail Gracefully
|
||||
$this->assertSame('/subdir/', Utils::url('/', false, true));
|
||||
$this->assertSame('/subdir/', Utils::url('', false, true));
|
||||
$this->assertSame('/subdir/', Utils::url(new stdClass(), false, true));
|
||||
$this->assertSame('/subdir/', Utils::url(['foo','bar','baz'], false, true));
|
||||
$this->assertSame('/subdir/user/does/not/exist', Utils::url('user://does/not/exist', false, true));
|
||||
self::assertSame('/subdir/', Utils::url('/', false, true));
|
||||
self::assertSame('/subdir/', Utils::url('', false, true));
|
||||
self::assertSame('/subdir/', Utils::url(new stdClass(), false, true));
|
||||
self::assertSame('/subdir/', Utils::url(['foo','bar','baz'], false, true));
|
||||
self::assertSame('/subdir/user/does/not/exist', Utils::url('user://does/not/exist', false, true));
|
||||
|
||||
// Simple paths
|
||||
$this->assertSame('/subdir/', Utils::url('/'));
|
||||
$this->assertSame('/subdir/path1', Utils::url('/path1'));
|
||||
$this->assertSame('/subdir/path1/path2', Utils::url('/path1/path2'));
|
||||
$this->assertSame('/subdir/random/path1/path2', Utils::url('/random/path1/path2'));
|
||||
$this->assertSame('/subdir/foobar.jpg', Utils::url('/foobar.jpg'));
|
||||
$this->assertSame('/subdir/path1/foobar.jpg', Utils::url('/path1/foobar.jpg'));
|
||||
$this->assertSame('/subdir/path1/path2/foobar.jpg', Utils::url('/path1/path2/foobar.jpg'));
|
||||
$this->assertSame('/subdir/random/path1/path2/foobar.jpg', Utils::url('/random/path1/path2/foobar.jpg'));
|
||||
self::assertSame('/subdir/', Utils::url('/'));
|
||||
self::assertSame('/subdir/path1', Utils::url('/path1'));
|
||||
self::assertSame('/subdir/path1/path2', Utils::url('/path1/path2'));
|
||||
self::assertSame('/subdir/random/path1/path2', Utils::url('/random/path1/path2'));
|
||||
self::assertSame('/subdir/foobar.jpg', Utils::url('/foobar.jpg'));
|
||||
self::assertSame('/subdir/path1/foobar.jpg', Utils::url('/path1/foobar.jpg'));
|
||||
self::assertSame('/subdir/path1/path2/foobar.jpg', Utils::url('/path1/path2/foobar.jpg'));
|
||||
self::assertSame('/subdir/random/path1/path2/foobar.jpg', Utils::url('/random/path1/path2/foobar.jpg'));
|
||||
|
||||
// Simple paths with domain
|
||||
$this->assertSame('http://testing.dev/subdir/', Utils::url('/', true));
|
||||
$this->assertSame('http://testing.dev/subdir/path1', Utils::url('/path1', true));
|
||||
$this->assertSame('http://testing.dev/subdir/path1/path2', Utils::url('/path1/path2', true));
|
||||
$this->assertSame('http://testing.dev/subdir/random/path1/path2', Utils::url('/random/path1/path2', true));
|
||||
$this->assertSame('http://testing.dev/subdir/foobar.jpg', Utils::url('/foobar.jpg', true));
|
||||
$this->assertSame('http://testing.dev/subdir/path1/foobar.jpg', Utils::url('/path1/foobar.jpg', true));
|
||||
$this->assertSame('http://testing.dev/subdir/path1/path2/foobar.jpg', Utils::url('/path1/path2/foobar.jpg', true));
|
||||
$this->assertSame('http://testing.dev/subdir/random/path1/path2/foobar.jpg', Utils::url('/random/path1/path2/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/subdir/', Utils::url('/', true));
|
||||
self::assertSame('http://testing.dev/subdir/path1', Utils::url('/path1', true));
|
||||
self::assertSame('http://testing.dev/subdir/path1/path2', Utils::url('/path1/path2', true));
|
||||
self::assertSame('http://testing.dev/subdir/random/path1/path2', Utils::url('/random/path1/path2', true));
|
||||
self::assertSame('http://testing.dev/subdir/foobar.jpg', Utils::url('/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/subdir/path1/foobar.jpg', Utils::url('/path1/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/subdir/path1/path2/foobar.jpg', Utils::url('/path1/path2/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/subdir/random/path1/path2/foobar.jpg', Utils::url('/random/path1/path2/foobar.jpg', true));
|
||||
|
||||
// Paths including the grav base.
|
||||
$this->assertSame('/subdir/', Utils::url('/subdir'));
|
||||
$this->assertSame('/subdir/path1', Utils::url('/subdir/path1'));
|
||||
$this->assertSame('/subdir/path1/path2', Utils::url('/subdir/path1/path2'));
|
||||
$this->assertSame('/subdir/foobar.jpg', Utils::url('/subdir/foobar.jpg'));
|
||||
$this->assertSame('/subdir/path1/foobar.jpg', Utils::url('/subdir/path1/foobar.jpg'));
|
||||
self::assertSame('/subdir/', Utils::url('/subdir'));
|
||||
self::assertSame('/subdir/path1', Utils::url('/subdir/path1'));
|
||||
self::assertSame('/subdir/path1/path2', Utils::url('/subdir/path1/path2'));
|
||||
self::assertSame('/subdir/foobar.jpg', Utils::url('/subdir/foobar.jpg'));
|
||||
self::assertSame('/subdir/path1/foobar.jpg', Utils::url('/subdir/path1/foobar.jpg'));
|
||||
|
||||
// Relative paths from Grav root with domain.
|
||||
$this->assertSame('http://testing.dev/subdir/', Utils::url('/subdir', true));
|
||||
$this->assertSame('http://testing.dev/subdir/path1', Utils::url('/subdir/path1', true));
|
||||
$this->assertSame('http://testing.dev/subdir/path1/path2', Utils::url('/subdir/path1/path2', true));
|
||||
$this->assertSame('http://testing.dev/subdir/foobar.jpg', Utils::url('/subdir/foobar.jpg', true));
|
||||
$this->assertSame('http://testing.dev/subdir/path1/foobar.jpg', Utils::url('/subdir/path1/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/subdir/', Utils::url('/subdir', true));
|
||||
self::assertSame('http://testing.dev/subdir/path1', Utils::url('/subdir/path1', true));
|
||||
self::assertSame('http://testing.dev/subdir/path1/path2', Utils::url('/subdir/path1/path2', true));
|
||||
self::assertSame('http://testing.dev/subdir/foobar.jpg', Utils::url('/subdir/foobar.jpg', true));
|
||||
self::assertSame('http://testing.dev/subdir/path1/foobar.jpg', Utils::url('/subdir/path1/foobar.jpg', true));
|
||||
|
||||
// Relative paths from Grav root.
|
||||
$this->assertSame('/subdir/subdir', Utils::url('subdir'));
|
||||
$this->assertSame('/subdir/subdir/path1', Utils::url('subdir/path1'));
|
||||
$this->assertSame('/subdir/subdir/path1/path2', Utils::url('subdir/path1/path2'));
|
||||
$this->assertSame('/subdir/path1', Utils::url('path1'));
|
||||
$this->assertSame('/subdir/path1/path2', Utils::url('path1/path2'));
|
||||
$this->assertSame('/subdir/foobar.jpg', Utils::url('foobar.jpg'));
|
||||
$this->assertSame('http://testing.dev/subdir/foobar.jpg', Utils::url('foobar.jpg', true));
|
||||
self::assertSame('/subdir/subdir', Utils::url('subdir'));
|
||||
self::assertSame('/subdir/subdir/path1', Utils::url('subdir/path1'));
|
||||
self::assertSame('/subdir/subdir/path1/path2', Utils::url('subdir/path1/path2'));
|
||||
self::assertSame('/subdir/path1', Utils::url('path1'));
|
||||
self::assertSame('/subdir/path1/path2', Utils::url('path1/path2'));
|
||||
self::assertSame('/subdir/foobar.jpg', Utils::url('foobar.jpg'));
|
||||
self::assertSame('http://testing.dev/subdir/foobar.jpg', Utils::url('foobar.jpg', true));
|
||||
|
||||
// All Non-existing streams should be treated as external URI / protocol.
|
||||
$this->assertSame('http://domain.com/path', Utils::url('http://domain.com/path'));
|
||||
$this->assertSame('ftp://domain.com/path', Utils::url('ftp://domain.com/path'));
|
||||
$this->assertSame('sftp://domain.com/path', Utils::url('sftp://domain.com/path'));
|
||||
$this->assertSame('ssh://domain.com', Utils::url('ssh://domain.com'));
|
||||
$this->assertSame('pop://domain.com', Utils::url('pop://domain.com'));
|
||||
$this->assertSame('foo://bar/baz', Utils::url('foo://bar/baz'));
|
||||
$this->assertSame('foo://bar/baz', Utils::url('foo://bar/baz', true));
|
||||
// $this->assertSame('mailto:joe@domain.com', Utils::url('mailto:joe@domain.com', true)); // FIXME <-
|
||||
self::assertSame('http://domain.com/path', Utils::url('http://domain.com/path'));
|
||||
self::assertSame('ftp://domain.com/path', Utils::url('ftp://domain.com/path'));
|
||||
self::assertSame('sftp://domain.com/path', Utils::url('sftp://domain.com/path'));
|
||||
self::assertSame('ssh://domain.com', Utils::url('ssh://domain.com'));
|
||||
self::assertSame('pop://domain.com', Utils::url('pop://domain.com'));
|
||||
self::assertSame('foo://bar/baz', Utils::url('foo://bar/baz'));
|
||||
self::assertSame('foo://bar/baz', Utils::url('foo://bar/baz', true));
|
||||
// self::assertSame('mailto:joe@domain.com', Utils::url('mailto:joe@domain.com', true)); // FIXME <-
|
||||
}
|
||||
|
||||
public function testUrlWithStreams()
|
||||
public function testUrlWithStreams(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testUrlwithExternals()
|
||||
public function testUrlwithExternals(): void
|
||||
{
|
||||
$this->uri->initializeWithUrl('http://testing.dev/path1/path2')->init();
|
||||
$this->assertSame('http://foo.com', Utils::url('http://foo.com'));
|
||||
$this->assertSame('https://foo.com', Utils::url('https://foo.com'));
|
||||
$this->assertSame('//foo.com', Utils::url('//foo.com'));
|
||||
$this->assertSame('//foo.com?param=x', Utils::url('//foo.com?param=x'));
|
||||
self::assertSame('http://foo.com', Utils::url('http://foo.com'));
|
||||
self::assertSame('https://foo.com', Utils::url('https://foo.com'));
|
||||
self::assertSame('//foo.com', Utils::url('//foo.com'));
|
||||
self::assertSame('//foo.com?param=x', Utils::url('//foo.com?param=x'));
|
||||
}
|
||||
|
||||
public function testCheckFilename()
|
||||
public function testCheckFilename(): void
|
||||
{
|
||||
// configure extension for consistent results
|
||||
/** @var \Grav\Common\Config\Config $config */
|
||||
$config = $this->grav['config'];
|
||||
$config->set('security.uploads_dangerous_extensions', ['php', 'html', 'htm', 'exe', 'js']);
|
||||
|
||||
$this->assertFalse(Utils::checkFilename('foo.php'));
|
||||
$this->assertFalse(Utils::checkFilename('bar.js'));
|
||||
self::assertFalse(Utils::checkFilename('foo.php'));
|
||||
self::assertFalse(Utils::checkFilename('bar.js'));
|
||||
|
||||
$this->assertTrue(Utils::checkFilename('foo.json'));
|
||||
$this->assertTrue(Utils::checkFilename('foo.xml'));
|
||||
$this->assertTrue(Utils::checkFilename('foo.yaml'));
|
||||
$this->assertTrue(Utils::checkFilename('foo.yml'));
|
||||
self::assertTrue(Utils::checkFilename('foo.json'));
|
||||
self::assertTrue(Utils::checkFilename('foo.xml'));
|
||||
self::assertTrue(Utils::checkFilename('foo.yaml'));
|
||||
self::assertTrue(Utils::checkFilename('foo.yml'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use Codeception\Util\Fixtures;
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Console\Gpm\InstallCommand;
|
||||
|
||||
/**
|
||||
* Class InstallCommandTest
|
||||
|
|
@ -15,13 +16,13 @@ class InstallCommandTest extends \Codeception\TestCase\Test
|
|||
protected $installCommand;
|
||||
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$this->grav = Fixtures::get('grav');
|
||||
$this->installCommand = new InstallCommand();
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
protected function _after(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,12 @@
|
|||
|
||||
use Grav\Framework\File\Formatter\CsvFormatter;
|
||||
|
||||
/**
|
||||
* Class CsvFormatterTest
|
||||
*/
|
||||
class CsvFormatterTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
public function testEncodeWithAssocColumns()
|
||||
public function testEncodeWithAssocColumns(): void
|
||||
{
|
||||
$data = [
|
||||
['col1' => 1, 'col2' => 2, 'col3' => 3],
|
||||
|
|
@ -23,7 +26,7 @@ class CsvFormatterTest extends \Codeception\TestCase\Test
|
|||
* TBD - If indexes are all numeric, what's the purpose
|
||||
* of displaying header
|
||||
*/
|
||||
public function testEncodeWithIndexColumns()
|
||||
public function testEncodeWithIndexColumns(): void
|
||||
{
|
||||
$data = [
|
||||
[0 => 1, 1 => 2, 2 => 3],
|
||||
|
|
@ -37,7 +40,7 @@ class CsvFormatterTest extends \Codeception\TestCase\Test
|
|||
self::assertEquals('0,1,2', $lines[0]);
|
||||
}
|
||||
|
||||
public function testEncodeEmptyData()
|
||||
public function testEncodeEmptyData(): void
|
||||
{
|
||||
$encoded = (new CsvFormatter())->encode([]);
|
||||
self::assertEquals('', $encoded);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
use Grav\Framework\Filesystem\Filesystem;
|
||||
|
||||
/**
|
||||
* Class FilesystemTest
|
||||
*/
|
||||
class FilesystemTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
protected $class;
|
||||
|
|
@ -277,17 +280,21 @@ class FilesystemTest extends \Codeception\TestCase\Test
|
|||
],
|
||||
];
|
||||
|
||||
protected function _before()
|
||||
protected function _before(): void
|
||||
{
|
||||
$this->class = Filesystem::getInstance();
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
protected function _after(): void
|
||||
{
|
||||
unset($this->class);
|
||||
}
|
||||
|
||||
protected function runTestSet(array $tests, $method)
|
||||
/**
|
||||
* @param array $tests
|
||||
* @param string $method
|
||||
*/
|
||||
protected function runTestSet(array $tests, $method): void
|
||||
{
|
||||
$class = $this->class;
|
||||
foreach ($tests as $path => $candidates) {
|
||||
|
|
@ -299,32 +306,32 @@ class FilesystemTest extends \Codeception\TestCase\Test
|
|||
|
||||
$result = $class->{$method}($path);
|
||||
|
||||
$this->assertSame($expected, $result, "Test {$method}('{$path}')");
|
||||
self::assertSame($expected, $result, "Test {$method}('{$path}')");
|
||||
|
||||
if (function_exists($method) && !strpos($path, '://')) {
|
||||
$cmp_result = $method($path);
|
||||
|
||||
$this->assertSame($cmp_result, $result, "Compare to original {$method}('{$path}')");
|
||||
self::assertSame($cmp_result, $result, "Compare to original {$method}('{$path}')");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testParent()
|
||||
public function testParent(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'parent');
|
||||
}
|
||||
|
||||
public function testNormalize()
|
||||
public function testNormalize(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'normalize');
|
||||
}
|
||||
|
||||
public function testDirname()
|
||||
public function testDirname(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'dirname');
|
||||
}
|
||||
|
||||
public function testPathinfo()
|
||||
public function testPathinfo(): void
|
||||
{
|
||||
$this->runTestSet($this->tests, 'pathinfo');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ twig:
|
|||
cache: true
|
||||
debug: true
|
||||
auto_reload: true
|
||||
autoescape: false
|
||||
autoescape: true
|
||||
|
||||
assets:
|
||||
css_pipeline: false
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user