|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Tests\Generated; |
| 6 | + |
| 7 | +use PHPUnit\Framework\TestCase; |
| 8 | +use Vazaha\Mastodon\Models\AccountModel; |
| 9 | + |
| 10 | +class AccountTest extends TestCase |
| 11 | +{ |
| 12 | + protected string $json; |
| 13 | + |
| 14 | + protected function setUp(): void |
| 15 | + { |
| 16 | + $this->json = <<<'JSON' |
| 17 | +{ |
| 18 | + "id": "23634", |
| 19 | + "username": "noiob", |
| 20 | + |
| 21 | + "display_name": "ikea shark fan account", |
| 22 | + "locked": false, |
| 23 | + "bot": false, |
| 24 | + "created_at": "2017-02-08T02:00:53.274Z", |
| 25 | + "note": "<p>:ms_rainbow_flag: :ms_bisexual_flagweb: :ms_nonbinary_flag: <a href=\"https://awoo.space/tags/awoo\" class=\"mention hashtag\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">#<span>awoo</span}.space <a href=\"https://awoo.space/tags/admin\" class=\"mention hashtag\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">#<span>admin</span} ~ <a href=\"https://awoo.space/tags/bi\" class=\"mention hashtag\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">#<span>bi</span} ~ <a href=\"https://awoo.space/tags/nonbinary\" class=\"mention hashtag\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">#<span>nonbinary</span} ~ compsci student ~ likes video <a href=\"https://awoo.space/tags/games\" class=\"mention hashtag\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">#<span>games</span} and weird/ old electronics and will post obsessively about both ~ avatar by <span class=\"h-card\"><a href=\"https://weirder.earth/@dzuk\" class=\"u-url mention\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">@<span>dzuk</span}</span></p>", |
| 26 | + "url": "https://awoo.space/@noiob", |
| 27 | + "avatar": "https://files.mastodon.social/accounts/avatars/000/023/634/original/6ca8804dc46800ad.png", |
| 28 | + "avatar_static": "https://files.mastodon.social/accounts/avatars/000/023/634/original/6ca8804dc46800ad.png", |
| 29 | + "header": "https://files.mastodon.social/accounts/headers/000/023/634/original/256eb8d7ac40f49a.png", |
| 30 | + "header_static": "https://files.mastodon.social/accounts/headers/000/023/634/original/256eb8d7ac40f49a.png", |
| 31 | + "followers_count": 547, |
| 32 | + "following_count": 404, |
| 33 | + "statuses_count": 28468, |
| 34 | + "last_status_at": "2019-11-17T00:02:23.693Z", |
| 35 | + "emojis": [ |
| 36 | + { |
| 37 | + "shortcode": "ms_rainbow_flag", |
| 38 | + "url": "https://files.mastodon.social/custom_emojis/images/000/028/691/original/6de008d6281f4f59.png", |
| 39 | + "static_url": "https://files.mastodon.social/custom_emojis/images/000/028/691/static/6de008d6281f4f59.png", |
| 40 | + "visible_in_picker": true |
| 41 | + }, |
| 42 | + { |
| 43 | + "shortcode": "ms_bisexual_flag", |
| 44 | + "url": "https://files.mastodon.social/custom_emojis/images/000/050/744/original/02f94a5fca7eaf78.png", |
| 45 | + "static_url": "https://files.mastodon.social/custom_emojis/images/000/050/744/static/02f94a5fca7eaf78.png", |
| 46 | + "visible_in_picker": true |
| 47 | + }, |
| 48 | + { |
| 49 | + "shortcode": "ms_nonbinary_flag", |
| 50 | + "url": "https://files.mastodon.social/custom_emojis/images/000/105/099/original/8106088bd4782072.png", |
| 51 | + "static_url": "https://files.mastodon.social/custom_emojis/images/000/105/099/static/8106088bd4782072.png", |
| 52 | + "visible_in_picker": true |
| 53 | + } |
| 54 | + ], |
| 55 | + "fields": [ |
| 56 | + { |
| 57 | + "name": "Pronouns", |
| 58 | + "value": "they/them", |
| 59 | + "verified_at": null |
| 60 | + }, |
| 61 | + { |
| 62 | + "name": "Alt", |
| 63 | + "value": "<span class=\"h-card\"><a href=\"https://cybre.space/@noiob\" class=\"u-url mention\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">@<span>noiob</span}</span>", |
| 64 | + "verified_at": null |
| 65 | + }, |
| 66 | + { |
| 67 | + "name": "Bots", |
| 68 | + "value": "<span class=\"h-card\"><a href=\"https://botsin.space/@darksouls\" class=\"u-url mention\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">@<span>darksouls</span}</span>, <span class=\"h-card\"><a href=\"https://botsin.space/@nierautomata\" class=\"u-url mention\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">@<span>nierautomata</span}</span>, <span class=\"h-card\"><a href=\"https://mastodon.social/@fedi\" class=\"u-url mention\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">@<span>fedi</span}</span>, code for <span class=\"h-card\"><a href=\"https://botsin.space/@awoobot\" class=\"u-url mention\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">@<span>awoobot</span}</span>", |
| 69 | + "verified_at": null |
| 70 | + }, |
| 71 | + { |
| 72 | + "name": "Website", |
| 73 | + "value": "<a href=\"http://shork.xyz\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">http://</span><span class=\"\">shork.xyz</span><span class=\"invisible\"></span}", |
| 74 | + "verified_at": "2019-11-10T10:31:10.744+00:00" |
| 75 | + } |
| 76 | + ] |
| 77 | +} |
| 78 | + |
| 79 | +JSON; |
| 80 | + } |
| 81 | + |
| 82 | + public function testModelInstantation(): void |
| 83 | + { |
| 84 | + self::assertTrue(true); |
| 85 | + |
| 86 | + $array = json_decode($this->json, true); |
| 87 | + |
| 88 | + if (!is_array($array)) { |
| 89 | + // too bad... |
| 90 | + return; |
| 91 | + } |
| 92 | + |
| 93 | + $model = AccountModel::fromArray($array); |
| 94 | + |
| 95 | + foreach ($array as $property => $value) { |
| 96 | + $property = AccountModel::sanitizePropertyName($property); |
| 97 | + |
| 98 | + self::assertObjectHasProperty($property, $model); |
| 99 | + |
| 100 | + $modelValue = $model->{$property}; |
| 101 | + |
| 102 | + if (!is_string($modelValue) && !is_int($modelValue)) { |
| 103 | + // TODO find some other way to test this |
| 104 | + continue; |
| 105 | + } |
| 106 | + |
| 107 | + self::assertEquals($value, $model->{$property}); |
| 108 | + } |
| 109 | + } |
| 110 | +} |
0 commit comments