{"id":19218741,"url":"https://github.com/fadilxcoder/phpunit","last_synced_at":"2025-02-23T09:14:50.992Z","repository":{"id":52494851,"uuid":"460597946","full_name":"fadilxcoder/phpunit","owner":"fadilxcoder","description":"PHP Unit - Udemy","archived":false,"fork":false,"pushed_at":"2023-10-23T20:23:00.000Z","size":50,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-04T19:23:42.275Z","etag":null,"topics":["code-coverage","github-actions","notes","php","phpunit","test","udemy"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fadilxcoder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-02-17T20:31:00.000Z","updated_at":"2022-08-21T11:44:17.000Z","dependencies_parsed_at":"2024-11-09T14:31:42.973Z","dependency_job_id":"c6d1df13-3e11-405f-98da-cc67baf99d25","html_url":"https://github.com/fadilxcoder/phpunit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fadilxcoder%2Fphpunit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fadilxcoder%2Fphpunit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fadilxcoder%2Fphpunit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fadilxcoder%2Fphpunit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fadilxcoder","download_url":"https://codeload.github.com/fadilxcoder/phpunit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240292395,"owners_count":19778311,"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":["code-coverage","github-actions","notes","php","phpunit","test","udemy"],"created_at":"2024-11-09T14:27:56.959Z","updated_at":"2025-02-23T09:14:50.909Z","avatar_url":"https://github.com/fadilxcoder.png","language":"PHP","readme":"# NOTES\n\n```\n        \\        FADILXCODER        /\n         \\                         /\n          \\                       /\n           ]                     [    ,'|\n           ]                     [   /  |\n           ]___               ___[ ,'   |\n           ]  ]\\             /[  [ |:   |\n           ]  ] \\           / [  [ |:   |\n           ]  ]  ]         [  [  [ |:   |\n           ]  ]  ]__     __[  [  [ |:   |\n           ]  ]  ] ]\\ _ /[ [  [  [ |:   |\n           ]  ]  ] ] (#) [ [  [  [ :===='\n           ]  ]  ]_].nHn.[_[  [  [\n           ]  ]  ]  HHHHH. [  [  [\n           ]  ] /   `HH(\"N  \\ [  [\n           ]__]/     HHH  \"  \\[__[\n           ]         NNN         [\n           ]         N/\"         [\n           ]         N H         [\n          /          N            \\\n         /           q,            \\\n        /                           \\\n```\n\n\n- https://phpunit.de/getting-started/phpunit-9.html (PHPUnit 9)\n- Install `composer require --dev phpunit/phpunit ^9`\n- Check by `./vendor/bin/phpunit --version`\n- Create / Update `phpunit.xml` with ` ./vendor/bin/phpunit  --generate-configuration` / `./vendor/bin/phpunit --migrate-configuration`\n- Running PHPUnit and adding an alias (macOS, Linux) :\n- - `./vendor/phpunit/phpunit/phpunit`\n- - `alias phpunit=\"./vendor/phpunit/phpunit/phpunit\"`\n- - `./vendor/bin/phpunit`\n- When methods are not prefix by `test`, they are not tested by phpunit, tag them with \n- Configure using `phpunit.xml`\n```\n/**\n * @test\n */\n```\n- Tests dependency : check `tests/QueueTest.php`\n```\n/**\n * @depends .....\n */\n```\n\n- `protected function setUp()` and `protected function tearDown()` are called before/after **each method** is tested.\n- `public static function setUpBeforeClass()` and `public static function tearDownAfterClass()` are called before/after **a class** is tested.\n- `$this-\u003ecreateMock` and `$this-\u003egetMockBuilder` in `UserTest.php`\n- Mockery PHPUnit framework\n- - Install `composer req mockery/mockery --dev`\n\n\n# Documentation\n\n- https://phpunit.readthedocs.io/en/9.5/assertions.html (Assertions)\n- https://phpunit.readthedocs.io/en/9.5/configuration.html (The XML Configuration File)\n- https://phpunit.readthedocs.io/en/9.5/test-doubles.html (Test Doubles / Mock)\n- https://github.com/sebastianbergmann/phpunit/blob/main/src/Framework/Assert.php (Mock `$this-\u003eequalTo` list of other similar available methods)\n- http://docs.mockery.io/en/latest/index.html (PHP mock object framework testing with PHPUnit)\n- http://docs.mockery.io/en/latest/reference/phpunit_integration.html (Mockery - PHPUnit Integration)\n- http://docs.mockery.io/en/latest/reference/expectations.html (Declaring Method Call Expectations)\n- https://phpunit.readthedocs.io/en/9.5/writing-tests-for-phpunit.html#data-providers (Dataproviders for test)\n\n# Execute\n\nRun test by : \n- `phpunit ./tests/ExampleTest.php` (By filename)\n- `phpunit ./tests/` (By repo)\n- `./vendor/bin/phpunit ./tests/ExampleTest.php`\n- `./vendor/bin/phpunit ./tests/ --filter=testReturnFullName` (Filter by method name)\n- `./vendor/bin/phpunit ./tests/ --filter=testReturnFullName --color` (Colorful output)\n- `./vendor/bin/phpunit` - Use after configuring `phpunit.xml`\n- `./vendor/bin/phpunit --filter=QueueTest` (Test dependency among methods)\n- `php bin/phpunit --filter=QueueRefactoTest` (No test dependency / Individual test each method)\n- `php bin/phpunit --filter=OrderTest` (Mockery usage)\n\n# Code coverage\n\n- URL : http://localhost/phpunit/_coverage/dashboard.html\n- CMD : `php bin/phpunit --coverage-html html` - Generate report to specific directory\n- CMD : `php bin/phpunit` - Generate report into **_coverage**\n\n# CLI\n\n```bash\n\n$ php bin/phpunit\n\n--------------------------------------------------------------------\n\n\nSCORE : 1:0    ¯\\_(ツ)_/¯\\ *|  /¯\\_(°_o)_/¯\n\nPHPUnit 9.5.21 #StandWithUkraine\n\nRuntime:       PHP 7.4.9 with Xdebug 2.9.6\nConfiguration: C:\\wamp64\\www\\phpunit\\phpunit.xml\n\n.........\n Mail dispatch using connector : EDM::aM7Kj\n FROM : fadil@xcoder.dvlpr\n MSG : Alpha Tango Foxtrot Sierra Lima\n.....................                                    30 / 30 (100%)\n\nTime: 00:03.694, Memory: 16.00 MB\n\nOK (30 tests, 37 assertions)\n\nGenerating code coverage report in HTML format ... done [00:00.106]\n\n\nCode Coverage Report Summary:\n  Classes: 83.33% (5/6)      \n  Methods: 92.86% (13/14)    \n  Lines:   89.66% (26/29)    \n\n\n--------------------------------------------------------------------\n\n```\n\n# Github Action test / code coverage\n\n- https://github.com/shivammathur/setup-php (Setup PHP in GitHub Actions)\n- https://github.com/marketplace/actions/setup-php-action (Setup PHP Action)\n\n```yml\nname: PHPUnit\non:\n  push:\n    branches:\n      - master\njobs:\n  unit-tests:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Check out repo\n        uses: actions/checkout@v3\n\n      - name: Install dependencies\n        uses: php-actions/composer@v6\n        with:\n          php_version: \"8.1\"\n\n      - name: PHP init \n        uses: shivammathur/setup-php@master\n        with:\n          php-version: '8.1'\n          extensions: xdebug\n          coverage: xdebug\n      - name: php details\n        run: php -v\n      - name: phpunit exec\n        run: php bin/phpunit\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffadilxcoder%2Fphpunit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffadilxcoder%2Fphpunit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffadilxcoder%2Fphpunit/lists"}