{"id":23260816,"url":"https://github.com/123inkt/phpunit-extensions","last_synced_at":"2026-02-11T11:04:36.606Z","repository":{"id":179111324,"uuid":"657515953","full_name":"123inkt/phpunit-extensions","owner":"123inkt","description":"A library with convenient test case classes and functions for phpunit","archived":false,"fork":false,"pushed_at":"2026-02-06T10:09:01.000Z","size":77,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-06T18:09:57.606Z","etag":null,"topics":["mock","phpunit","test","testcase"],"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/123inkt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-06-23T08:27:28.000Z","updated_at":"2026-02-06T10:09:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"0e2cb678-d87e-4773-826f-7d27daa701f3","html_url":"https://github.com/123inkt/phpunit-extensions","commit_stats":null,"previous_names":["123inkt/phpunit-extensions"],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/123inkt/phpunit-extensions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/123inkt%2Fphpunit-extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/123inkt%2Fphpunit-extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/123inkt%2Fphpunit-extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/123inkt%2Fphpunit-extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/123inkt","download_url":"https://codeload.github.com/123inkt/phpunit-extensions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/123inkt%2Fphpunit-extensions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29228603,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-08T09:43:19.170Z","status":"ssl_error","status_checked_at":"2026-02-08T09:42:55.556Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["mock","phpunit","test","testcase"],"created_at":"2024-12-19T13:18:59.091Z","updated_at":"2026-02-08T11:06:23.619Z","avatar_url":"https://github.com/123inkt.png","language":"PHP","readme":"[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.1-8892BF)](https://php.net/)\n![Run tests](https://github.com/123inkt/phpunit-extensions/actions/workflows/test.yml/badge.svg)\n\n## PHPUnit extensions\n\nUtility classes to make unit testing life easier.\n\n\n## Features\n\n### withConsecutive\nIn PHPUnit 10 withConsecutive method was removed. To still be able to migrate existing codebases a replacement method:\n\nPHPUnit \u003c= 9.5:\n```php\n$mock-\u003emethod('myMethod')-\u003ewithConsecutive([123, 'foobar'], [456]);\n```\nPHPUnit \u003e= 9.6:\n```php\n$mock-\u003emethod('myMethod')-\u003ewith(...consecutive([123, 'foobar'], [456]));\n```\n\n\n### Symfony controller tests\nTesting a Symfony controller internally invokes the dependency container. A utility class to mock these classes more easily.\n\n```php\nuse DR\\PHPUnitExtensions\\Symfony\\AbstractControllerTestCase;\n\nclass MyControllerTest extends AbstractControllerTestCase \n{    \n    public function myTest(): void \n    {\n        $this-\u003eexpectDenyAccessUnlessGranted('attribute', null, true);\n        $this-\u003eexpectGetUser(new User());\n        $this-\u003eexpectCreateForm(TextType::class);\n        \n        ($this-\u003econtroller)();    \n    }\n    \n    public function getController() {\n        return new MyController();    \n    }    \n}\n```\n\n**Methods**\n- `expectGetUser`\n- `expectIsGranted`\n- `expectDenyAccessUnlessGranted`\n- `expectCreateForm`\n- `expectAddFlash`\n- `expectGenerateUrl`\n- `expectGenerateUrlWithConsecutive`\n- `expectRedirectToRoute`\n- `expectForward`\n- `expectRender`\n\n### Symfony ConstraintValidator tests\n\nTestCase for testing Symfony ConstraintValidators.\n\n```php\nuse DR\\PHPUnitExtensions\\Symfony\\AbstractConstraintValidatorTestCase;\n\nclass MyConstraintValidatorTest extends AbstractConstraintValidatorTestCase \n{    \n    public function testValidate(): void\n    {\n        $this-\u003eexpectBuildViolation($constraint-\u003emessage, ['parameter' =\u003e 123])\n            -\u003eexpectSetCode(789)\n            -\u003eexpectAtPath('path')\n            -\u003eexpectAddViolation();\n\n        $this-\u003evalidator-\u003evalidate(123, $this-\u003econstraint);\n    }\n    \n    protected function getValidator(): ConstraintValidator\n    {\n        return new MyConstraintValidator();\n    }\n\n    protected function getConstraint(): Constraint\n    {\n        return new MyConstraint();\n    }\n}\n```\n\n**Methods**\n- `assertHandlesIncorrectConstraintType`\n- `expectNoViolations`\n- `expectBuildViolation(): ConstraintViolationBuilderAssertion`\n\n**ConstraintViolationBuilderAssertion**\n- `expectSetInvalidValue`\n- `expectSetPlural`\n- `expectSetCode`\n- `expectSetCause`\n- `expectSetTranslationDomain`\n- `expectSetParameters`\n- `expectSetParameter`\n- `expectSetParameterWithConsecutive`\n- `expectAtPath`\n- `expectAddViolation`\n\n### ResponseAssertions trait\nThe ResponseAssertions trait provides a set of assertion methods designed to streamline the testing of Symfony HTTP responses. \nThis trait includes methods for verifying the status code, response message content and specific types of responses such as JSON responses\n\n**Methods**\n- `assertJsonResponse`\n- `assertResponse`\n- `assertResponseIsSuccessful`\n- `assertResponseIsRedirection`\n- `assertResponseIsClientError`\n- `assertResponseIsServerError`\n\n### ClockTestTrait\nThe ClockTestTrait provides a set of methods to manipulate the current time in tests. This trait will automatically freeze the time at the start of\neach test. The trait also provides methods to get the current time as timestamp or `DateTimeImmutable` object, \n\n**Methods**\n- `self::time(): int`\n- `self::now(): DateTimeImmutable`\n- `self::sleep(int|float $seconds): void`\n- `self::assertNow()`\n- `self::assertSameTime()`\n\n### ImageTestTrait\nThe `ImageTestTrait` provides methods to compare two images by `binary string`, `SplFileInfo` or `resource`. (Requires `Imagick`). Internally \n`Imagick::compareImages()` is used to compare the images and therefore supports various image formats such as PNG, JPEG, GIF, PDF and more. \n\n**Methods**\n- `self::assertSameImage(string|SplFileInfo|resource, string|SplFileInfo|resource)`\n- `self::assertNotSameImage(string|SplFileInfo|resource, string|SplFileInfo|resource)`\n\n### PdfTestTrait\nThe `PdfTestTrait` provides methods to compare a `TCPDF` object against an image of `binary string`, `SplFileInfo`, `resource` or another `TCPDF` file. (Requires `Imagick` with `ghostscript` and `TCPDF`)\n\n**Methods**\n- `self::assertSamePdf(string|SplFileInfo|resource|TCPDF, TCPDF)`\n- `self::assertNotSamePdf(string|SplFileInfo|resource|TCPDF, TCPDF)`.\n\n**For both ImageTestTrait and PdfTestTrait:**\n\nThe environment variable `PHPUNIT_EXTENSIONS_IMAGE_DIFF_OUTPUT_PATH` can be set to a directory where a `diff.html` will be generated which will\nshow the differences. Optionally, the environment variable `PHPUNIT_EXTENSIONS_IMAGE_DIFF_OUTPUT_URL` can be set to inform the user where\nto find the outputted `diff.html` file. This is useful when running tests in a CI environment.\n\n## About us\n\nAt 123inkt (Part of Digital Revolution B.V.), every day more than 50 development professionals are working on improving our internal ERP \nand our several shops. Do you want to join us? [We are looking for developers](https://www.werkenbij123inkt.nl/zoek-op-afdeling/it).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F123inkt%2Fphpunit-extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F123inkt%2Fphpunit-extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F123inkt%2Fphpunit-extensions/lists"}