{"id":15014395,"url":"https://github.com/inspirum/phpunit-extension","last_synced_at":"2026-01-26T19:33:31.858Z","repository":{"id":240228212,"uuid":"801998241","full_name":"inspirum/phpunit-extension","owner":"inspirum","description":"PHPUnit extension with additional assertions","archived":false,"fork":false,"pushed_at":"2024-11-21T14:29:23.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-23T21:37:41.392Z","etag":null,"topics":["phpunit","phpunit-assertions","with-consecutive"],"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/inspirum.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2024-05-17T10:15:28.000Z","updated_at":"2024-11-21T14:29:57.000Z","dependencies_parsed_at":"2025-01-15T06:44:38.109Z","dependency_job_id":"37696f83-2ae6-4104-972a-e8d0c4eba7c3","html_url":"https://github.com/inspirum/phpunit-extension","commit_stats":{"total_commits":4,"total_committers":1,"mean_commits":4.0,"dds":0.0,"last_synced_commit":"37dd8953c8132d16137cb89030f7bb16da7fed10"},"previous_names":["inspirum/phpunit-extension"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/inspirum/phpunit-extension","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inspirum%2Fphpunit-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inspirum%2Fphpunit-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inspirum%2Fphpunit-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inspirum%2Fphpunit-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inspirum","download_url":"https://codeload.github.com/inspirum/phpunit-extension/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inspirum%2Fphpunit-extension/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28785735,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T13:55:28.044Z","status":"ssl_error","status_checked_at":"2026-01-26T13:55:26.068Z","response_time":59,"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":["phpunit","phpunit-assertions","with-consecutive"],"created_at":"2024-09-24T19:45:34.837Z","updated_at":"2026-01-26T19:33:31.816Z","avatar_url":"https://github.com/inspirum.png","language":"PHP","readme":"# PHPUnit extension\n\n[![Latest Stable Version][ico-packagist-stable]][link-packagist-stable]\n[![Build Status][ico-workflow]][link-workflow]\n[![Coverage Status][ico-scrutinizer]][link-scrutinizer]\n[![Quality Score][ico-code-quality]][link-code-quality]\n[![PHPStan][ico-phpstan]][link-phpstan]\n[![Total Downloads][ico-packagist-download]][link-packagist-download]\n[![Software License][ico-license]][link-licence]\n\nPHPUnit extension with additional assertions and other helpers.\n\n- Support some deprecated functionality\n- Easy to implement\n\n## Features\n\nSupports deprecated assertion method `withConsecutive`\n\nBefore PHPUnit 10.0\n\n```php\nuse PHPUnit\\Framework\\TestCase;\n\nfinal class CalculatorTest extends TestCase\n{\n    public function testMultiply(): void\n    {\n        $mock = $this-\u003ecreateMock(Calculator::class);\n        \n        $arguments = [[1,2,3], [4,5,6]]\n        $responses = [6, 120]\n        \n        $mock-\u003eexpects($this-\u003eexactly(count($arguments)))-\u003emethod('multiply')\n            -\u003ewithConsecutive(...$arguments)\n            -\u003ewillReturnOnConsecutiveCalls(...$responses);\n            \n        // ... test\n    }\n}\n```\n\nAfter PHPUnit 10.0\n\n```php\nuse Inspirum\\PHPUnit\\Extension;\nuse PHPUnit\\Framework\\TestCase;\n\nfinal class CalculatorTest extends TestCase\n{\n    use Extension;\n    \n    public function testMultiply(): void\n    {\n        $mock = $this-\u003ecreateMock(Calculator::class);\n        \n        $arguments = [[1,2,3], [4,5,6]]\n        $responses = [6, 120]\n        \n        $mock-\u003eexpects($this-\u003eexactly(count($arguments)))-\u003emethod('multiply')\n            -\u003ewill(self::withConsecutive($arguments, $responses));\n            \n        // ... test\n    }\n}\n```\n\n\n## System requirements\n\n* [PHP 8.1+](http://php.net/releases/8_1_0.php)\n\n## Installation\n\nRun composer require command\n```bash\n$ composer require inspirum/phpunit-extension\n```\nor add requirement to your `composer.json`\n```json\n\"inspirum/phpunit-extension\": \"^1.0\"\n```\n\n## Usage\n\nValidate arguments and responses:\n\n```php\n$mock-\u003eexpects($this-\u003eexactly(2))-\u003emethod('example')\n    -\u003ewill(self::withConsecutive(\n        arguments: [\n            [1, 2, 0.1],\n            [2, 3, 0.01],\n        ], \n        responses: [\n            true,\n            false,\n        ],\n    ));\n\nself::assertTrue($mock-\u003eexample(1, 2, 0.1));\nself::assertFalse($mock-\u003eexample(2, 3, 0.01));\n```\n\nOptional responses:\n\n```php\n$mock-\u003eexpects($this-\u003eexactly(2))-\u003emethod('example')\n    -\u003ewill(self::withConsecutive(\n        arguments: [\n            [1, 2, 0.1],\n            [2, 3, 0.01],\n        ], \n    ));\n\n$mock-\u003eexample(1, 2, 0.1);\n$mock-\u003eexample(2, 3, 0.01);\n```\n\nSimplification for same response for each call\n\n```php\n$mock-\u003eexpects($this-\u003eexactly(2))-\u003emethod('example')\n    -\u003ewill(self::withConsecutive(\n        arguments: [\n            [1, 2, 0.1],\n            [2, 3, 0.01],\n        ], \n        responses: true,\n    ));\n\nself::assertTrue($mock-\u003eexample(1, 2, 0.1));\nself::assertTrue($mock-\u003eexample(2, 3, 0.01));\n```\n\nSupports throwing exceptions:\n\n```php\n$mock-\u003eexpects($this-\u003eexactly(2))-\u003emethod('example')\n    -\u003ewill(self::withConsecutive(\n        arguments: [\n            [1, 2, 0.1],\n            [2, 3, 0.01],\n        ], \n        responses: [\n           true,\n           new RuntimeException('Custom error'),\n        ],\n    ));\n\nself::assertTrue($mock-\u003eexample(1, 2, 0.1));\n\ntry {\n    $mock-\u003eexample(2, 3, 0.01);\n} catch (RuntimeException $exception) {\n    self::assertSame('Custom error', $exception-\u003egetMessage());\n}\n```\n\n## Testing\n\nTo run unit tests, run:\n\n```bash\n$ composer test:test\n```\n\nTo show coverage, run:\n\n```bash\n$ composer test:coverage\n```\n\n\n## Contributing\n\nPlease see [CONTRIBUTING][link-contributing] and [CODE_OF_CONDUCT][link-code-of-conduct] for details.\n\n\n## Security\n\nIf you discover any security related issues, please email tomas.novotny@inspirum.cz instead of using the issue tracker.\n\n\n## Credits\n\n- [Tomáš Novotný](https://github.com/tomas-novotny)\n- [All Contributors][link-contributors]\n\n\n## License\n\nThe MIT License (MIT). Please see [License File][link-licence] for more information.\n\n\n[ico-license]:              https://img.shields.io/github/license/inspirum/phpunit-extension.svg?style=flat-square\u0026colorB=blue\n[ico-workflow]:             https://img.shields.io/github/actions/workflow/status/inspirum/phpunit-extension/master.yml?branch=master\u0026style=flat-square\n[ico-scrutinizer]:          https://img.shields.io/scrutinizer/coverage/g/inspirum/phpunit-extension/master.svg?style=flat-square\n[ico-code-quality]:         https://img.shields.io/scrutinizer/g/inspirum/phpunit-extension.svg?style=flat-square\n[ico-packagist-stable]:     https://img.shields.io/packagist/v/inspirum/phpunit-extension.svg?style=flat-square\u0026colorB=blue\n[ico-packagist-download]:   https://img.shields.io/packagist/dt/inspirum/phpunit-extension.svg?style=flat-square\u0026colorB=blue\n[ico-phpstan]:              https://img.shields.io/badge/style-level%2010-brightgreen.svg?style=flat-square\u0026label=phpstan\n\n[link-author]:              https://github.com/inspirum\n[link-contributors]:        https://github.com/inspirum/phpunit-extension/contributors\n[link-licence]:             ./LICENSE.md\n[link-changelog]:           ./CHANGELOG.md\n[link-contributing]:        ./docs/CONTRIBUTING.md\n[link-code-of-conduct]:     ./docs/CODE_OF_CONDUCT.md\n[link-workflow]:            https://github.com/inspirum/phpunit-extension/actions\n[link-scrutinizer]:         https://scrutinizer-ci.com/g/inspirum/phpunit-extension/code-structure\n[link-code-quality]:        https://scrutinizer-ci.com/g/inspirum/phpunit-extension\n[link-packagist-stable]:    https://packagist.org/packages/inspirum/phpunit-extension\n[link-packagist-download]:  https://packagist.org/packages/inspirum/phpunit-extension/stats\n[link-phpstan]:             https://github.com/phpstan/phpstan\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finspirum%2Fphpunit-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finspirum%2Fphpunit-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finspirum%2Fphpunit-extension/lists"}