{"id":18309810,"url":"https://github.com/phpdevcommunity/unitester","last_synced_at":"2025-04-05T17:33:04.757Z","repository":{"id":257813369,"uuid":"867730683","full_name":"phpdevcommunity/unitester","owner":"phpdevcommunity","description":"PHP UniTester is a unit testing library for PHP that provides a straightforward interface for writing and executing tests. It focuses on a minimalist approach, allowing developers to create assertions and organize tests at the lowest level of PHP, without reliance on complex external libraries.","archived":false,"fork":false,"pushed_at":"2025-03-07T10:18:00.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-21T08:34:50.678Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/phpdevcommunity.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}},"created_at":"2024-10-04T15:56:29.000Z","updated_at":"2025-03-07T09:55:46.000Z","dependencies_parsed_at":"2024-10-07T08:49:03.460Z","dependency_job_id":"e89c679a-8aa1-458d-8cfc-03944f1f447d","html_url":"https://github.com/phpdevcommunity/unitester","commit_stats":null,"previous_names":["phpdevcommunity/unitester"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpdevcommunity%2Funitester","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpdevcommunity%2Funitester/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpdevcommunity%2Funitester/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpdevcommunity%2Funitester/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phpdevcommunity","download_url":"https://codeload.github.com/phpdevcommunity/unitester/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247375653,"owners_count":20929073,"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","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":[],"created_at":"2024-11-05T16:12:28.498Z","updated_at":"2025-04-05T17:32:59.738Z","avatar_url":"https://github.com/phpdevcommunity.png","language":"PHP","readme":"# PHP UniTester\n\n**UniTester** is a unit testing library for PHP that provides a straightforward interface for writing and executing tests. It focuses on a minimalist approach, allowing developers to create assertions and organize tests at the lowest level of PHP, without reliance on complex external libraries.\n\n## Installation\n\nYou can install this library via [Composer](https://getcomposer.org/). Ensure your project meets the minimum PHP version requirement of 7.4.\n\n```bash\ncomposer require phpdevcommunity/unitester\n```\n## Requirements\n\n- PHP version 7.4 or higher\n- Psr\\Container 2.0 or higher\n\n## Project Structure\n\nBefore getting started, make sure you have a `tests/` directory at the root of your project. This directory will contain all your test classes.\n\n```\nyour-project/\n│\n├── src/          # Directory containing your source code\n├── tests/        # Directory containing your test classes\n│   ├── AssertionTest.php\n│   └── AnotherTest.php\n└── ...\n```\n\n## Basic Structure of a Test\n\nTo create tests with UniTester, you need to extend the `TestCase` class and implement the `setUp()`, `tearDown()`, and `execute()` methods.\n\n### Example Usage:\n\n```php\nclass AssertionTest extends TestCase\n{\n    protected function setUp(): void\n    {\n        // Initialize any necessary resources before each test\n    }\n\n    protected function tearDown(): void\n    {\n        // Release resources after each test\n    }\n\n    protected function execute(): void\n    {\n        $this-\u003etestAssertTrue();\n        $this-\u003etestAssertEquals();\n    }\n\n    public function testAssertTrue()\n    {\n        $this-\u003eassertTrue(true);\n    }\n\n    public function testAssertEquals()\n    {\n        $this-\u003eassertEquals(10, 5 + 5);\n    }\n}\n```\n\n### Method Explanation:\n\n- **setUp()**: This method is called before each test is executed. You can initialize any necessary resources for your tests here.\n\n- **tearDown()**: This method is called after each test is executed. It allows you to release any resources used.\n\n- **execute()**: This method should contain all the tests in the class. You can call as many test methods as needed.\n\n### Creating Multiple Test Classes\n\nYou can create as many test classes as needed in the `tests/` directory, each following the same structure. Just make sure to extend the `TestCase` class and implement the required methods.\n\n## Executing Tests\n\nTo run your tests using UniTester, navigate to the root of your project in the terminal and use the following command:\n\n```bash\nphp vendor/bin/unitester tests/\n```\n\n### Command Explanation:\n\n- **php**: This is the PHP command-line interface, which allows you to run PHP scripts from the terminal.\n\n\n- **vendor/bin/unitester**: This path points to the UniTester executable. Ensure that UniTester is installed and available in your `vendor` directory.\n\n\n- **tests/**: This specifies the directory where your test classes are located. UniTester will automatically find and execute all test classes in this directory.\n\n### Output\n\nAfter executing the command, you will see the results of your tests in the terminal, indicating which tests passed and which, if any, failed.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpdevcommunity%2Funitester","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphpdevcommunity%2Funitester","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpdevcommunity%2Funitester/lists"}