{"id":15226356,"url":"https://github.com/joomla-framework/test","last_synced_at":"2025-10-29T00:43:12.463Z","repository":{"id":7209763,"uuid":"8515496","full_name":"joomla-framework/test","owner":"joomla-framework","description":"Joomla Framework Test Package","archived":false,"fork":false,"pushed_at":"2025-03-31T16:57:20.000Z","size":5460,"stargazers_count":3,"open_issues_count":0,"forks_count":6,"subscribers_count":13,"default_branch":"3.x-dev","last_synced_at":"2025-03-31T17:50:38.708Z","etag":null,"topics":["joomla","joomla-framework","mocking","php","phpunit","reflection"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joomla-framework.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"joomla","custom":"https://community.joomla.org/sponsorship-campaigns.html"}},"created_at":"2013-03-02T04:22:00.000Z","updated_at":"2025-03-31T16:56:15.000Z","dependencies_parsed_at":"2024-06-18T21:28:59.087Z","dependency_job_id":"38fd61fb-8593-45e2-823a-e25d846871fe","html_url":"https://github.com/joomla-framework/test","commit_stats":{"total_commits":97,"total_committers":13,"mean_commits":7.461538461538462,"dds":0.4020618556701031,"last_synced_commit":"7ad61393eac855366d8d0d9d93898a5727e055d5"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joomla-framework%2Ftest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joomla-framework%2Ftest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joomla-framework%2Ftest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joomla-framework%2Ftest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joomla-framework","download_url":"https://codeload.github.com/joomla-framework/test/tar.gz/refs/heads/3.x-dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248107022,"owners_count":21048842,"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":["joomla","joomla-framework","mocking","php","phpunit","reflection"],"created_at":"2024-09-28T20:04:45.490Z","updated_at":"2025-10-29T00:43:12.457Z","avatar_url":"https://github.com/joomla-framework.png","language":"PHP","funding_links":["https://github.com/sponsors/joomla","https://community.joomla.org/sponsorship-campaigns.html"],"categories":[],"sub_categories":[],"readme":"# The Test Package [![Build Status](https://github.com/joomla-framework/test/status.svg)](https://github.com/joomla-framework/test)\n\n[![Latest Stable Version](https://poser.pugx.org/joomla/test/v/stable)](https://packagist.org/packages/joomla/test)\n[![Total Downloads](https://poser.pugx.org/joomla/test/downloads)](https://packagist.org/packages/joomla/test)\n[![Latest Unstable Version](https://poser.pugx.org/joomla/test/v/unstable)](https://packagist.org/packages/joomla/test)\n[![License](https://poser.pugx.org/joomla/test/license)](https://packagist.org/packages/joomla/test)\n\nThis package is a collection of tools that make some of the jobs of unit testing easier.\n\n## TestHelper\n\n`Joomla\\Test\\TestHelper` is a static helper class that can be used to take some of the pain out of repetitive tasks whilst unit testing with PHPUnit.\n\n### Mocking\n\nThere are two methods that help with PHPUnit mock objects.\n\n#### `TestHelper::assignMockCallbacks`\n\nThis helper method provides an easy way to configure mock callbacks in bulk.\n\n```php\nuse Joomla\\Test\\TestHelper;\n\nclass FooTest extends \\PHPUnit_Framework_TestCase\n{\n\tpublic function testFoo()\n\t{\n\t\t// Create the mock.\n\t\t$mockFoo = $this-\u003egetMock(\n\t\t\t'Foo',\n\t\t\t// Methods array.\n\t\t\tarray(),\n\t\t\t// Constructor arguments.\n\t\t\tarray(),\n\t\t\t// Mock class name.\n\t\t\t'',\n\t\t\t// Call original constructor.\n\t\t\tfalse\n\t\t);\n\n\t\t$mockCallbacks = array(\n\t\t\t// 'Method Name' =\u003e \u003ccallback\u003e\n\t\t\t'method1' =\u003e array('\\mockFoo', 'method1'),\n\t\t\t'method2' =\u003e array($this, 'mockMethod2'),\n\t\t);\n\n\t\tTestHelper::assignMockCallbacks($mockFoo, $this, $mockCallbacks);\n\t}\n\n\tpublic function mockMethod2($value)\n\t{\n\t\treturn strtolower($value);\n\t}\n}\n\n```\n\n#### `TestHelper::assignMockReturns`\n\nThis helper method provides an easy way to configure mock returns values in bulk.\n\n```php\nuse Joomla\\Test\\TestHelper;\n\nclass FooTest extends \\PHPUnit_Framework_TestCase\n{\n\tpublic function testFoo()\n\t{\n\t\t// Create the mock.\n\t\t$mockFoo = $this-\u003egetMock(\n\t\t\t'Foo',\n\t\t\t// Methods array.\n\t\t\tarray(),\n\t\t\t// Constructor arguments.\n\t\t\tarray(),\n\t\t\t// Mock class name.\n\t\t\t'',\n\t\t\t// Call original constructor.\n\t\t\tfalse\n\t\t);\n\n\t\t$mockReturns = array(\n\t\t\t// 'Method Name' =\u003e 'Canned return value'\n\t\t\t'method1' =\u003e 'canned result 1',\n\t\t\t'method2' =\u003e 'canned result 2',\n\t\t\t'method3' =\u003e 'canned result 3',\n\t\t);\n\n\t\tTestHelper::assignMockReturns($mockFoo, $this, $mockReturns);\n\t}\n}\n\n```\n\n### Reflection\n\nThere are three methods that help with reflection.\n\n#### `TestHelper::getValue`\n\nThe `TestHelper::getValue` method allows you to get the value of any protected or private property.\n\n```php\nuse Joomla\\Test\\TestHelper;\n\nclass FooTest extends \\PHPUnit_Framework_TestCase\n{\n\tpublic function testFoo()\n\t{\n\t\t$instance = new \\Foo;\n\n\t\t// Get the value of a protected `bar` property.\n\t\t$value = TestHelper::getValue($instance, 'bar');\n\t}\n}\n\n```\n\nThis method should be used sparingly. It is usually more appropriate to use PHPunit's `assertAttribute*` methods.\n\n#### `TestHelper::setValue`\n\nThe `TestHelper::setValue` method allows you to set the value of any protected or private property.\n\n```php\nuse Joomla\\Test\\TestHelper;\n\nclass FooTest extends \\PHPUnit_Framework_TestCase\n{\n\tpublic function testFoo()\n\t{\n\t\t$instance = new \\Foo;\n\n\t\t// Set the value of a protected `bar` property.\n\t\tTestHelper::setValue($instance, 'bar', 'New Value');\n\t}\n}\n\n```\n\nThis method is useful for injecting values into an object for the purpose of testing getter methods.\n\n#### `TestHelper::invoke`\n\nThe `TestHelper::invoke` method allow you to invoke any protected or private method. After specifying the object and the method name, any remaining arguments are passed to the method being invoked.\n\n```php\nuse Joomla\\Test\\TestHelper;\n\nclass FooTest extends \\PHPUnit_Framework_TestCase\n{\n\tpublic function testFoo()\n\t{\n\t\t$instance = new \\Foo;\n\n\t\t// Invoke the protected `bar` method.\n\t\t$value1 = TestHelper::invoke($instance, 'bar');\n\n\t\t// Invoke the protected `bar` method with arguments.\n\t\t$value2 = TestHelper::invoke($instance, 'bar', 'arg1', 'arg2');\n\t}\n}\n```\n\n## Installation via Composer\n\nAdd `\"joomla/test\": \"~2.0\"` to the require block in your composer.json and then run `composer install`.\n\n```json\n{\n\t\"require\": {\n\t\t\"joomla/test\": \"~2.0\"\n\t}\n}\n```\n\nAlternatively, you can simply run the following from the command line:\n\n```sh\ncomposer require joomla/test \"~2.0\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoomla-framework%2Ftest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoomla-framework%2Ftest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoomla-framework%2Ftest/lists"}