{"id":15008360,"url":"https://github.com/astrotomic/phpunit-assertions","last_synced_at":"2025-08-10T11:08:14.708Z","repository":{"id":38423338,"uuid":"329250915","full_name":"Astrotomic/phpunit-assertions","owner":"Astrotomic","description":"This package provides a set of common PHPUnit custom assertions.","archived":false,"fork":false,"pushed_at":"2025-05-22T11:46:57.000Z","size":109,"stargazers_count":18,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-08T12:48:56.666Z","etag":null,"topics":["assertions","phpunit","phpunit-assertions","testing"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Astrotomic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["Gummibeer"],"custom":["https://forest.astrotomic.info"]}},"created_at":"2021-01-13T09:06:51.000Z","updated_at":"2025-05-22T11:38:44.000Z","dependencies_parsed_at":"2025-06-10T16:08:13.243Z","dependency_job_id":"9983cd7d-9c71-4f8d-9f71-c125b8999343","html_url":"https://github.com/Astrotomic/phpunit-assertions","commit_stats":{"total_commits":54,"total_committers":6,"mean_commits":9.0,"dds":"0.40740740740740744","last_synced_commit":"bd08c3e03ae5e707b0fbb4c1dc2099561d255732"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/Astrotomic/phpunit-assertions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrotomic%2Fphpunit-assertions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrotomic%2Fphpunit-assertions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrotomic%2Fphpunit-assertions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrotomic%2Fphpunit-assertions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Astrotomic","download_url":"https://codeload.github.com/Astrotomic/phpunit-assertions/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrotomic%2Fphpunit-assertions/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269713884,"owners_count":24463244,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assertions","phpunit","phpunit-assertions","testing"],"created_at":"2024-09-24T19:17:49.478Z","updated_at":"2025-08-10T11:08:14.700Z","avatar_url":"https://github.com/Astrotomic.png","language":"PHP","readme":"# PHPUnit Assertions\n\n[![Latest Version](http://img.shields.io/packagist/v/astrotomic/phpunit-assertions.svg?label=Release\u0026style=for-the-badge)](https://packagist.org/packages/astrotomic/phpunit-assertions)\n[![MIT License](https://img.shields.io/github/license/Astrotomic/phpunit-assertions.svg?label=License\u0026color=blue\u0026style=for-the-badge)](https://github.com/Astrotomic/phpunit-assertions/blob/master/LICENSE)\n[![Offset Earth](https://img.shields.io/badge/Treeware-%F0%9F%8C%B3-green?style=for-the-badge)](https://forest.astrotomic.info)\n[![Larabelles](https://img.shields.io/badge/Larabelles-%F0%9F%A6%84-lightpink?style=for-the-badge)](https://larabelles.com)\n\n[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/Astrotomic/phpunit-assertions/phpunit.yml?style=flat-square\u0026logoColor=white\u0026logo=github\u0026label=Tests)](https://github.com/Astrotomic/phpunit-assertions/actions?query=workflow%3Aphpunit)\n[![Total Downloads](https://img.shields.io/packagist/dt/astrotomic/phpunit-assertions.svg?label=Downloads\u0026style=flat-square)](https://packagist.org/packages/astrotomic/phpunit-assertions)\n[![Trees](https://img.shields.io/ecologi/trees/astrotomic?style=flat-square)](https://forest.astrotomic.info)\n[![Carbon](https://img.shields.io/ecologi/carbon/astrotomic?style=flat-square)](https://forest.astrotomic.info)\n\nThis package provides a set of common [PHPUnit](https://phpunit.de/) custom assertions.\nSome require optional packages - check the `composer.json[suggest]` section for more details.\n\n## Installation\n\n```bash\ncomposer require --dev astrotomic/phpunit-assertions\n```\n\n## Usage\n\nEven if all assertions are in `trait`s I highly recommend you to don't `use` these traits in your test classes.\nInstead you can access all assertions as static methods on the traits.\n\n```php\n\\Astrotomic\\PhpunitAssertions\\StringLengthAssertions::assertSame(10, 'Astrotomic');\n```\n\nThis will prevent any method name conflicts with core, your custom or other trait assertions.\n\n## Assertions\n\n### Array\n\n```php\n\\Astrotomic\\PhpunitAssertions\\ArrayAssertions::assertIndexed(['foo', 'bar']);\n\\Astrotomic\\PhpunitAssertions\\ArrayAssertions::assertAssociative(['foo' =\u003e 'bar']);\n\\Astrotomic\\PhpunitAssertions\\ArrayAssertions::assertEquals(['foo', 'bar'], ['bar', 'foo']);\n\\Astrotomic\\PhpunitAssertions\\ArrayAssertions::assertSubset(['foo' =\u003e 'bar'], ['baz' =\u003e 'foo', 'foo' =\u003e 'bar']);\n\\Astrotomic\\PhpunitAssertions\\ArrayAssertions::assertContainsAll(['foo', 'bar'], ['baz', 'foo', 'lorem', 'ipsum', 'bar']);\n```\n\n### Country\n\n`composer require --dev league/iso3166:^3.0`\n\n```php\n\\Astrotomic\\PhpunitAssertions\\CountryAssertions::assertName('Germany');\n\\Astrotomic\\PhpunitAssertions\\CountryAssertions::assertAlpha2('DE');\n\\Astrotomic\\PhpunitAssertions\\CountryAssertions::assertAlpha3('DEU');\n\\Astrotomic\\PhpunitAssertions\\CountryAssertions::assertNumeric('276');\n```\n\n### Email\n\n`composer require --dev egulias/email-validator:^3.0`\n\n```php\n\\Astrotomic\\PhpunitAssertions\\EmailAssertions::assertValidLoose('gummibeer@astrotomic.info');\n\\Astrotomic\\PhpunitAssertions\\EmailAssertions::assertValidStrict('gummibeer@astrotomic.info');\n\\Astrotomic\\PhpunitAssertions\\EmailAssertions::assertDomain('astrotomic.info', 'gummibeer@astrotomic.info');\n\\Astrotomic\\PhpunitAssertions\\EmailAssertions::assertLocalPart('gummibeer', 'gummibeer@astrotomic.info');\n\\Astrotomic\\PhpunitAssertions\\EmailAssertions::assertPlusMailbox('gummibeer', 'gummibeer+news@astrotomic.info');\n\\Astrotomic\\PhpunitAssertions\\EmailAssertions::assertPlusAlias('news', 'gummibeer+news@astrotomic.info');\n```\n\n### Geographic\n\n```php\n\\Astrotomic\\PhpunitAssertions\\GeographicAssertions::assertLatitude(53.551085);\n\\Astrotomic\\PhpunitAssertions\\GeographicAssertions::assertLongitude(9.993682);\n\\Astrotomic\\PhpunitAssertions\\GeographicAssertions::assertCoordinates([\n    'lat' =\u003e 53.551085,\n    'lng' =\u003e 9.993682,\n]);\n```\n\n### HashID\n\n`composer require --dev hashids/hashids:^4.0`\n\n```php\n\\Astrotomic\\PhpunitAssertions\\HashidAssertions::assertHashIds('3kTMd', 2, 'this is my salt');\n\\Astrotomic\\PhpunitAssertions\\HashidAssertions::assertHashId('yr8', 'this is my salt');\n```\n\n### Language\n\n`composer require --dev astrotomic/iso639:^1.0`\n\n```php\n\\Astrotomic\\PhpunitAssertions\\LanguageAssertions::assertName('German');\n\\Astrotomic\\PhpunitAssertions\\LanguageAssertions::assertAlpha2('de');\n```\n\n### Nullable Type\n\n```php\n\\Astrotomic\\PhpunitAssertions\\NullableTypeAssertions::assertIsNullableString('Astrotomic');\n\\Astrotomic\\PhpunitAssertions\\NullableTypeAssertions::assertIsNullableInt(42);\n\\Astrotomic\\PhpunitAssertions\\NullableTypeAssertions::assertIsNullableFloat(42.5);\n\\Astrotomic\\PhpunitAssertions\\NullableTypeAssertions::assertIsNullableArray(['Astrotomic' =\u003e 'Gummibeer']);\n\\Astrotomic\\PhpunitAssertions\\NullableTypeAssertions::assertIsNullableBool(true);\n```\n\n### Phone Number\n\n`composer require --dev giggsey/libphonenumber-for-php:^8.12`\n\n```php\n\\Astrotomic\\PhpunitAssertions\\PhoneNumberAssertions::assertE164('+498001110550');\n\\Astrotomic\\PhpunitAssertions\\PhoneNumberAssertions::assertValid('+49 800 - 111 0 550');\n\\Astrotomic\\PhpunitAssertions\\PhoneNumberAssertions::assertValidForRegion('+49 800 - 111 0 550', 'DE');\n```\n\n### String\n\n```php\n\\Astrotomic\\PhpunitAssertions\\StringLengthAssertions::assertSame(10, 'Astrotomic');\n\\Astrotomic\\PhpunitAssertions\\StringLengthAssertions::assertNotSame(8, 'Astrotomic');\n\\Astrotomic\\PhpunitAssertions\\StringLengthAssertions::assertLessThan(11, 'Astrotomic');\n\\Astrotomic\\PhpunitAssertions\\StringLengthAssertions::assertLessThanOrEqual(10, 'Astrotomic');\n\\Astrotomic\\PhpunitAssertions\\StringLengthAssertions::assertGreaterThan(9, 'Astrotomic');\n\\Astrotomic\\PhpunitAssertions\\StringLengthAssertions::assertGreaterThanOrEqual(10, 'Astrotomic');\n```\n\n### URL\n\n```php\n\\Astrotomic\\PhpunitAssertions\\UrlAssertions::assertValidLoose('https://astrotomic.info');\n\\Astrotomic\\PhpunitAssertions\\UrlAssertions::assertScheme('https', 'https://astrotomic.info');\n\\Astrotomic\\PhpunitAssertions\\UrlAssertions::assertHost('astrotomic.info', 'https://astrotomic.info');\n\\Astrotomic\\PhpunitAssertions\\UrlAssertions::assertPath('/contributor/gummibeer/', 'https://astrotomic.info/contributor/gummibeer/');\n\\Astrotomic\\PhpunitAssertions\\UrlAssertions::assertQuery(['_' =\u003e '123', 'q' =\u003e 'search'], 'https://astrotomic.info?q=search\u0026_=123');\n\\Astrotomic\\PhpunitAssertions\\UrlAssertions::assertComponent('gummibeer', 'https://gummibeer@astrotomic.info', PHP_URL_USER);\n```\n\n### Path\n\n```php\n\\Astrotomic\\PhpunitAssertions\\PathAssertions::assertDirname('/foo/bar', '/foo/bar/image.jpg');\n\\Astrotomic\\PhpunitAssertions\\PathAssertions::assertBasename('image.jpg', '/foo/bar/image.jpg');\n\\Astrotomic\\PhpunitAssertions\\PathAssertions::assertFilename('image', '/foo/bar/image.jpg');\n\\Astrotomic\\PhpunitAssertions\\PathAssertions::assertExtension('jpg', '/foo/bar/image.jpg');\n```\n\n### UUID\n\n`composer require --dev ramsey/uuid:^4.0`\n\n```php\n\\Astrotomic\\PhpunitAssertions\\UuidAssertions::assertUuid('52d08e38-ad24-4960-af02-22e0f7e0db8d');\n```\n\n## Laravel Assertions\n\n### Collection\n\n```php\n\\Astrotomic\\PhpunitAssertions\\Laravel\\CollectionAssertions::assertContains($collection, 'Astrotomic');\n```\n\n### HashID\n\n`composer require --dev vinkla/hashids:^9.0`\n\n```php\n\\Astrotomic\\PhpunitAssertions\\Laravel\\HashidAssertions::assertHashIds('3kTMd', 2);\n\\Astrotomic\\PhpunitAssertions\\Laravel\\HashidAssertions::assertHashId('yr8');\n```\n\n### Model\n\n```php\n\\Astrotomic\\PhpunitAssertions\\Laravel\\ModelAssertions::assertExists($model);\n\\Astrotomic\\PhpunitAssertions\\Laravel\\ModelAssertions::assertSame($model, \\App\\Models\\User::first());\n\\Astrotomic\\PhpunitAssertions\\Laravel\\ModelAssertions::assertRelated($post, 'comments', $comment);\n\\Astrotomic\\PhpunitAssertions\\Laravel\\ModelAssertions::assertRelated(\n    $post, \n    'comments',\n    \\App\\Models\\Comment::class,\n    \\Illuminate\\Database\\Eloquent\\Relations\\HasMany::class\n);\n```\n\n### Blade\n\n`composer require --dev gajus/dindent:^2.0`\n\n```php\n\\Astrotomic\\PhpunitAssertions\\Laravel\\BladeAssertions::assertRenderEquals(\n    \"\u003cp\u003ePrice: \u003ccode\u003e99.99 €\u003c/code\u003e\u003c/p\u003e\",\n    '\u003cp\u003ePrice: \u003ccode\u003e{{ number_format($price, 2) }} €\u003c/code\u003e\u003c/p\u003e',\n    ['price' =\u003e 99.99]\n);\n```\n","funding_links":["https://github.com/sponsors/Gummibeer","https://forest.astrotomic.info"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastrotomic%2Fphpunit-assertions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fastrotomic%2Fphpunit-assertions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastrotomic%2Fphpunit-assertions/lists"}