mirror of
https://github.com/jonathan-martz/pocketbase-php-sdk.git
synced 2026-04-03 07:27:42 +00:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af1bbab9e2 | ||
|
|
e71299b013 | ||
|
|
76038f8bfb | ||
|
|
f9911ffc29 | ||
|
|
28df3f28e7 | ||
|
|
9b1ded7968 | ||
|
|
7c2253c896 | ||
|
|
d92bff0357 | ||
|
|
75354764d8 | ||
|
|
59a4edd7a5 | ||
|
|
f3f4e84688 | ||
|
|
e2f2ee4be0 | ||
|
|
d733fda627 | ||
|
|
cbd0438d22 | ||
|
|
9625de8b52 |
2
.github/workflows/tdd.yml
vendored
2
.github/workflows/tdd.yml
vendored
@@ -6,7 +6,7 @@ on:
|
||||
pull_request:
|
||||
branches: [master]
|
||||
schedule:
|
||||
- cron: '0 * * * *'
|
||||
- cron: '0 17 * * *'
|
||||
|
||||
jobs:
|
||||
run-mailer:
|
||||
|
||||
10
README.md
10
README.md
@@ -4,6 +4,12 @@
|
||||
##### This Repository are in active Development
|
||||
***
|
||||
|
||||
***
|
||||
### Gitlab is the one for Packagist, but they should both be up to Date.
|
||||
##### Github: https://github.com/jonathan-martz/pocketbase-php-sdk/
|
||||
##### Gitlab: https://gitlab.jonathan-martz.de/softwareentwicklung/pocketbase-php-sdk
|
||||
***
|
||||
|
||||
``` bash
|
||||
composer require jonathan-martz/pocketbase-php-sdk
|
||||
```
|
||||
@@ -11,8 +17,8 @@ composer require jonathan-martz/pocketbase-php-sdk
|
||||
``` php
|
||||
// Example init and use
|
||||
use \Pb\Client as pb;
|
||||
$pb = new pb('https://backend-shop.mkay.dev');
|
||||
var_dump($pb->collection('countries')->getList());
|
||||
$pb = new pb('https://admin.pocketbase.dev');
|
||||
var_dump($pb->collection('users')->getList());
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
275
composer.lock
generated
275
composer.lock
generated
@@ -9,16 +9,16 @@
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "myclabs/deep-copy",
|
||||
"version": "1.12.1",
|
||||
"version": "1.13.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/myclabs/DeepCopy.git",
|
||||
"reference": "123267b2c49fbf30d78a7b2d333f6be754b94845"
|
||||
"reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/123267b2c49fbf30d78a7b2d333f6be754b94845",
|
||||
"reference": "123267b2c49fbf30d78a7b2d333f6be754b94845",
|
||||
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a",
|
||||
"reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -57,7 +57,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/myclabs/DeepCopy/issues",
|
||||
"source": "https://github.com/myclabs/DeepCopy/tree/1.12.1"
|
||||
"source": "https://github.com/myclabs/DeepCopy/tree/1.13.4"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -65,20 +65,20 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-11-08T17:47:46+00:00"
|
||||
"time": "2025-08-01T08:46:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nikic/php-parser",
|
||||
"version": "v5.4.0",
|
||||
"version": "v5.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nikic/PHP-Parser.git",
|
||||
"reference": "447a020a1f875a434d62f2a401f53b82a396e494"
|
||||
"reference": "dca41cd15c2ac9d055ad70dbfd011130757d1f82"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/447a020a1f875a434d62f2a401f53b82a396e494",
|
||||
"reference": "447a020a1f875a434d62f2a401f53b82a396e494",
|
||||
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/dca41cd15c2ac9d055ad70dbfd011130757d1f82",
|
||||
"reference": "dca41cd15c2ac9d055ad70dbfd011130757d1f82",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -97,7 +97,7 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
"dev-master": "5.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -121,9 +121,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/nikic/PHP-Parser/issues",
|
||||
"source": "https://github.com/nikic/PHP-Parser/tree/v5.4.0"
|
||||
"source": "https://github.com/nikic/PHP-Parser/tree/v5.7.0"
|
||||
},
|
||||
"time": "2024-12-30T11:07:19+00:00"
|
||||
"time": "2025-12-06T11:56:16+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phar-io/manifest",
|
||||
@@ -245,35 +245,35 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
"version": "11.0.8",
|
||||
"version": "11.0.12",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
||||
"reference": "418c59fd080954f8c4aa5631d9502ecda2387118"
|
||||
"reference": "2c1ed04922802c15e1de5d7447b4856de949cf56"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/418c59fd080954f8c4aa5631d9502ecda2387118",
|
||||
"reference": "418c59fd080954f8c4aa5631d9502ecda2387118",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2c1ed04922802c15e1de5d7447b4856de949cf56",
|
||||
"reference": "2c1ed04922802c15e1de5d7447b4856de949cf56",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-dom": "*",
|
||||
"ext-libxml": "*",
|
||||
"ext-xmlwriter": "*",
|
||||
"nikic/php-parser": "^5.3.1",
|
||||
"nikic/php-parser": "^5.7.0",
|
||||
"php": ">=8.2",
|
||||
"phpunit/php-file-iterator": "^5.1.0",
|
||||
"phpunit/php-text-template": "^4.0.1",
|
||||
"sebastian/code-unit-reverse-lookup": "^4.0.1",
|
||||
"sebastian/complexity": "^4.0.1",
|
||||
"sebastian/environment": "^7.2.0",
|
||||
"sebastian/environment": "^7.2.1",
|
||||
"sebastian/lines-of-code": "^3.0.1",
|
||||
"sebastian/version": "^5.0.2",
|
||||
"theseer/tokenizer": "^1.2.3"
|
||||
"theseer/tokenizer": "^1.3.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^11.5.0"
|
||||
"phpunit/phpunit": "^11.5.46"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-pcov": "PHP extension that provides line coverage",
|
||||
@@ -311,40 +311,52 @@
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
|
||||
"security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy",
|
||||
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/11.0.8"
|
||||
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/11.0.12"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/sebastianbergmann",
|
||||
"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": "2024-12-11T12:34:27+00:00"
|
||||
"time": "2025-12-24T07:01:01+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-file-iterator",
|
||||
"version": "5.1.0",
|
||||
"version": "5.1.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
|
||||
"reference": "118cfaaa8bc5aef3287bf315b6060b1174754af6"
|
||||
"reference": "2f3a64888c814fc235386b7387dd5b5ed92ad903"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/118cfaaa8bc5aef3287bf315b6060b1174754af6",
|
||||
"reference": "118cfaaa8bc5aef3287bf315b6060b1174754af6",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/2f3a64888c814fc235386b7387dd5b5ed92ad903",
|
||||
"reference": "2f3a64888c814fc235386b7387dd5b5ed92ad903",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^11.0"
|
||||
"phpunit/phpunit": "^11.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "5.0-dev"
|
||||
"dev-main": "5.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -372,15 +384,27 @@
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/php-file-iterator/issues",
|
||||
"security": "https://github.com/sebastianbergmann/php-file-iterator/security/policy",
|
||||
"source": "https://github.com/sebastianbergmann/php-file-iterator/tree/5.1.0"
|
||||
"source": "https://github.com/sebastianbergmann/php-file-iterator/tree/5.1.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/sebastianbergmann",
|
||||
"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": "2024-08-27T05:02:59+00:00"
|
||||
"time": "2026-02-02T13:52:54+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-invoker",
|
||||
@@ -568,16 +592,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "11.5.2",
|
||||
"version": "11.5.51",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "153d0531b9f7e883c5053160cad6dd5ac28140b3"
|
||||
"reference": "ad14159f92910b0f0e3928c13e9b2077529de091"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/153d0531b9f7e883c5053160cad6dd5ac28140b3",
|
||||
"reference": "153d0531b9f7e883c5053160cad6dd5ac28140b3",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ad14159f92910b0f0e3928c13e9b2077529de091",
|
||||
"reference": "ad14159f92910b0f0e3928c13e9b2077529de091",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -587,24 +611,25 @@
|
||||
"ext-mbstring": "*",
|
||||
"ext-xml": "*",
|
||||
"ext-xmlwriter": "*",
|
||||
"myclabs/deep-copy": "^1.12.1",
|
||||
"myclabs/deep-copy": "^1.13.4",
|
||||
"phar-io/manifest": "^2.0.4",
|
||||
"phar-io/version": "^3.2.1",
|
||||
"php": ">=8.2",
|
||||
"phpunit/php-code-coverage": "^11.0.8",
|
||||
"phpunit/php-file-iterator": "^5.1.0",
|
||||
"phpunit/php-code-coverage": "^11.0.12",
|
||||
"phpunit/php-file-iterator": "^5.1.1",
|
||||
"phpunit/php-invoker": "^5.0.1",
|
||||
"phpunit/php-text-template": "^4.0.1",
|
||||
"phpunit/php-timer": "^7.0.1",
|
||||
"sebastian/cli-parser": "^3.0.2",
|
||||
"sebastian/code-unit": "^3.0.2",
|
||||
"sebastian/comparator": "^6.2.1",
|
||||
"sebastian/code-unit": "^3.0.3",
|
||||
"sebastian/comparator": "^6.3.3",
|
||||
"sebastian/diff": "^6.0.2",
|
||||
"sebastian/environment": "^7.2.0",
|
||||
"sebastian/exporter": "^6.3.0",
|
||||
"sebastian/environment": "^7.2.1",
|
||||
"sebastian/exporter": "^6.3.2",
|
||||
"sebastian/global-state": "^7.0.2",
|
||||
"sebastian/object-enumerator": "^6.0.1",
|
||||
"sebastian/type": "^5.1.0",
|
||||
"sebastian/recursion-context": "^6.0.3",
|
||||
"sebastian/type": "^5.1.3",
|
||||
"sebastian/version": "^5.0.2",
|
||||
"staabm/side-effects-detector": "^1.0.5"
|
||||
},
|
||||
@@ -649,7 +674,7 @@
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
|
||||
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
|
||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.2"
|
||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.51"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -660,12 +685,20 @@
|
||||
"url": "https://github.com/sebastianbergmann",
|
||||
"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",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-12-21T05:51:08+00:00"
|
||||
"time": "2026-02-05T07:59:30+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/cli-parser",
|
||||
@@ -726,16 +759,16 @@
|
||||
},
|
||||
{
|
||||
"name": "sebastian/code-unit",
|
||||
"version": "3.0.2",
|
||||
"version": "3.0.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/code-unit.git",
|
||||
"reference": "ee88b0cdbe74cf8dd3b54940ff17643c0d6543ca"
|
||||
"reference": "54391c61e4af8078e5b276ab082b6d3c54c9ad64"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/ee88b0cdbe74cf8dd3b54940ff17643c0d6543ca",
|
||||
"reference": "ee88b0cdbe74cf8dd3b54940ff17643c0d6543ca",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/54391c61e4af8078e5b276ab082b6d3c54c9ad64",
|
||||
"reference": "54391c61e4af8078e5b276ab082b6d3c54c9ad64",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -771,7 +804,7 @@
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/code-unit/issues",
|
||||
"security": "https://github.com/sebastianbergmann/code-unit/security/policy",
|
||||
"source": "https://github.com/sebastianbergmann/code-unit/tree/3.0.2"
|
||||
"source": "https://github.com/sebastianbergmann/code-unit/tree/3.0.3"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -779,7 +812,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2024-12-12T09:59:06+00:00"
|
||||
"time": "2025-03-19T07:56:08+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/code-unit-reverse-lookup",
|
||||
@@ -839,16 +872,16 @@
|
||||
},
|
||||
{
|
||||
"name": "sebastian/comparator",
|
||||
"version": "6.3.0",
|
||||
"version": "6.3.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/comparator.git",
|
||||
"reference": "d4e47a769525c4dd38cea90e5dcd435ddbbc7115"
|
||||
"reference": "2c95e1e86cb8dd41beb8d502057d1081ccc8eca9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/d4e47a769525c4dd38cea90e5dcd435ddbbc7115",
|
||||
"reference": "d4e47a769525c4dd38cea90e5dcd435ddbbc7115",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2c95e1e86cb8dd41beb8d502057d1081ccc8eca9",
|
||||
"reference": "2c95e1e86cb8dd41beb8d502057d1081ccc8eca9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -867,7 +900,7 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "6.2-dev"
|
||||
"dev-main": "6.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -907,15 +940,27 @@
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/comparator/issues",
|
||||
"security": "https://github.com/sebastianbergmann/comparator/security/policy",
|
||||
"source": "https://github.com/sebastianbergmann/comparator/tree/6.3.0"
|
||||
"source": "https://github.com/sebastianbergmann/comparator/tree/6.3.3"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/sebastianbergmann",
|
||||
"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": "2025-01-06T10:28:19+00:00"
|
||||
"time": "2026-01-24T09:26:40+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/complexity",
|
||||
@@ -1044,23 +1089,23 @@
|
||||
},
|
||||
{
|
||||
"name": "sebastian/environment",
|
||||
"version": "7.2.0",
|
||||
"version": "7.2.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/environment.git",
|
||||
"reference": "855f3ae0ab316bbafe1ba4e16e9f3c078d24a0c5"
|
||||
"reference": "a5c75038693ad2e8d4b6c15ba2403532647830c4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/855f3ae0ab316bbafe1ba4e16e9f3c078d24a0c5",
|
||||
"reference": "855f3ae0ab316bbafe1ba4e16e9f3c078d24a0c5",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/a5c75038693ad2e8d4b6c15ba2403532647830c4",
|
||||
"reference": "a5c75038693ad2e8d4b6c15ba2403532647830c4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^11.0"
|
||||
"phpunit/phpunit": "^11.3"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-posix": "*"
|
||||
@@ -1096,28 +1141,40 @@
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/environment/issues",
|
||||
"security": "https://github.com/sebastianbergmann/environment/security/policy",
|
||||
"source": "https://github.com/sebastianbergmann/environment/tree/7.2.0"
|
||||
"source": "https://github.com/sebastianbergmann/environment/tree/7.2.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/sebastianbergmann",
|
||||
"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": "2024-07-03T04:54:44+00:00"
|
||||
"time": "2025-05-21T11:55:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/exporter",
|
||||
"version": "6.3.0",
|
||||
"version": "6.3.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/exporter.git",
|
||||
"reference": "3473f61172093b2da7de1fb5782e1f24cc036dc3"
|
||||
"reference": "70a298763b40b213ec087c51c739efcaa90bcd74"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/3473f61172093b2da7de1fb5782e1f24cc036dc3",
|
||||
"reference": "3473f61172093b2da7de1fb5782e1f24cc036dc3",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/70a298763b40b213ec087c51c739efcaa90bcd74",
|
||||
"reference": "70a298763b40b213ec087c51c739efcaa90bcd74",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1131,7 +1188,7 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "6.1-dev"
|
||||
"dev-main": "6.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -1174,15 +1231,27 @@
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/exporter/issues",
|
||||
"security": "https://github.com/sebastianbergmann/exporter/security/policy",
|
||||
"source": "https://github.com/sebastianbergmann/exporter/tree/6.3.0"
|
||||
"source": "https://github.com/sebastianbergmann/exporter/tree/6.3.2"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/sebastianbergmann",
|
||||
"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": "2024-12-05T09:17:50+00:00"
|
||||
"time": "2025-09-24T06:12:51+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/global-state",
|
||||
@@ -1420,23 +1489,23 @@
|
||||
},
|
||||
{
|
||||
"name": "sebastian/recursion-context",
|
||||
"version": "6.0.2",
|
||||
"version": "6.0.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/recursion-context.git",
|
||||
"reference": "694d156164372abbd149a4b85ccda2e4670c0e16"
|
||||
"reference": "f6458abbf32a6c8174f8f26261475dc133b3d9dc"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/694d156164372abbd149a4b85ccda2e4670c0e16",
|
||||
"reference": "694d156164372abbd149a4b85ccda2e4670c0e16",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/f6458abbf32a6c8174f8f26261475dc133b3d9dc",
|
||||
"reference": "f6458abbf32a6c8174f8f26261475dc133b3d9dc",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^11.0"
|
||||
"phpunit/phpunit": "^11.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
@@ -1472,28 +1541,40 @@
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/recursion-context/issues",
|
||||
"security": "https://github.com/sebastianbergmann/recursion-context/security/policy",
|
||||
"source": "https://github.com/sebastianbergmann/recursion-context/tree/6.0.2"
|
||||
"source": "https://github.com/sebastianbergmann/recursion-context/tree/6.0.3"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/sebastianbergmann",
|
||||
"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": "2024-07-03T05:10:34+00:00"
|
||||
"time": "2025-08-13T04:42:22+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/type",
|
||||
"version": "5.1.0",
|
||||
"version": "5.1.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/type.git",
|
||||
"reference": "461b9c5da241511a2a0e8f240814fb23ce5c0aac"
|
||||
"reference": "f77d2d4e78738c98d9a68d2596fe5e8fa380f449"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/461b9c5da241511a2a0e8f240814fb23ce5c0aac",
|
||||
"reference": "461b9c5da241511a2a0e8f240814fb23ce5c0aac",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/f77d2d4e78738c98d9a68d2596fe5e8fa380f449",
|
||||
"reference": "f77d2d4e78738c98d9a68d2596fe5e8fa380f449",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1529,15 +1610,27 @@
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/type/issues",
|
||||
"security": "https://github.com/sebastianbergmann/type/security/policy",
|
||||
"source": "https://github.com/sebastianbergmann/type/tree/5.1.0"
|
||||
"source": "https://github.com/sebastianbergmann/type/tree/5.1.3"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/sebastianbergmann",
|
||||
"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": "2024-09-17T13:12:04+00:00"
|
||||
"time": "2025-08-09T06:55:48+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/version",
|
||||
@@ -1647,16 +1740,16 @@
|
||||
},
|
||||
{
|
||||
"name": "theseer/tokenizer",
|
||||
"version": "1.2.3",
|
||||
"version": "1.3.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/theseer/tokenizer.git",
|
||||
"reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2"
|
||||
"reference": "b7489ce515e168639d17feec34b8847c326b0b3c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2",
|
||||
"reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2",
|
||||
"url": "https://api.github.com/repos/theseer/tokenizer/zipball/b7489ce515e168639d17feec34b8847c326b0b3c",
|
||||
"reference": "b7489ce515e168639d17feec34b8847c326b0b3c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1685,7 +1778,7 @@
|
||||
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
|
||||
"support": {
|
||||
"issues": "https://github.com/theseer/tokenizer/issues",
|
||||
"source": "https://github.com/theseer/tokenizer/tree/1.2.3"
|
||||
"source": "https://github.com/theseer/tokenizer/tree/1.3.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -1693,7 +1786,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2024-03-03T12:36:25+00:00"
|
||||
"time": "2025-11-17T20:03:58+00:00"
|
||||
},
|
||||
{
|
||||
"name": "tomasvotruba/phpunit-json-result-printer",
|
||||
|
||||
14
mailer.go
14
mailer.go
@@ -34,7 +34,7 @@ func main() {
|
||||
}
|
||||
|
||||
// Format the date as YYYY-MM-DD
|
||||
currentDate := now.Format("01-02-2006")
|
||||
currentDate := now.Format("01.02.2006")
|
||||
|
||||
recipient := "support@jonathan-martz.de"
|
||||
subject := "PHPUnit - PocketBase PHP SDK - " + currentDate
|
||||
@@ -56,8 +56,6 @@ func main() {
|
||||
log.Fatal("PHPUnit output is empty. Please check your configuration.")
|
||||
}
|
||||
|
||||
fmt.Println(output.String())
|
||||
|
||||
// Parse the JSON output
|
||||
var result map[string]interface{}
|
||||
if err := json.Unmarshal(output.Bytes(), &result); err != nil {
|
||||
@@ -70,6 +68,13 @@ fmt.Println(output.String())
|
||||
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 {
|
||||
@@ -93,4 +98,7 @@ fmt.Println(output.String())
|
||||
}
|
||||
|
||||
log.Println("Test results sent to", recipient)
|
||||
} else {
|
||||
log.Println("No failures detected. No email sent.")
|
||||
}
|
||||
}
|
||||
46
src/AuthTest.php
Normal file
46
src/AuthTest.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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']);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace Pb;
|
||||
class Client
|
||||
{
|
||||
private string $url;
|
||||
public string $token = '';
|
||||
|
||||
public function __construct(string $url)
|
||||
{
|
||||
@@ -13,11 +14,21 @@ class Client
|
||||
|
||||
public function collection(string $collection): Collection
|
||||
{
|
||||
return new Collection($this->url ,$collection);
|
||||
return new Collection($this->url ,$collection, $this->token);
|
||||
}
|
||||
|
||||
public function settings(): Settings
|
||||
{
|
||||
return new Settings($this->url);
|
||||
return new Settings($this->url, $this->token);
|
||||
}
|
||||
|
||||
public function setAuthToken(string $token): void
|
||||
{
|
||||
$this->token = $token;
|
||||
}
|
||||
|
||||
public function getAuthToken(): string
|
||||
{
|
||||
return $this->token;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,15 @@ class Collection
|
||||
/**
|
||||
* @param string $url
|
||||
* @param string $collection
|
||||
* @param string $token
|
||||
*/
|
||||
public function __construct(string $url, string $collection)
|
||||
public function __construct(string $url, string $collection, string $token = '')
|
||||
{
|
||||
$this->url = $url;
|
||||
$this->collection = $collection;
|
||||
if (!empty($token)) {
|
||||
self::$token = $token;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,12 +81,13 @@ class Collection
|
||||
* @param string $password
|
||||
* @return void
|
||||
*/
|
||||
public function authAsUser(string $email, string $password)
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,7 +124,7 @@ class Collection
|
||||
*/
|
||||
public function create(array $bodyParams = [], array $queryParams = []): string
|
||||
{
|
||||
return $this->doRequest($this->url . "/api/collections/" . $this->collection . "/records", 'POST', json_encode($bodyParams));
|
||||
return $this->doRequest($this->url . "/api/collections/" . $this->collection . "/records", 'POST', $bodyParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +136,7 @@ class Collection
|
||||
public function update(string $recordId, array $bodyParams = [], array $queryParams = []): void
|
||||
{
|
||||
// Todo bodyParams equals json, currently workaround
|
||||
$this->doRequest($this->url . "/api/collections/" . $this->collection . "/records/" . $recordId, 'PATCH', json_encode($bodyParams));
|
||||
$this->doRequest($this->url . "/api/collections/" . $this->collection . "/records/" . $recordId, 'PATCH', $bodyParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,11 +157,12 @@ class Collection
|
||||
*/
|
||||
public function doRequest(string $url, string $method, $bodyParams = []): string
|
||||
{
|
||||
// TODO move doRequestIntoService ?
|
||||
// TODO replace curl with HttpClient
|
||||
$ch = curl_init();
|
||||
|
||||
if (self::$token != '') {
|
||||
$headers = array(
|
||||
'Content-Type:application/json',
|
||||
'Authorization: ' . self::$token
|
||||
);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
@@ -191,11 +197,16 @@ class Collection
|
||||
* @param string $password
|
||||
* @return void
|
||||
*/
|
||||
public function authAsAdmin(string $email, string $password): void
|
||||
public function authAsAdmin(string $email, string $password): string
|
||||
{
|
||||
$bodyParams['identity'] = $email;
|
||||
$bodyParams['password'] = $password;
|
||||
$output = $this->doRequest($this->url . "/api/admins/auth-with-password", 'POST', $bodyParams);
|
||||
self::$token = json_decode($output, true)['token'];
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,34 +19,28 @@ class Settings
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @param string $collection
|
||||
* @param string $token
|
||||
*/
|
||||
public function __construct(string $url)
|
||||
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/admins/auth-with-password", 'POST', $bodyParams);
|
||||
$output = $this->doRequest($this->url . "/api/collections/_superusers/auth-with-password", 'POST', $bodyParams);
|
||||
self::$token = json_decode($output, true)['token'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $recordId
|
||||
* @param string $url
|
||||
* @param string $method
|
||||
* @return bool|string
|
||||
*/
|
||||
public function doRequest(string $url, string $method, $bodyParams = []): string
|
||||
{
|
||||
$ch = curl_init();
|
||||
|
||||
if (self::$token != '') {
|
||||
$headers = array(
|
||||
'Content-Type:application/json',
|
||||
'Authorization: ' . self::$token
|
||||
);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
@@ -65,9 +59,6 @@ class Settings
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getAll():array
|
||||
{
|
||||
return json_decode($this->doRequest($this->url . '/api/settings', 'GET', []), true);
|
||||
|
||||
8
src/SuperUser.php
Normal file
8
src/SuperUser.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Pb;
|
||||
|
||||
class SuperUser
|
||||
{
|
||||
|
||||
}
|
||||
18
src/User.php
Normal file
18
src/User.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?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;
|
||||
}
|
||||
14
src/viewModels/CollectionItem.php
Normal file
14
src/viewModels/CollectionItem.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Pb\viewModels;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class CollectionItem
|
||||
{
|
||||
public string $collectionName;
|
||||
public string $collectionId;
|
||||
public DateTime $created;
|
||||
public string $id;
|
||||
public DateTime $updated;
|
||||
}
|
||||
12
src/viewModels/CollectionResponse.php
Normal file
12
src/viewModels/CollectionResponse.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Pb\viewModels;
|
||||
|
||||
class CollectionResponse
|
||||
{
|
||||
public array $items;
|
||||
public int $page;
|
||||
public int $perPage;
|
||||
public int $totalItems;
|
||||
public int $totalPages;
|
||||
}
|
||||
48
tests/ClientTest.php
Normal file
48
tests/ClientTest.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use Pb\Client;
|
||||
use Pb\Collection;
|
||||
use Pb\Settings;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class ClientTest 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 test_collection(): void
|
||||
{
|
||||
$pb = new Client($this->url);
|
||||
|
||||
$actual = $pb->collection('users');
|
||||
|
||||
$this->assertEquals($actual, $this->collection);
|
||||
}
|
||||
|
||||
public function test_settings(): void
|
||||
{
|
||||
$pb = new Client($this->url);
|
||||
|
||||
$actual = $pb->settings();
|
||||
|
||||
$this->assertEquals($actual, new Settings($this->url));
|
||||
}
|
||||
|
||||
public function test_setToken(){
|
||||
$token = 'test123';
|
||||
|
||||
$pb = new Client($this->url);
|
||||
$pb->setAuthToken($token);
|
||||
|
||||
$this->assertEquals($token, $pb->getAuthToken());
|
||||
$this->assertEquals($token, $pb->token);
|
||||
$pb->token = 'test456';
|
||||
$this->assertEquals('test456', $pb->getAuthToken());
|
||||
}
|
||||
}
|
||||
55
tests/CollectionGetFirstListItemTest.php
Normal file
55
tests/CollectionGetFirstListItemTest.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
28
tests/CollectionGetFullListTest.php
Normal file
28
tests/CollectionGetFullListTest.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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.');
|
||||
}
|
||||
}
|
||||
76
tests/CollectionGetListTest.php
Normal file
76
tests/CollectionGetListTest.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?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.');
|
||||
}
|
||||
}
|
||||
50
tests/CollectionGetOneTest.php
Normal file
50
tests/CollectionGetOneTest.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php declare(strict_types=1);
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class CollectionTest extends TestCase
|
||||
{
|
||||
public function test(): void
|
||||
{
|
||||
$expected = [];
|
||||
|
||||
$url = 'https://admin.pocketbase.dev';
|
||||
$collection = new \Pb\Collection($url, 'users');
|
||||
$actual = $collection->getList(1,10);
|
||||
|
||||
$this->assertSame($expected, $actual);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user