mirror of
https://github.com/jonathan-martz/pocketbase-php-sdk.git
synced 2026-04-03 15:27:44 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
414bf4fe45 | ||
|
|
a21e474749 | ||
|
|
81e8486870 |
@@ -8,18 +8,17 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"classmap": [
|
"psr-4": {
|
||||||
"src/Client.php",
|
"PocketBase\\": "src/",
|
||||||
"src/Settings.php",
|
"PocketBase\\ViewModel\\": "src/viewModel"
|
||||||
"src/Collection.php"
|
}
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.1|^8.2",
|
"php": "^8.3|^8.4",
|
||||||
"ext-curl": "*"
|
"ext-curl": "*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^11.5",
|
"tomasvotruba/phpunit-json-result-printer": "^0.2.1",
|
||||||
"tomasvotruba/phpunit-json-result-printer": "^0.2.1"
|
"phpunit/phpunit": "^11.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
279
composer.lock
generated
279
composer.lock
generated
@@ -4,21 +4,21 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "e3ef1b1407a46f944e79ec18eb6f6a9b",
|
"content-hash": "a3032883f5e5af1996fb350351fc84ac",
|
||||||
"packages": [],
|
"packages": [],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
{
|
{
|
||||||
"name": "myclabs/deep-copy",
|
"name": "myclabs/deep-copy",
|
||||||
"version": "1.13.4",
|
"version": "1.12.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/myclabs/DeepCopy.git",
|
"url": "https://github.com/myclabs/DeepCopy.git",
|
||||||
"reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a"
|
"reference": "123267b2c49fbf30d78a7b2d333f6be754b94845"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a",
|
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/123267b2c49fbf30d78a7b2d333f6be754b94845",
|
||||||
"reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a",
|
"reference": "123267b2c49fbf30d78a7b2d333f6be754b94845",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/myclabs/DeepCopy/issues",
|
"issues": "https://github.com/myclabs/DeepCopy/issues",
|
||||||
"source": "https://github.com/myclabs/DeepCopy/tree/1.13.4"
|
"source": "https://github.com/myclabs/DeepCopy/tree/1.12.1"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -65,20 +65,20 @@
|
|||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2025-08-01T08:46:24+00:00"
|
"time": "2024-11-08T17:47:46+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "nikic/php-parser",
|
"name": "nikic/php-parser",
|
||||||
"version": "v5.7.0",
|
"version": "v5.4.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/nikic/PHP-Parser.git",
|
"url": "https://github.com/nikic/PHP-Parser.git",
|
||||||
"reference": "dca41cd15c2ac9d055ad70dbfd011130757d1f82"
|
"reference": "447a020a1f875a434d62f2a401f53b82a396e494"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/dca41cd15c2ac9d055ad70dbfd011130757d1f82",
|
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/447a020a1f875a434d62f2a401f53b82a396e494",
|
||||||
"reference": "dca41cd15c2ac9d055ad70dbfd011130757d1f82",
|
"reference": "447a020a1f875a434d62f2a401f53b82a396e494",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -97,7 +97,7 @@
|
|||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "5.x-dev"
|
"dev-master": "5.0-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -121,9 +121,9 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/nikic/PHP-Parser/issues",
|
"issues": "https://github.com/nikic/PHP-Parser/issues",
|
||||||
"source": "https://github.com/nikic/PHP-Parser/tree/v5.7.0"
|
"source": "https://github.com/nikic/PHP-Parser/tree/v5.4.0"
|
||||||
},
|
},
|
||||||
"time": "2025-12-06T11:56:16+00:00"
|
"time": "2024-12-30T11:07:19+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phar-io/manifest",
|
"name": "phar-io/manifest",
|
||||||
@@ -245,35 +245,35 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-code-coverage",
|
"name": "phpunit/php-code-coverage",
|
||||||
"version": "11.0.12",
|
"version": "11.0.8",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
||||||
"reference": "2c1ed04922802c15e1de5d7447b4856de949cf56"
|
"reference": "418c59fd080954f8c4aa5631d9502ecda2387118"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2c1ed04922802c15e1de5d7447b4856de949cf56",
|
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/418c59fd080954f8c4aa5631d9502ecda2387118",
|
||||||
"reference": "2c1ed04922802c15e1de5d7447b4856de949cf56",
|
"reference": "418c59fd080954f8c4aa5631d9502ecda2387118",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"ext-dom": "*",
|
"ext-dom": "*",
|
||||||
"ext-libxml": "*",
|
"ext-libxml": "*",
|
||||||
"ext-xmlwriter": "*",
|
"ext-xmlwriter": "*",
|
||||||
"nikic/php-parser": "^5.7.0",
|
"nikic/php-parser": "^5.3.1",
|
||||||
"php": ">=8.2",
|
"php": ">=8.2",
|
||||||
"phpunit/php-file-iterator": "^5.1.0",
|
"phpunit/php-file-iterator": "^5.1.0",
|
||||||
"phpunit/php-text-template": "^4.0.1",
|
"phpunit/php-text-template": "^4.0.1",
|
||||||
"sebastian/code-unit-reverse-lookup": "^4.0.1",
|
"sebastian/code-unit-reverse-lookup": "^4.0.1",
|
||||||
"sebastian/complexity": "^4.0.1",
|
"sebastian/complexity": "^4.0.1",
|
||||||
"sebastian/environment": "^7.2.1",
|
"sebastian/environment": "^7.2.0",
|
||||||
"sebastian/lines-of-code": "^3.0.1",
|
"sebastian/lines-of-code": "^3.0.1",
|
||||||
"sebastian/version": "^5.0.2",
|
"sebastian/version": "^5.0.2",
|
||||||
"theseer/tokenizer": "^1.3.1"
|
"theseer/tokenizer": "^1.2.3"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^11.5.46"
|
"phpunit/phpunit": "^11.5.0"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-pcov": "PHP extension that provides line coverage",
|
"ext-pcov": "PHP extension that provides line coverage",
|
||||||
@@ -311,52 +311,40 @@
|
|||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
|
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
|
||||||
"security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy",
|
"security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy",
|
||||||
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/11.0.12"
|
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/11.0.8"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://liberapay.com/sebastianbergmann",
|
|
||||||
"type": "liberapay"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://thanks.dev/u/gh/sebastianbergmann",
|
|
||||||
"type": "thanks_dev"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/phpunit/php-code-coverage",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2025-12-24T07:01:01+00:00"
|
"time": "2024-12-11T12:34:27+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-file-iterator",
|
"name": "phpunit/php-file-iterator",
|
||||||
"version": "5.1.1",
|
"version": "5.1.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
|
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
|
||||||
"reference": "2f3a64888c814fc235386b7387dd5b5ed92ad903"
|
"reference": "118cfaaa8bc5aef3287bf315b6060b1174754af6"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/2f3a64888c814fc235386b7387dd5b5ed92ad903",
|
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/118cfaaa8bc5aef3287bf315b6060b1174754af6",
|
||||||
"reference": "2f3a64888c814fc235386b7387dd5b5ed92ad903",
|
"reference": "118cfaaa8bc5aef3287bf315b6060b1174754af6",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.2"
|
"php": ">=8.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^11.3"
|
"phpunit/phpunit": "^11.0"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-main": "5.1-dev"
|
"dev-main": "5.0-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -384,27 +372,15 @@
|
|||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/php-file-iterator/issues",
|
"issues": "https://github.com/sebastianbergmann/php-file-iterator/issues",
|
||||||
"security": "https://github.com/sebastianbergmann/php-file-iterator/security/policy",
|
"security": "https://github.com/sebastianbergmann/php-file-iterator/security/policy",
|
||||||
"source": "https://github.com/sebastianbergmann/php-file-iterator/tree/5.1.1"
|
"source": "https://github.com/sebastianbergmann/php-file-iterator/tree/5.1.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://liberapay.com/sebastianbergmann",
|
|
||||||
"type": "liberapay"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://thanks.dev/u/gh/sebastianbergmann",
|
|
||||||
"type": "thanks_dev"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/phpunit/php-file-iterator",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2026-02-02T13:52:54+00:00"
|
"time": "2024-08-27T05:02:59+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-invoker",
|
"name": "phpunit/php-invoker",
|
||||||
@@ -592,16 +568,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/phpunit",
|
"name": "phpunit/phpunit",
|
||||||
"version": "11.5.51",
|
"version": "11.5.8",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||||
"reference": "ad14159f92910b0f0e3928c13e9b2077529de091"
|
"reference": "c9bd61aab12f0fc5e82ecfe621ff518a1d1f1049"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ad14159f92910b0f0e3928c13e9b2077529de091",
|
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c9bd61aab12f0fc5e82ecfe621ff518a1d1f1049",
|
||||||
"reference": "ad14159f92910b0f0e3928c13e9b2077529de091",
|
"reference": "c9bd61aab12f0fc5e82ecfe621ff518a1d1f1049",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -611,25 +587,24 @@
|
|||||||
"ext-mbstring": "*",
|
"ext-mbstring": "*",
|
||||||
"ext-xml": "*",
|
"ext-xml": "*",
|
||||||
"ext-xmlwriter": "*",
|
"ext-xmlwriter": "*",
|
||||||
"myclabs/deep-copy": "^1.13.4",
|
"myclabs/deep-copy": "^1.12.1",
|
||||||
"phar-io/manifest": "^2.0.4",
|
"phar-io/manifest": "^2.0.4",
|
||||||
"phar-io/version": "^3.2.1",
|
"phar-io/version": "^3.2.1",
|
||||||
"php": ">=8.2",
|
"php": ">=8.2",
|
||||||
"phpunit/php-code-coverage": "^11.0.12",
|
"phpunit/php-code-coverage": "^11.0.8",
|
||||||
"phpunit/php-file-iterator": "^5.1.1",
|
"phpunit/php-file-iterator": "^5.1.0",
|
||||||
"phpunit/php-invoker": "^5.0.1",
|
"phpunit/php-invoker": "^5.0.1",
|
||||||
"phpunit/php-text-template": "^4.0.1",
|
"phpunit/php-text-template": "^4.0.1",
|
||||||
"phpunit/php-timer": "^7.0.1",
|
"phpunit/php-timer": "^7.0.1",
|
||||||
"sebastian/cli-parser": "^3.0.2",
|
"sebastian/cli-parser": "^3.0.2",
|
||||||
"sebastian/code-unit": "^3.0.3",
|
"sebastian/code-unit": "^3.0.2",
|
||||||
"sebastian/comparator": "^6.3.3",
|
"sebastian/comparator": "^6.3.0",
|
||||||
"sebastian/diff": "^6.0.2",
|
"sebastian/diff": "^6.0.2",
|
||||||
"sebastian/environment": "^7.2.1",
|
"sebastian/environment": "^7.2.0",
|
||||||
"sebastian/exporter": "^6.3.2",
|
"sebastian/exporter": "^6.3.0",
|
||||||
"sebastian/global-state": "^7.0.2",
|
"sebastian/global-state": "^7.0.2",
|
||||||
"sebastian/object-enumerator": "^6.0.1",
|
"sebastian/object-enumerator": "^6.0.1",
|
||||||
"sebastian/recursion-context": "^6.0.3",
|
"sebastian/type": "^5.1.0",
|
||||||
"sebastian/type": "^5.1.3",
|
|
||||||
"sebastian/version": "^5.0.2",
|
"sebastian/version": "^5.0.2",
|
||||||
"staabm/side-effects-detector": "^1.0.5"
|
"staabm/side-effects-detector": "^1.0.5"
|
||||||
},
|
},
|
||||||
@@ -674,7 +649,7 @@
|
|||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
|
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
|
||||||
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
|
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
|
||||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.51"
|
"source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.8"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -685,20 +660,12 @@
|
|||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"url": "https://liberapay.com/sebastianbergmann",
|
|
||||||
"type": "liberapay"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://thanks.dev/u/gh/sebastianbergmann",
|
|
||||||
"type": "thanks_dev"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit",
|
"url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit",
|
||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2026-02-05T07:59:30+00:00"
|
"time": "2025-02-18T06:26:59+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/cli-parser",
|
"name": "sebastian/cli-parser",
|
||||||
@@ -759,16 +726,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/code-unit",
|
"name": "sebastian/code-unit",
|
||||||
"version": "3.0.3",
|
"version": "3.0.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/code-unit.git",
|
"url": "https://github.com/sebastianbergmann/code-unit.git",
|
||||||
"reference": "54391c61e4af8078e5b276ab082b6d3c54c9ad64"
|
"reference": "ee88b0cdbe74cf8dd3b54940ff17643c0d6543ca"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/54391c61e4af8078e5b276ab082b6d3c54c9ad64",
|
"url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/ee88b0cdbe74cf8dd3b54940ff17643c0d6543ca",
|
||||||
"reference": "54391c61e4af8078e5b276ab082b6d3c54c9ad64",
|
"reference": "ee88b0cdbe74cf8dd3b54940ff17643c0d6543ca",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -804,7 +771,7 @@
|
|||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/code-unit/issues",
|
"issues": "https://github.com/sebastianbergmann/code-unit/issues",
|
||||||
"security": "https://github.com/sebastianbergmann/code-unit/security/policy",
|
"security": "https://github.com/sebastianbergmann/code-unit/security/policy",
|
||||||
"source": "https://github.com/sebastianbergmann/code-unit/tree/3.0.3"
|
"source": "https://github.com/sebastianbergmann/code-unit/tree/3.0.2"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -812,7 +779,7 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2025-03-19T07:56:08+00:00"
|
"time": "2024-12-12T09:59:06+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/code-unit-reverse-lookup",
|
"name": "sebastian/code-unit-reverse-lookup",
|
||||||
@@ -872,16 +839,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/comparator",
|
"name": "sebastian/comparator",
|
||||||
"version": "6.3.3",
|
"version": "6.3.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/comparator.git",
|
"url": "https://github.com/sebastianbergmann/comparator.git",
|
||||||
"reference": "2c95e1e86cb8dd41beb8d502057d1081ccc8eca9"
|
"reference": "d4e47a769525c4dd38cea90e5dcd435ddbbc7115"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2c95e1e86cb8dd41beb8d502057d1081ccc8eca9",
|
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/d4e47a769525c4dd38cea90e5dcd435ddbbc7115",
|
||||||
"reference": "2c95e1e86cb8dd41beb8d502057d1081ccc8eca9",
|
"reference": "d4e47a769525c4dd38cea90e5dcd435ddbbc7115",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -900,7 +867,7 @@
|
|||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-main": "6.3-dev"
|
"dev-main": "6.2-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -940,27 +907,15 @@
|
|||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/comparator/issues",
|
"issues": "https://github.com/sebastianbergmann/comparator/issues",
|
||||||
"security": "https://github.com/sebastianbergmann/comparator/security/policy",
|
"security": "https://github.com/sebastianbergmann/comparator/security/policy",
|
||||||
"source": "https://github.com/sebastianbergmann/comparator/tree/6.3.3"
|
"source": "https://github.com/sebastianbergmann/comparator/tree/6.3.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://liberapay.com/sebastianbergmann",
|
|
||||||
"type": "liberapay"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://thanks.dev/u/gh/sebastianbergmann",
|
|
||||||
"type": "thanks_dev"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/sebastian/comparator",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2026-01-24T09:26:40+00:00"
|
"time": "2025-01-06T10:28:19+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/complexity",
|
"name": "sebastian/complexity",
|
||||||
@@ -1089,23 +1044,23 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/environment",
|
"name": "sebastian/environment",
|
||||||
"version": "7.2.1",
|
"version": "7.2.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/environment.git",
|
"url": "https://github.com/sebastianbergmann/environment.git",
|
||||||
"reference": "a5c75038693ad2e8d4b6c15ba2403532647830c4"
|
"reference": "855f3ae0ab316bbafe1ba4e16e9f3c078d24a0c5"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/a5c75038693ad2e8d4b6c15ba2403532647830c4",
|
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/855f3ae0ab316bbafe1ba4e16e9f3c078d24a0c5",
|
||||||
"reference": "a5c75038693ad2e8d4b6c15ba2403532647830c4",
|
"reference": "855f3ae0ab316bbafe1ba4e16e9f3c078d24a0c5",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.2"
|
"php": ">=8.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^11.3"
|
"phpunit/phpunit": "^11.0"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-posix": "*"
|
"ext-posix": "*"
|
||||||
@@ -1141,40 +1096,28 @@
|
|||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/environment/issues",
|
"issues": "https://github.com/sebastianbergmann/environment/issues",
|
||||||
"security": "https://github.com/sebastianbergmann/environment/security/policy",
|
"security": "https://github.com/sebastianbergmann/environment/security/policy",
|
||||||
"source": "https://github.com/sebastianbergmann/environment/tree/7.2.1"
|
"source": "https://github.com/sebastianbergmann/environment/tree/7.2.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://liberapay.com/sebastianbergmann",
|
|
||||||
"type": "liberapay"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://thanks.dev/u/gh/sebastianbergmann",
|
|
||||||
"type": "thanks_dev"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/sebastian/environment",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2025-05-21T11:55:47+00:00"
|
"time": "2024-07-03T04:54:44+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/exporter",
|
"name": "sebastian/exporter",
|
||||||
"version": "6.3.2",
|
"version": "6.3.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/exporter.git",
|
"url": "https://github.com/sebastianbergmann/exporter.git",
|
||||||
"reference": "70a298763b40b213ec087c51c739efcaa90bcd74"
|
"reference": "3473f61172093b2da7de1fb5782e1f24cc036dc3"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/70a298763b40b213ec087c51c739efcaa90bcd74",
|
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/3473f61172093b2da7de1fb5782e1f24cc036dc3",
|
||||||
"reference": "70a298763b40b213ec087c51c739efcaa90bcd74",
|
"reference": "3473f61172093b2da7de1fb5782e1f24cc036dc3",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -1188,7 +1131,7 @@
|
|||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-main": "6.3-dev"
|
"dev-main": "6.1-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -1231,27 +1174,15 @@
|
|||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/exporter/issues",
|
"issues": "https://github.com/sebastianbergmann/exporter/issues",
|
||||||
"security": "https://github.com/sebastianbergmann/exporter/security/policy",
|
"security": "https://github.com/sebastianbergmann/exporter/security/policy",
|
||||||
"source": "https://github.com/sebastianbergmann/exporter/tree/6.3.2"
|
"source": "https://github.com/sebastianbergmann/exporter/tree/6.3.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://liberapay.com/sebastianbergmann",
|
|
||||||
"type": "liberapay"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://thanks.dev/u/gh/sebastianbergmann",
|
|
||||||
"type": "thanks_dev"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/sebastian/exporter",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2025-09-24T06:12:51+00:00"
|
"time": "2024-12-05T09:17:50+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/global-state",
|
"name": "sebastian/global-state",
|
||||||
@@ -1489,23 +1420,23 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/recursion-context",
|
"name": "sebastian/recursion-context",
|
||||||
"version": "6.0.3",
|
"version": "6.0.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/recursion-context.git",
|
"url": "https://github.com/sebastianbergmann/recursion-context.git",
|
||||||
"reference": "f6458abbf32a6c8174f8f26261475dc133b3d9dc"
|
"reference": "694d156164372abbd149a4b85ccda2e4670c0e16"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/f6458abbf32a6c8174f8f26261475dc133b3d9dc",
|
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/694d156164372abbd149a4b85ccda2e4670c0e16",
|
||||||
"reference": "f6458abbf32a6c8174f8f26261475dc133b3d9dc",
|
"reference": "694d156164372abbd149a4b85ccda2e4670c0e16",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.2"
|
"php": ">=8.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^11.3"
|
"phpunit/phpunit": "^11.0"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
@@ -1541,40 +1472,28 @@
|
|||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/recursion-context/issues",
|
"issues": "https://github.com/sebastianbergmann/recursion-context/issues",
|
||||||
"security": "https://github.com/sebastianbergmann/recursion-context/security/policy",
|
"security": "https://github.com/sebastianbergmann/recursion-context/security/policy",
|
||||||
"source": "https://github.com/sebastianbergmann/recursion-context/tree/6.0.3"
|
"source": "https://github.com/sebastianbergmann/recursion-context/tree/6.0.2"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://liberapay.com/sebastianbergmann",
|
|
||||||
"type": "liberapay"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://thanks.dev/u/gh/sebastianbergmann",
|
|
||||||
"type": "thanks_dev"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/sebastian/recursion-context",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2025-08-13T04:42:22+00:00"
|
"time": "2024-07-03T05:10:34+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/type",
|
"name": "sebastian/type",
|
||||||
"version": "5.1.3",
|
"version": "5.1.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/type.git",
|
"url": "https://github.com/sebastianbergmann/type.git",
|
||||||
"reference": "f77d2d4e78738c98d9a68d2596fe5e8fa380f449"
|
"reference": "461b9c5da241511a2a0e8f240814fb23ce5c0aac"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/f77d2d4e78738c98d9a68d2596fe5e8fa380f449",
|
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/461b9c5da241511a2a0e8f240814fb23ce5c0aac",
|
||||||
"reference": "f77d2d4e78738c98d9a68d2596fe5e8fa380f449",
|
"reference": "461b9c5da241511a2a0e8f240814fb23ce5c0aac",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -1610,27 +1529,15 @@
|
|||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/type/issues",
|
"issues": "https://github.com/sebastianbergmann/type/issues",
|
||||||
"security": "https://github.com/sebastianbergmann/type/security/policy",
|
"security": "https://github.com/sebastianbergmann/type/security/policy",
|
||||||
"source": "https://github.com/sebastianbergmann/type/tree/5.1.3"
|
"source": "https://github.com/sebastianbergmann/type/tree/5.1.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://liberapay.com/sebastianbergmann",
|
|
||||||
"type": "liberapay"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://thanks.dev/u/gh/sebastianbergmann",
|
|
||||||
"type": "thanks_dev"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/sebastian/type",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2025-08-09T06:55:48+00:00"
|
"time": "2024-09-17T13:12:04+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/version",
|
"name": "sebastian/version",
|
||||||
@@ -1740,16 +1647,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "theseer/tokenizer",
|
"name": "theseer/tokenizer",
|
||||||
"version": "1.3.1",
|
"version": "1.2.3",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/theseer/tokenizer.git",
|
"url": "https://github.com/theseer/tokenizer.git",
|
||||||
"reference": "b7489ce515e168639d17feec34b8847c326b0b3c"
|
"reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/theseer/tokenizer/zipball/b7489ce515e168639d17feec34b8847c326b0b3c",
|
"url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2",
|
||||||
"reference": "b7489ce515e168639d17feec34b8847c326b0b3c",
|
"reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -1778,7 +1685,7 @@
|
|||||||
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
|
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/theseer/tokenizer/issues",
|
"issues": "https://github.com/theseer/tokenizer/issues",
|
||||||
"source": "https://github.com/theseer/tokenizer/tree/1.3.1"
|
"source": "https://github.com/theseer/tokenizer/tree/1.2.3"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -1786,7 +1693,7 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2025-11-17T20:03:58+00:00"
|
"time": "2024-03-03T12:36:25+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "tomasvotruba/phpunit-json-result-printer",
|
"name": "tomasvotruba/phpunit-json-result-printer",
|
||||||
@@ -1835,7 +1742,7 @@
|
|||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": {
|
"platform": {
|
||||||
"php": "^8.1|^8.2",
|
"php": "^8.3|^8.4",
|
||||||
"ext-curl": "*"
|
"ext-curl": "*"
|
||||||
},
|
},
|
||||||
"platform-dev": [],
|
"platform-dev": [],
|
||||||
|
|||||||
12
docker-compose.yml
Normal file
12
docker-compose.yml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
services:
|
||||||
|
pocketbase_php_sdk:
|
||||||
|
image: ghcr.io/muchobien/pocketbase:latest
|
||||||
|
container_name: pocketbase_php_sdk
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "7090:8090"
|
||||||
|
healthcheck: # optional, recommended since v0.10.0
|
||||||
|
test: wget --no-verbose --tries=1 --spider http://localhost:8090/api/health || exit 1
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
104
mailer.go
104
mailer.go
@@ -1,104 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"encoding/json"
|
|
||||||
"flag"
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
"net/smtp"
|
|
||||||
"os/exec"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
now := time.Now()
|
|
||||||
|
|
||||||
// Define flags
|
|
||||||
smtpPass := flag.String("password", "", "SMTP password")
|
|
||||||
sender := flag.String("sender", "", "SMTP sender")
|
|
||||||
smtpUser := flag.String("user", "", "SMTP username")
|
|
||||||
|
|
||||||
// Parse the flags
|
|
||||||
flag.Parse()
|
|
||||||
|
|
||||||
// Check if required flags are provided
|
|
||||||
if *smtpPass == "" {
|
|
||||||
log.Fatal("Error: Password is required. Use -password flag.")
|
|
||||||
}
|
|
||||||
if *smtpUser == "" {
|
|
||||||
log.Fatal("Error: SMTP username is required. Use -user flag.")
|
|
||||||
}
|
|
||||||
if *sender == "" {
|
|
||||||
log.Fatal("Error: Sender email is required. Use -sender flag.")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Format the date as YYYY-MM-DD
|
|
||||||
currentDate := now.Format("01.02.2006")
|
|
||||||
|
|
||||||
recipient := "support@jonathan-martz.de"
|
|
||||||
subject := "PHPUnit - PocketBase PHP SDK - " + currentDate
|
|
||||||
smtpHost := "smtps.udag.de" // Replace with your SMTP host
|
|
||||||
smtpPort := "587" // Replace with your SMTP port
|
|
||||||
|
|
||||||
// Run PHPUnit with combined stdout and stderr
|
|
||||||
cmd := exec.Command("php", "vendor/bin/phpunit")
|
|
||||||
var output bytes.Buffer
|
|
||||||
cmd.Stdout = &output
|
|
||||||
cmd.Stderr = &output
|
|
||||||
|
|
||||||
if err := cmd.Run(); err != nil {
|
|
||||||
log.Printf("PHPUnit command failed: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if output is empty
|
|
||||||
if output.Len() == 0 {
|
|
||||||
log.Fatal("PHPUnit output is empty. Please check your configuration.")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse the JSON output
|
|
||||||
var result map[string]interface{}
|
|
||||||
if err := json.Unmarshal(output.Bytes(), &result); err != nil {
|
|
||||||
log.Fatalf("Failed to parse JSON output: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract the 'counts' field
|
|
||||||
counts, ok := result["counts"].(map[string]interface{})
|
|
||||||
if !ok {
|
|
||||||
log.Fatal("Counts field not found in PHPUnit output.")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if 'fails' is greater than 0
|
|
||||||
failed, ok := counts["failed"].(float64)
|
|
||||||
if !ok {
|
|
||||||
log.Fatal("'fails' field not found in counts.")
|
|
||||||
}
|
|
||||||
|
|
||||||
if failed > 0 {
|
|
||||||
// Serialize the counts field to JSON for the email body
|
|
||||||
countsJSON, err := json.MarshalIndent(counts, "", " ")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Failed to serialize counts to JSON: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prepare the email body
|
|
||||||
emailBody := fmt.Sprintf("Subject: %s\r\n\r\n%s", subject, string(countsJSON))
|
|
||||||
|
|
||||||
// Connect to the SMTP server
|
|
||||||
auth := smtp.PlainAuth("", *smtpUser, *smtpPass, smtpHost)
|
|
||||||
err = smtp.SendMail(
|
|
||||||
smtpHost+":"+smtpPort,
|
|
||||||
auth,
|
|
||||||
*sender,
|
|
||||||
[]string{recipient},
|
|
||||||
[]byte(emailBody),
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Failed to send email: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Println("Test results sent to", recipient)
|
|
||||||
} else {
|
|
||||||
log.Println("No failures detected. No email sent.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,6 @@
|
|||||||
cacheDirectory=".phpunit.cache"
|
cacheDirectory=".phpunit.cache"
|
||||||
executionOrder="depends,defects"
|
executionOrder="depends,defects"
|
||||||
shortenArraysForExportThreshold="10"
|
shortenArraysForExportThreshold="10"
|
||||||
requireCoverageMetadata="true"
|
|
||||||
beStrictAboutCoverageMetadata="true"
|
beStrictAboutCoverageMetadata="true"
|
||||||
beStrictAboutOutputDuringTests="true"
|
beStrictAboutOutputDuringTests="true"
|
||||||
displayDetailsOnPhpunitDeprecations="true"
|
displayDetailsOnPhpunitDeprecations="true"
|
||||||
@@ -17,9 +16,10 @@
|
|||||||
<directory>tests</directory>
|
<directory>tests</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
<extensions>
|
|
||||||
|
<!-- <extensions>
|
||||||
<bootstrap class="TomasVotruba\PHPUnitJsonResultPrinter\PHPUnitJsonResultPrinterExtension" />
|
<bootstrap class="TomasVotruba\PHPUnitJsonResultPrinter\PHPUnitJsonResultPrinterExtension" />
|
||||||
</extensions>
|
</extensions> -->
|
||||||
|
|
||||||
<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
|
<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
|
||||||
<include>
|
<include>
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Pb;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
|
|
||||||
final class AuthTest extends TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
private Collection $collection;
|
|
||||||
private ?string $url;
|
|
||||||
|
|
||||||
protected function setUp(): void
|
|
||||||
{
|
|
||||||
$this->url = getenv('POCKETBASE_URL') ?: 'https://admin.pocketbase.dev';
|
|
||||||
$this->collection = new Collection($this->url, 'users');
|
|
||||||
}
|
|
||||||
public function testAuthUser(): void
|
|
||||||
{
|
|
||||||
$actual = $this->collection->authAsUser('support@jonathan-martz.de', 'rockt');
|
|
||||||
$expected = '{"data":{},"message":"Failed to authenticate.","status":400}';
|
|
||||||
|
|
||||||
$this->assertEquals($expected, trim($actual, PHP_EOL));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testAuthSuperUser(): void
|
|
||||||
{
|
|
||||||
$this->collection = new Collection($this->url, '_superusers');
|
|
||||||
$actual = $this->collection->authAsAdmin('admin@jonathan-martz.de', 'rockt');
|
|
||||||
$expected = '{"data":{},"message":"Failed to authenticate.","status":400}';
|
|
||||||
|
|
||||||
$this->assertEquals($expected, trim($actual, PHP_EOL));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testAuthSuperUser2(): void
|
|
||||||
{
|
|
||||||
$this->collection = new Collection($this->url, '_superusers');
|
|
||||||
|
|
||||||
$actual = $this->collection->authAsAdmin('admin@jonathan-martz.de', 'rockt');
|
|
||||||
|
|
||||||
$data = json_decode($actual,true);
|
|
||||||
$this->assertArrayHasKey('record',$data);
|
|
||||||
$this->assertArrayHasKey('token',$data);
|
|
||||||
$this->assertCount(8,$data['record']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,34 +1,52 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Pb;
|
namespace PocketBase;
|
||||||
|
|
||||||
class Client
|
class Client
|
||||||
{
|
{
|
||||||
private string $url;
|
|
||||||
public string $token = '';
|
|
||||||
|
|
||||||
public function __construct(string $url)
|
public ?string $baseurl = null;
|
||||||
|
public ?string $token = null;
|
||||||
|
public HttpClient $http;
|
||||||
|
|
||||||
|
public function __construct($baseurl = null)
|
||||||
{
|
{
|
||||||
$this->url = $url;
|
$this->baseurl = $baseurl ?? 'http://localhost:7090';
|
||||||
|
$this->http = new HttpClient();
|
||||||
|
$this->token = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function collection(string $collection): Collection
|
public function collection(string $name): Collection
|
||||||
{
|
{
|
||||||
return new Collection($this->url ,$collection, $this->token);
|
return new Collection($this->baseurl, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function settings(): Settings
|
public function setBaseUrl($baseurl){
|
||||||
{
|
$this->baseurl = $baseurl;
|
||||||
return new Settings($this->url, $this->token);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setAuthToken(string $token): void
|
public function getBaseUrl(){
|
||||||
{
|
return $this->baseurl;
|
||||||
$this->token = $token;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAuthToken(): string
|
public function getToken(): ?string
|
||||||
{
|
{
|
||||||
return $this->token;
|
return $this->token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setToken(?string $token): void
|
||||||
|
{
|
||||||
|
$this->token = $token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHttp(): HttpClient
|
||||||
|
{
|
||||||
|
return $this->http;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHttp(HttpClient $http): Client
|
||||||
|
{
|
||||||
|
$this->http = $http;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,212 +1,146 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Pb;
|
namespace PocketBase;
|
||||||
|
|
||||||
|
use PocketBase\ViewModel\CustomRecordViewModel;
|
||||||
|
use PocketBase\ViewModel\RecordListViewModel;
|
||||||
|
use PocketBase\ViewModel\RecordViewModel;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class Collection
|
class Collection
|
||||||
{
|
{
|
||||||
/**
|
public HttpClient $http;
|
||||||
* @var string
|
private Client $client;
|
||||||
*/
|
private string $name;
|
||||||
private string $collection;
|
public string $path;
|
||||||
|
|
||||||
/**
|
public function getPath(): string
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private string $url;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private static string $token = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $url
|
|
||||||
* @param string $collection
|
|
||||||
* @param string $token
|
|
||||||
*/
|
|
||||||
public function __construct(string $url, string $collection, string $token = '')
|
|
||||||
{
|
{
|
||||||
$this->url = $url;
|
return $this->path;
|
||||||
$this->collection = $collection;
|
|
||||||
if (!empty($token)) {
|
|
||||||
self::$token = $token;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function setPath(string $path): Collection
|
||||||
* @param int $start
|
|
||||||
* @param int $end
|
|
||||||
* @param array $queryParams
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getList(int $start = 1, int $end = 50, array $queryParams = []): array
|
|
||||||
{
|
{
|
||||||
$queryParams['perPage'] = $end;
|
$this->path = $path;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __construct(string $url = null, string $name = 'users')
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
$this->http = new HttpClient();
|
||||||
|
$this->client = new Client();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFullList(int $batch, $bodyParams = [], array $queryParams = []): RecordListViewModel
|
||||||
|
{
|
||||||
|
$queryParams['limit'] = $batch;
|
||||||
$getParams = !empty($queryParams) ? http_build_query($queryParams) : "";
|
$getParams = !empty($queryParams) ? http_build_query($queryParams) : "";
|
||||||
$response = $this->doRequest($this->url . "/api/collections/" . $this->collection . "/records?" . $getParams, 'GET');
|
return new RecordListViewModel(
|
||||||
|
json_decode(
|
||||||
return json_decode($response, JSON_FORCE_OBJECT);
|
$this->http->doRequest(
|
||||||
|
$this->client->getBaseUrl() . $this->path . '?' . $getParams,
|
||||||
|
'GET',
|
||||||
|
$bodyParams,
|
||||||
|
$this->client->token
|
||||||
|
),
|
||||||
|
true)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getList(int $page, int $limit, $bodyParams = [], array $queryParams = []): RecordListViewModel
|
||||||
* @param string $recordId
|
|
||||||
* @param string $field
|
|
||||||
* @param string $filepath
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function upload(string $recordId, string $field, string $filepath): void
|
|
||||||
{
|
{
|
||||||
$ch = curl_init($this->url . "/api/collections/" . $this->collection . "/records/" . $recordId);
|
|
||||||
curl_setopt_array($ch, array(
|
|
||||||
CURLOPT_CUSTOMREQUEST => 'PATCH',
|
|
||||||
CURLOPT_POSTFIELDS => array(
|
|
||||||
$field => new \CURLFile($filepath)
|
|
||||||
)
|
|
||||||
));
|
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
||||||
|
|
||||||
$headers = array('Content-Type: multipart/form-data');
|
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
|
||||||
|
|
||||||
$response = curl_exec($ch);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $email
|
|
||||||
* @param string $password
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function authAsUser(string $email, string $password): string
|
|
||||||
{
|
|
||||||
$result = $this->doRequest($this->url . "/api/collections/users/auth-with-password", 'POST', ['identity' => $email, 'password' => $password]);
|
|
||||||
if (!empty($result['token'])) {
|
|
||||||
self::$token = $result['token'];
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $batch
|
|
||||||
* @param array $queryParams
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getFullList(array $queryParams, int $batch = 200): array
|
|
||||||
{
|
|
||||||
$queryParams = [... $queryParams, 'perPage' => $batch];
|
|
||||||
$getParams = !empty($queryParams) ? http_build_query($queryParams) : "";
|
$getParams = !empty($queryParams) ? http_build_query($queryParams) : "";
|
||||||
$response = $this->doRequest($this->url . "/api/collections/" . $this->collection . "/records?" . $getParams, 'GET');
|
return new RecordListViewModel(json_decode(
|
||||||
|
$this->http->doRequest(
|
||||||
return json_decode($response, JSON_FORCE_OBJECT);
|
$this->client->getBaseUrl() . $this->path . '?' . $getParams,
|
||||||
|
'GET',
|
||||||
|
$bodyParams,
|
||||||
|
$this->client->token
|
||||||
|
), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function authAsUser(string $email, string $password): ?string
|
||||||
* @param string $filter
|
|
||||||
* @param array $queryParams
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getFirstListItem(string $filter, array $queryParams = []): array
|
|
||||||
{
|
{
|
||||||
$queryParams['perPage'] = 1;
|
|
||||||
$getParams = !empty($queryParams) ? http_build_query($queryParams) : "";
|
$getParams = !empty($queryParams) ? http_build_query($queryParams) : "";
|
||||||
$response = $this->doRequest($this->url . "/api/collections/" . $this->collection . "/records?" . $getParams, 'GET');
|
$data = json_decode(
|
||||||
return json_decode($response, JSON_FORCE_OBJECT)['items'][0];
|
$this->http->doRequest(
|
||||||
|
$this->client->getBaseUrl() . '/api/collections/users/auth-with-password' . '?' . $getParams,
|
||||||
|
'POST',
|
||||||
|
[
|
||||||
|
'identity' => $email,
|
||||||
|
'password' => $password,
|
||||||
|
]
|
||||||
|
), true);
|
||||||
|
return $data['token'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function authAsAdmin(string $email, string $password): ?string
|
||||||
* @param array $bodyParams
|
|
||||||
* @param array $queryParams
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function create(array $bodyParams = [], array $queryParams = []): string
|
|
||||||
{
|
{
|
||||||
return $this->doRequest($this->url . "/api/collections/" . $this->collection . "/records", 'POST', $bodyParams);
|
$getParams = !empty($queryParams) ? http_build_query($queryParams) : "";
|
||||||
|
$data = json_decode($this->http->doRequest(
|
||||||
|
$this->client->baseurl . "/api/collections/_superusers/auth-with-password" . '?' . $getParams,
|
||||||
|
'POST',
|
||||||
|
[
|
||||||
|
'identity' => $email,
|
||||||
|
'password' => $password,
|
||||||
|
]), true);
|
||||||
|
return $data['token'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function create(array $bodyParams, array $queryParams = []): CustomRecordViewModel
|
||||||
* @param string $recordId
|
|
||||||
* @param array $bodyParams
|
|
||||||
* @param array $queryParams
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function update(string $recordId, array $bodyParams = [], array $queryParams = []): void
|
|
||||||
{
|
{
|
||||||
// Todo bodyParams equals json, currently workaround
|
$getParams = !empty($queryParams) ? http_build_query($queryParams) : "";
|
||||||
$this->doRequest($this->url . "/api/collections/" . $this->collection . "/records/" . $recordId, 'PATCH', $bodyParams);
|
|
||||||
|
return new CustomRecordViewModel(json_decode(
|
||||||
|
$this->http->doRequest(
|
||||||
|
$this->client->getBaseUrl() . $this->getPath() . '?' . $getParams,
|
||||||
|
'POST',
|
||||||
|
$bodyParams,
|
||||||
|
$this->client->token
|
||||||
|
), true) ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function update($id, $bodyParams, $token = '', array $queryParams = []): RecordViewModel
|
||||||
* @param string $recordId
|
|
||||||
* @param array $queryParams
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function delete(string $recordId, array $queryParams = []): void
|
|
||||||
{
|
{
|
||||||
$this->doRequest($this->url . "/api/collections/" . $this->collection . "/records/" . $recordId, 'DELETE');
|
$getParams = !empty($queryParams) ? http_build_query($queryParams) : "";
|
||||||
|
return new RecordViewModel(json_decode($this->http->doRequest(
|
||||||
|
$this->client->getBaseUrl() . '/api/collections/test/records/' . $id . '?' . $getParams
|
||||||
|
, 'PATCH', json_encode($bodyParams), $token), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getOne($id, $token = '', array $queryParams = []): CustomRecordViewModel
|
||||||
* @param string $recordId
|
|
||||||
* @param string $url
|
|
||||||
* @param string $method
|
|
||||||
* @return bool|string
|
|
||||||
*/
|
|
||||||
public function doRequest(string $url, string $method, $bodyParams = []): string
|
|
||||||
{
|
{
|
||||||
// TODO move doRequestIntoService ?
|
$getParams = !empty($queryParams) ? http_build_query($queryParams) : "";
|
||||||
// TODO replace curl with HttpClient
|
return new CustomRecordViewModel(json_decode($this->http->doRequest(
|
||||||
$ch = curl_init();
|
$this->client->getBaseUrl() . '/api/collections/test/records/' . $id . '?' . $getParams#
|
||||||
|
, 'GET', [], $token), true));
|
||||||
if (self::$token != '') {
|
|
||||||
$headers = array(
|
|
||||||
'Authorization: ' . self::$token
|
|
||||||
);
|
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($bodyParams) {
|
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
||||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
|
|
||||||
$output = curl_exec($ch);
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
return $output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function delete($id, $token = '', array $queryParams = []): CustomRecordViewModel
|
||||||
* @param string $recordId
|
|
||||||
* @param array $queryParams
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getOne(string $recordId, array $queryParams = []): array
|
|
||||||
{
|
{
|
||||||
$output = $this->doRequest($this->url . "/api/collections/" . $this->collection . "/records/" . $recordId, 'GET');
|
$getParams = !empty($queryParams) ? http_build_query($queryParams) : "";
|
||||||
return json_decode($output, JSON_FORCE_OBJECT);
|
return new CustomRecordViewModel(json_decode($this->http->doRequest(
|
||||||
|
$this->client->getBaseUrl() . '/api/collections/test/records/' . $id . '?' . $getParams
|
||||||
|
, 'DELETE', [], $token), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function setClient(Client $client): void
|
||||||
* @param string $email
|
|
||||||
* @param string $password
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function authAsAdmin(string $email, string $password): string
|
|
||||||
{
|
{
|
||||||
$bodyParams['identity'] = $email;
|
$this->client = $client;
|
||||||
$bodyParams['password'] = $password;
|
}
|
||||||
$output = $this->doRequest($this->url . "/api/collections/_superusers/auth-with-password", 'POST', $bodyParams);
|
|
||||||
$token = json_decode($output, true)['token'];
|
|
||||||
if ($token) {
|
|
||||||
self::$token = $token;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $output;
|
public function getName(): string
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAuthToken(): ?string
|
||||||
|
{
|
||||||
|
return $this->client->token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHttp(HttpClient $httpClient): void
|
||||||
|
{
|
||||||
|
$this->http = $httpClient;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
31
src/HttpClient.php
Normal file
31
src/HttpClient.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace PocketBase;
|
||||||
|
|
||||||
|
class HttpClient
|
||||||
|
{
|
||||||
|
public function doRequest(string $url, string $method, $bodyParams = [], ?string $token = null): string
|
||||||
|
{
|
||||||
|
$ch = curl_init();
|
||||||
|
|
||||||
|
if ($token != '') {
|
||||||
|
$headers = array(
|
||||||
|
'Content-Type:application/json',
|
||||||
|
'Authorization: ' . $token
|
||||||
|
);
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($bodyParams) {
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
|
||||||
|
$output = curl_exec($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Pb;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class Settings
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private string $url;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private static string $token = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $url
|
|
||||||
* @param string $token
|
|
||||||
*/
|
|
||||||
public function __construct(string $url, string $token = '')
|
|
||||||
{
|
|
||||||
$this->url = $url;
|
|
||||||
self::$token = $token;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function authAsAdmin(string $email, string $password): void
|
|
||||||
{
|
|
||||||
$bodyParams['identity'] = $email;
|
|
||||||
$bodyParams['password'] = $password;
|
|
||||||
$output = $this->doRequest($this->url . "/api/collections/_superusers/auth-with-password", 'POST', $bodyParams);
|
|
||||||
self::$token = json_decode($output, true)['token'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function doRequest(string $url, string $method, $bodyParams = []): string
|
|
||||||
{
|
|
||||||
$ch = curl_init();
|
|
||||||
|
|
||||||
if (self::$token != '') {
|
|
||||||
$headers = array(
|
|
||||||
'Authorization: ' . self::$token
|
|
||||||
);
|
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($bodyParams) {
|
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
||||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
|
|
||||||
$output = curl_exec($ch);
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAll():array
|
|
||||||
{
|
|
||||||
return json_decode($this->doRequest($this->url . '/api/settings', 'GET', []), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update($bodyParam):array{
|
|
||||||
return json_decode($this->doRequest($this->url . '/api/settings', 'PATCH', json_encode($bodyParam)), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Pb;
|
|
||||||
|
|
||||||
class SuperUser
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
18
src/User.php
18
src/User.php
@@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Pb;
|
|
||||||
|
|
||||||
use DateTime;
|
|
||||||
|
|
||||||
class User
|
|
||||||
{
|
|
||||||
public string $avatar;
|
|
||||||
public string $collectionName;
|
|
||||||
public string $collectionId;
|
|
||||||
public bool $emailVisibility;
|
|
||||||
public DateTime $created;
|
|
||||||
public string $id;
|
|
||||||
public string $name;
|
|
||||||
public DateTime $updated;
|
|
||||||
public bool $verified;
|
|
||||||
}
|
|
||||||
15
src/viewModel/CustomRecordViewModel.php
Normal file
15
src/viewModel/CustomRecordViewModel.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace PocketBase\ViewModel;
|
||||||
|
|
||||||
|
class CustomRecordViewModel extends RecordViewModel
|
||||||
|
{
|
||||||
|
public function __construct(array $data)
|
||||||
|
{
|
||||||
|
foreach ($data as $key => $item){
|
||||||
|
$this->$key = $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::__construct($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
88
src/viewModel/RecordListViewModel.php
Normal file
88
src/viewModel/RecordListViewModel.php
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace PocketBase\ViewModel;
|
||||||
|
|
||||||
|
class RecordListViewModel extends RecordViewModel
|
||||||
|
{
|
||||||
|
private array $items;
|
||||||
|
private int $page;
|
||||||
|
private int $perPage;
|
||||||
|
private int $totalItems;
|
||||||
|
private int $totalPages;
|
||||||
|
|
||||||
|
public function __construct(array $data)
|
||||||
|
{
|
||||||
|
if (key_exists('items', $data)) {
|
||||||
|
$this->setItems($data['items']);
|
||||||
|
}
|
||||||
|
if (key_exists('page', $data)) {
|
||||||
|
$this->setPage($data['page']);
|
||||||
|
}
|
||||||
|
if (key_exists('perPage', $data)) {
|
||||||
|
$this->setPerPage($data['perPage']);
|
||||||
|
}
|
||||||
|
if (key_exists('totalItems', $data)) {
|
||||||
|
$this->setTotalItems($data['totalItems']);
|
||||||
|
}
|
||||||
|
if (key_exists('totalPages', $data)) {
|
||||||
|
$this->setTotalPages($data['totalPages']);
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::__construct($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTotalItems(int $totalItems): RecordListViewModel
|
||||||
|
{
|
||||||
|
$this->totalItems = $totalItems;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getItems(): array
|
||||||
|
{
|
||||||
|
return $this->items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setItems(array $items): RecordListViewModel
|
||||||
|
{
|
||||||
|
$this->items = $items;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPage(): int
|
||||||
|
{
|
||||||
|
return $this->page;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPage(int $page): RecordListViewModel
|
||||||
|
{
|
||||||
|
$this->page = $page;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPerPage(): int
|
||||||
|
{
|
||||||
|
return $this->perPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPerPage(int $perPage): RecordListViewModel
|
||||||
|
{
|
||||||
|
$this->perPage = $perPage;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTotalItems(): int
|
||||||
|
{
|
||||||
|
return $this->totalItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTotalPages(): int
|
||||||
|
{
|
||||||
|
return $this->totalPages;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTotalPages(int $totalPages): void
|
||||||
|
{
|
||||||
|
$this->totalPages = $totalPages;
|
||||||
|
}
|
||||||
|
}
|
||||||
86
src/viewModel/RecordViewModel.php
Normal file
86
src/viewModel/RecordViewModel.php
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace PocketBase\ViewModel;
|
||||||
|
|
||||||
|
class RecordViewModel
|
||||||
|
{
|
||||||
|
private string $collectionName;
|
||||||
|
private string $collectionId;
|
||||||
|
private string $created;
|
||||||
|
private string $updated;
|
||||||
|
private string $id;
|
||||||
|
|
||||||
|
public function __construct(array $data)
|
||||||
|
{
|
||||||
|
if(key_exists('id', $data)){
|
||||||
|
$this->setId($data['id']);
|
||||||
|
}
|
||||||
|
if(key_exists('updated', $data)){
|
||||||
|
$this->setUpdated($data['updated']);
|
||||||
|
}
|
||||||
|
if(key_exists('created', $data)){
|
||||||
|
$this->setCreated($data['created']);
|
||||||
|
}
|
||||||
|
if(key_exists('collectionName', $data)){
|
||||||
|
$this->setCollectionName($data['collectionName']);
|
||||||
|
}
|
||||||
|
if(key_exists('collectionId', $data)){
|
||||||
|
$this->setCollectionId($data['collectionId']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCollectionName(): string
|
||||||
|
{
|
||||||
|
return $this->collectionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCollectionName(string $collectionName): RecordViewModel
|
||||||
|
{
|
||||||
|
$this->collectionName = $collectionName;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCollectionId(): string
|
||||||
|
{
|
||||||
|
return $this->collectionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCollectionId(string $collectionId): RecordViewModel
|
||||||
|
{
|
||||||
|
$this->collectionId = $collectionId;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCreated(): string
|
||||||
|
{
|
||||||
|
return $this->created;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCreated(string $created): RecordViewModel
|
||||||
|
{
|
||||||
|
$this->created = $created;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUpdated(): string
|
||||||
|
{
|
||||||
|
return $this->updated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUpdated(string $updated): RecordViewModel
|
||||||
|
{
|
||||||
|
$this->updated = $updated;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getId(): string
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setId(string $id): RecordViewModel
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Pb\viewModels;
|
|
||||||
|
|
||||||
use DateTime;
|
|
||||||
|
|
||||||
class CollectionItem
|
|
||||||
{
|
|
||||||
public string $collectionName;
|
|
||||||
public string $collectionId;
|
|
||||||
public DateTime $created;
|
|
||||||
public string $id;
|
|
||||||
public DateTime $updated;
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Pb\viewModels;
|
|
||||||
|
|
||||||
class CollectionResponse
|
|
||||||
{
|
|
||||||
public array $items;
|
|
||||||
public int $page;
|
|
||||||
public int $perPage;
|
|
||||||
public int $totalItems;
|
|
||||||
public int $totalPages;
|
|
||||||
}
|
|
||||||
@@ -1,48 +1,46 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Pb\Client;
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
use Pb\Collection;
|
|
||||||
use Pb\Settings;
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use PocketBase\Client;
|
||||||
|
use PocketBase\Collection;
|
||||||
|
use PocketBase\HttpClient;
|
||||||
|
|
||||||
final class ClientTest extends TestCase
|
final class ClientTest extends TestCase
|
||||||
{
|
{
|
||||||
private Collection $collection;
|
|
||||||
private ?string $url;
|
|
||||||
|
|
||||||
protected function setUp(): void
|
private Collection $collection;
|
||||||
{
|
private ?Client $client = null;
|
||||||
$this->url = getenv('POCKETBASE_URL') ?: 'https://admin.pocketbase.dev';
|
public ?HttpClient $http = null;
|
||||||
$this->collection = new Collection($this->url, 'users');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_collection(): void
|
public function test_collection(): void
|
||||||
{
|
{
|
||||||
$pb = new Client($this->url);
|
$this->client = new Client();
|
||||||
|
$this->collection = $this->client->collection('_superusers');
|
||||||
$actual = $pb->collection('users');
|
$this->assertEquals(Collection::class, get_class($this->collection));
|
||||||
|
|
||||||
$this->assertEquals($actual, $this->collection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_settings(): void
|
public function test_authAsUser(): void
|
||||||
{
|
{
|
||||||
$pb = new Client($this->url);
|
$this->client = new Client();
|
||||||
|
$this->collection = $this->client->collection('users');
|
||||||
|
$this->collection->setPath('/api/collections/users/auth-with-password');
|
||||||
|
|
||||||
$actual = $pb->settings();
|
$token = $this->collection->authAsUser('admin@jonathan-martz.de', 'Password123');
|
||||||
|
$this->assertNotEmpty($token);
|
||||||
$this->assertEquals($actual, new Settings($this->url));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_setToken(){
|
/**
|
||||||
$token = 'test123';
|
* @throws \PHPUnit\Framework\MockObject\Exception
|
||||||
|
*/
|
||||||
|
// @sk
|
||||||
|
public function test_authAsAdmin(): void
|
||||||
|
{
|
||||||
|
$this->client = new Client();
|
||||||
|
$this->collection = $this->client->collection('_superusers');
|
||||||
|
$this->collection->setPath('/api/collections/' . $this->collection->getName() . '/auth-with-password');
|
||||||
|
|
||||||
$pb = new Client($this->url);
|
$token = $this->collection->authAsUser('admin@jonathan-martz.de', 'Password123');
|
||||||
$pb->setAuthToken($token);
|
$this->assertNotEmpty($token);
|
||||||
|
|
||||||
$this->assertEquals($token, $pb->getAuthToken());
|
|
||||||
$this->assertEquals($token, $pb->token);
|
|
||||||
$pb->token = 'test456';
|
|
||||||
$this->assertEquals('test456', $pb->getAuthToken());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Pb\Collection;
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
|
|
||||||
final class CollectionGetFirstListItemTest extends TestCase
|
|
||||||
{
|
|
||||||
private Collection $collection;
|
|
||||||
|
|
||||||
protected function setUp(): void
|
|
||||||
{
|
|
||||||
$url = getenv('POCKETBASE_URL') ?: 'https://admin.pocketbase.dev';
|
|
||||||
$this->collection = new Collection($url, 'users');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_getOne(): void
|
|
||||||
{
|
|
||||||
$id = '6588yk36406qqv1';
|
|
||||||
$actual = $this->collection->getFirstListItem('id="'.$id.'"');
|
|
||||||
$expected = [
|
|
||||||
'avatar' => '',
|
|
||||||
'collectionId' => '_pb_users_auth_',
|
|
||||||
'collectionName' => 'users',
|
|
||||||
'created' => '2025-01-21 21:22:47.002Z',
|
|
||||||
'emailVisibility' => false,
|
|
||||||
'id' => '6588yk36406qqv1',
|
|
||||||
'name' => 'Jonathan Martz',
|
|
||||||
'updated' => '2025-01-21 21:22:47.002Z',
|
|
||||||
'verified' => true
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
$this->assertCount(9, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_getOneWrongId(): void
|
|
||||||
{
|
|
||||||
$id = '6588yk36406qqva';
|
|
||||||
$actual = $this->collection->getFirstListItem('id="'.$id.'"');
|
|
||||||
$expected = [
|
|
||||||
'avatar' => '',
|
|
||||||
'collectionId' => '_pb_users_auth_',
|
|
||||||
'collectionName' => 'users',
|
|
||||||
'created' => '2025-01-21 21:22:47.002Z',
|
|
||||||
'emailVisibility' => false,
|
|
||||||
'id' => '6588yk36406qqv1',
|
|
||||||
'name' => 'Jonathan Martz',
|
|
||||||
'updated' => '2025-01-21 21:22:47.002Z',
|
|
||||||
'verified' => true
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
$this->assertCount(9,$actual);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Pb\Collection;
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
|
|
||||||
final class CollectionGetFullListTest extends TestCase
|
|
||||||
{
|
|
||||||
private string $url;
|
|
||||||
private Collection $collection;
|
|
||||||
|
|
||||||
protected function setUp(): void
|
|
||||||
{
|
|
||||||
$this->url = getenv('POCKETBASE_URL') ?: 'https://admin.pocketbase.dev';
|
|
||||||
$this->collection = new Collection($this->url, 'users');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_getFullList_gettingArrayWithOneUser(): void
|
|
||||||
{
|
|
||||||
$actual = $this->collection->getFullList([],100);
|
|
||||||
|
|
||||||
$this->assertArrayHasKey('items', $actual, 'Key "items" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('page', $actual, 'Key "page" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('perPage', $actual, 'Key "perPage" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('totalItems', $actual, 'Key "totalItems" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('totalPages', $actual, 'Key "totalPages" does not exist in the response.');
|
|
||||||
$this->assertCount(1, $actual['items'], 'Expected no items in the response.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
<?php declare(strict_types=1);
|
|
||||||
|
|
||||||
use Pb\Collection;
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
|
|
||||||
final class CollectionGetListTest extends TestCase
|
|
||||||
{
|
|
||||||
private string $url;
|
|
||||||
private Collection $collection;
|
|
||||||
|
|
||||||
protected function setUp(): void
|
|
||||||
{
|
|
||||||
$this->url = getenv('POCKETBASE_URL') ?: 'https://admin.pocketbase.dev';
|
|
||||||
$this->collection = new Collection($this->url, 'users');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_getList_gettingArrayWithOneItem(): void
|
|
||||||
{
|
|
||||||
$actual = $this->collection->getList(1, 10);
|
|
||||||
|
|
||||||
$this->assertArrayHasKey('items', $actual, 'Key "items" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('page', $actual, 'Key "page" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('perPage', $actual, 'Key "perPage" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('totalItems', $actual, 'Key "totalItems" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('totalPages', $actual, 'Key "totalPages" does not exist in the response.');
|
|
||||||
$this->assertCount(1, $actual['items'], 'Expected no items in the response.');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_getListWithContainsMartz(): void
|
|
||||||
{
|
|
||||||
$actual = $this->collection->getList(1, 10, ['filter'=>'name~"%Martz%"']);
|
|
||||||
|
|
||||||
$this->assertArrayHasKey('items', $actual, 'Key "items" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('page', $actual, 'Key "page" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('perPage', $actual, 'Key "perPage" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('totalItems', $actual, 'Key "totalItems" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('totalPages', $actual, 'Key "totalPages" does not exist in the response.');
|
|
||||||
$this->assertCount(1, $actual['items'], 'Expected no items in the response.');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_getListStartsWithMartz(): void
|
|
||||||
{
|
|
||||||
$actual = $this->collection->getList(1, 10, ['filter'=>'name~"Martz%"']);
|
|
||||||
|
|
||||||
$this->assertArrayHasKey('items', $actual, 'Key "items" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('page', $actual, 'Key "page" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('perPage', $actual, 'Key "perPage" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('totalItems', $actual, 'Key "totalItems" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('totalPages', $actual, 'Key "totalPages" does not exist in the response.');
|
|
||||||
$this->assertCount(0, $actual['items'], 'Expected no items in the response.');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_getListStartWithJonathan(): void
|
|
||||||
{
|
|
||||||
$actual = $this->collection->getList(1, 10, ['filter'=>'name~"Jonathan%"']);
|
|
||||||
|
|
||||||
$this->assertArrayHasKey('items', $actual, 'Key "items" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('page', $actual, 'Key "page" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('perPage', $actual, 'Key "perPage" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('totalItems', $actual, 'Key "totalItems" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('totalPages', $actual, 'Key "totalPages" does not exist in the response.');
|
|
||||||
$this->assertCount(1, $actual['items'], 'Expected no items in the response.');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_getListCheckingDifferentName(): void
|
|
||||||
{
|
|
||||||
$actual = $this->collection->getList(1, 10, ['filter'=>'name~"%Sibylle%"']);
|
|
||||||
|
|
||||||
$this->assertArrayHasKey('items', $actual, 'Key "items" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('page', $actual, 'Key "page" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('perPage', $actual, 'Key "perPage" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('totalItems', $actual, 'Key "totalItems" does not exist in the response.');
|
|
||||||
$this->assertArrayHasKey('totalPages', $actual, 'Key "totalPages" does not exist in the response.');
|
|
||||||
$this->assertCount(0, $actual['items'], 'Expected no items in the response.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Pb\Collection;
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
|
|
||||||
final class CollectionGetOneTest extends TestCase
|
|
||||||
{
|
|
||||||
private string $url;
|
|
||||||
private Collection $collection;
|
|
||||||
|
|
||||||
protected function setUp(): void
|
|
||||||
{
|
|
||||||
$this->url = getenv('POCKETBASE_URL') ?: 'https://admin.pocketbase.dev';
|
|
||||||
$this->collection = new Collection($this->url, 'users');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_getOne(): void
|
|
||||||
{
|
|
||||||
$id = '6588yk36406qqv1';
|
|
||||||
$actual = $this->collection->getOne($id);
|
|
||||||
$expected = [
|
|
||||||
'avatar' => '',
|
|
||||||
'collectionId' => '_pb_users_auth_',
|
|
||||||
'collectionName' => 'users',
|
|
||||||
'created' => '2025-01-21 21:22:47.002Z',
|
|
||||||
'emailVisibility' => false,
|
|
||||||
'id' => '6588yk36406qqv1',
|
|
||||||
'name' => 'Jonathan Martz',
|
|
||||||
'updated' => '2025-01-21 21:22:47.002Z',
|
|
||||||
'verified' => true
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
$this->assertCount(9, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_getOneWrongId(): void
|
|
||||||
{
|
|
||||||
$id = '6588yk36406qqva';
|
|
||||||
$actual = $this->collection->getOne($id);
|
|
||||||
$expected = [
|
|
||||||
'data' => [],
|
|
||||||
'message' => "The requested resource wasn't found.",
|
|
||||||
'status' => 404,
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
$this->assertCount(3,$actual);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
174
tests/CollectionTest.php
Normal file
174
tests/CollectionTest.php
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use PocketBase\ViewModel\CustomRecordViewModel;
|
||||||
|
use PocketBase\ViewModel\RecordListViewModel;
|
||||||
|
use PocketBase\ViewModel\RecordViewModel as RecordViewModelAlias;
|
||||||
|
use PocketBase\Client as Client;
|
||||||
|
use PocketBase\Collection as Collection;
|
||||||
|
use PocketBase\HttpClient as HttpClient;
|
||||||
|
|
||||||
|
final class CollectionTest extends TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
private Collection $collection;
|
||||||
|
private ?Client $client = null;
|
||||||
|
public ?HttpClient $http = null;
|
||||||
|
|
||||||
|
public string $name = '';
|
||||||
|
|
||||||
|
public function test_getFullList_empty()
|
||||||
|
{
|
||||||
|
$this->collection = new Collection(null, 'users');
|
||||||
|
$this->collection
|
||||||
|
->setClient(new Client('http://localhost:7090'));
|
||||||
|
$this->collection->setPath("/api/collections/" . $this->collection->getName() . "/records");
|
||||||
|
$data = $this->collection
|
||||||
|
->getFullList(10, []);
|
||||||
|
|
||||||
|
$this->assertEquals(RecordListViewModel::class, get_class($data));
|
||||||
|
$this->assertCount(0, $data->getItems());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_getFullList_ownUser()
|
||||||
|
{
|
||||||
|
$this->collection = new Collection(null, 'users');
|
||||||
|
$token = $this->collection->authAsUser('admin@jonathan-martz.de', 'Password123');
|
||||||
|
|
||||||
|
$this->client = new Client('http://localhost:7090');
|
||||||
|
$this->client->setToken($token);
|
||||||
|
$this->collection->setPath('/api/collections/' . $this->collection->getName() . '/records');
|
||||||
|
$this->collection->setClient($this->client);
|
||||||
|
|
||||||
|
$data = $this->collection->getFullList(10, []);
|
||||||
|
$this->assertEquals(RecordListViewModel::class, get_class($data));
|
||||||
|
$this->assertCount(1, $data->getItems());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_getFullList_ownAdmin()
|
||||||
|
{
|
||||||
|
$this->collection = new Collection(null, 'users');
|
||||||
|
$token = $this->collection->authAsAdmin('admin@jonathan-martz.de', 'Password123');
|
||||||
|
|
||||||
|
$this->client = new Client('http://localhost:7090');
|
||||||
|
$this->client->setToken($token);
|
||||||
|
$this->collection->setPath('/api/collections/' . $this->collection->getName() . '/records');
|
||||||
|
$this->collection->setClient($this->client);
|
||||||
|
|
||||||
|
$data = $this->collection->getFullList(10, []);
|
||||||
|
$this->assertEquals(RecordListViewModel::class, get_class($data));
|
||||||
|
$this->assertCount(2, $data->getItems());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_create_record(): void
|
||||||
|
{
|
||||||
|
$this->client = new \PocketBase\Client(null);
|
||||||
|
$this->collection = $this->client->collection('users');
|
||||||
|
$this->collection->setPath('/api/collections/users/records');
|
||||||
|
|
||||||
|
$record = $this->collection->create([
|
||||||
|
'email' => 'admin@jonathan-martz.de',
|
||||||
|
'password' => 'Password123',
|
||||||
|
'passwordConfirm' => 'Password123',
|
||||||
|
]);
|
||||||
|
$this->assertEquals(CustomRecordViewModel::class, get_class($record));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_update_record(): void
|
||||||
|
{
|
||||||
|
$this->client = new \PocketBase\Client(null);
|
||||||
|
$this->collection = $this->client->collection('users');
|
||||||
|
$token = $this->collection->authAsUser('admin@jonathan-martz.de', 'Password123');
|
||||||
|
|
||||||
|
$this->client->setToken($token);
|
||||||
|
$this->collection = $this->client->collection('test');
|
||||||
|
$this->collection->setClient($this->client);
|
||||||
|
$this->collection->setPath('/api/collections/test/records/');
|
||||||
|
|
||||||
|
try {
|
||||||
|
$record = $this->collection->update('ss05u9mnegvplds', [
|
||||||
|
'name' => 'Test123456'
|
||||||
|
], $token);
|
||||||
|
} catch (Exception $exception) {
|
||||||
|
$this->fail('Exception: ' . $exception->getMessage());
|
||||||
|
}
|
||||||
|
$this->assertEquals(RecordViewModelAlias::class, get_class($record));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_getone_record(): void
|
||||||
|
{
|
||||||
|
$this->client = new \PocketBase\Client(null);
|
||||||
|
$this->collection = $this->client->collection('users');
|
||||||
|
$token = $this->collection->authAsUser('admin@jonathan-martz.de', 'Password123');
|
||||||
|
|
||||||
|
$this->client->setToken($token);
|
||||||
|
$this->collection = $this->client->collection('test');
|
||||||
|
$this->collection->setClient($this->client);
|
||||||
|
$this->collection->setPath('/api/collections/test/records/');
|
||||||
|
|
||||||
|
try {
|
||||||
|
$record = $this->collection->getOne('ss05u9mnegvplds', $token);
|
||||||
|
} catch (Exception $exception) {
|
||||||
|
$this->fail('Exception: ' . $exception->getMessage());
|
||||||
|
}
|
||||||
|
$this->assertEquals(CustomRecordViewModel::class, get_class($record));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_getlist_record(): void
|
||||||
|
{
|
||||||
|
$this->client = new \PocketBase\Client(null);
|
||||||
|
$this->collection = $this->client->collection('users');
|
||||||
|
$token = $this->collection->authAsUser('admin@jonathan-martz.de', 'Password123');
|
||||||
|
|
||||||
|
$this->client->setToken($token);
|
||||||
|
$this->collection = $this->client->collection('test');
|
||||||
|
$this->collection->setClient($this->client);
|
||||||
|
$this->collection->setPath('/api/collections/users/records/');
|
||||||
|
|
||||||
|
try {
|
||||||
|
$record = $this->collection->getList(1, 10);
|
||||||
|
} catch (Exception $exception) {
|
||||||
|
$this->fail('Exception: ' . $exception->getMessage());
|
||||||
|
}
|
||||||
|
$this->assertEquals(RecordListViewModel::class, get_class($record));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_delete_record(): void
|
||||||
|
{
|
||||||
|
$this->client = new \PocketBase\Client(null);
|
||||||
|
$this->collection = $this->client->collection('users');
|
||||||
|
$token = $this->collection->authAsUser('admin@jonathan-martz.de', 'Password123');
|
||||||
|
|
||||||
|
$this->client->setToken($token);
|
||||||
|
$this->collection = $this->client->collection('test');
|
||||||
|
$this->collection->setClient($this->client);
|
||||||
|
$this->collection->setPath('/api/collections/test/records/');
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->collection->delete('65uahqp4wicc88l');
|
||||||
|
} catch (Exception $exception) {
|
||||||
|
$this->fail('Exception: ' . $exception->getMessage());
|
||||||
|
}
|
||||||
|
$this->assertTrue(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_upload_record(): void
|
||||||
|
{
|
||||||
|
$this->markTestSkipped('todo');
|
||||||
|
$this->client = new \PocketBase\Client(null);
|
||||||
|
$this->collection = $this->client->collection('users');
|
||||||
|
$token = $this->collection->authAsUser('admin@jonathan-martz.de', 'Password123');
|
||||||
|
|
||||||
|
$this->client->setToken($token);
|
||||||
|
$this->collection = $this->client->collection('test');
|
||||||
|
$this->collection->setPath('/api/collections/users/records/');
|
||||||
|
$this->collection->setClient($this->client);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$record = $this->collection->getList(1, 10);
|
||||||
|
} catch (Exception $exception) {
|
||||||
|
$this->fail('Exception: ' . $exception->getMessage());
|
||||||
|
}
|
||||||
|
$this->assertEquals(RecordListViewModel::class, get_class($record));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user