{"id":20940024,"url":"https://github.com/sashas777/magento2-testing-framework","last_synced_at":"2025-05-13T22:32:07.974Z","repository":{"id":41114948,"uuid":"263793855","full_name":"sashas777/magento2-testing-framework","owner":"sashas777","description":"Testing framework for Magento 2 modules. Can be used for pipelines test of a single module","archived":false,"fork":false,"pushed_at":"2024-12-17T20:09:46.000Z","size":362,"stargazers_count":4,"open_issues_count":4,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-17T05:17:39.737Z","etag":null,"topics":["composer","magento2","magento2-tests","phpcs","phpmd","unit-test"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sashas777.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}},"created_at":"2020-05-14T02:22:07.000Z","updated_at":"2024-12-17T20:09:50.000Z","dependencies_parsed_at":"2022-08-27T04:11:30.455Z","dependency_job_id":null,"html_url":"https://github.com/sashas777/magento2-testing-framework","commit_stats":null,"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sashas777%2Fmagento2-testing-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sashas777%2Fmagento2-testing-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sashas777%2Fmagento2-testing-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sashas777%2Fmagento2-testing-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sashas777","download_url":"https://codeload.github.com/sashas777/magento2-testing-framework/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254036818,"owners_count":22003657,"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":["composer","magento2","magento2-tests","phpcs","phpmd","unit-test"],"created_at":"2024-11-18T23:08:38.907Z","updated_at":"2025-05-13T22:32:03.552Z","avatar_url":"https://github.com/sashas777.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Magento 2 Testing Framework\n[![Latest Stable Version](https://poser.pugx.org/thesgroup/magento2-testing-framework/v)](//packagist.org/packages/thesgroup/magento2-testing-framework) [![Total Downloads](https://poser.pugx.org/thesgroup/magento2-testing-framework/downloads)](//packagist.org/packages/thesgroup/magento2-testing-framework) [![Latest Unstable Version](https://poser.pugx.org/thesgroup/magento2-testing-framework/v/unstable)](//packagist.org/packages/thesgroup/magento2-testing-framework) [![License](https://poser.pugx.org/thesgroup/magento2-testing-framework/license)](//packagist.org/packages/thesgroup/magento2-testing-framework)\n\nMagento 2 static/unit testing framework for a single module tests. It can be used for a pipeline or to  verify a Magento 2 module.\n\n## Installation\nRun the following command on your Magento 2 project:\n\n```bash\ncomposer require --dev thesgroup/magento2-testing-framework\n```\n\n***\n## Pipeline Examples\nAssumes $MAGENTO_USER and $MAGENTO_PASS set as pipeline variables.\n- [Bitbucket pipelines](https://github.com/sashas777/magento2-testing-framework/blob/master/bitbucket-pipelines.yml.sample)\n- [Gitlab CI](https://github.com/sashas777/magento2-testing-framework/blob/master/.gitlab-ci.yml.sample)\n***\n\n## Basic Usage\nIn the most cases you may use basic test suite to run PHP code, JavaScript, PhpUnit tests.\n\n### PHP Code\nThere is an option to run all php tests using one command.\nIt runs following tests:\n- PHP Coding Standard Verification\n- Code Integrity Tests\n- HTML Static Code Analysis\n- Less Static Code Analysis\n- GraphQL Static Code Analysis\n\nYou can run all tests by using the command:\n```bash\nvendor/bin/phpcs --config-set installed_paths vendor/magento/magento-coding-standard,vendor/phpcompatibility/php-compatibility/PHPCompatibility\nvendor/bin/run-all-tests\n```\n\nWhen you need to delete test files you can use the cleanup command:\n```bash\nvendor/bin/cleanup\n```\n### PHPUnit\nRun unit tests and check for code coverage threshold.\n\n```bash\nvendor/bin/phpunit-tests\n```\n\nAfter execution following reports generated:\n- JUnit log test-reports/junit.xml\n- Html test coverage report test-coverage-html/\n- Clover test coverage report clover.xml\n\nTo set code coverage threshold 80% (The default value 70%):\n```bash\nvendor/bin/phpunit-tests 80\n```\n### Javascript\nRun ESLint to ensure the quality of your JavaScript code:\n```bash\nvendor/bin/js-tests\n```\nFix ESLint Locally:\n```bash\nnpm install eslint --save-dev\nnpx eslint -c vendor/thesgroup/magento2-testing-framework/static/js/eslint/.eslintrc --ignore-pattern=vendor/** --no-error-on-unmatched-pattern .\n```\n \n***\n\n## Advanced Usage\n\n### PHP Coding Standard Verification\nThese testsuite include: PHPCS, PHPMD, PHPCPD, PHPStan Tests and strict types declaration.\nYou can run it exclusively using the following command:\n```bash\nvendor/bin/phpcs --config-set installed_paths vendor/magento/magento-coding-standard,vendor/phpcompatibility/php-compatibility/PHPCompatibility\nvendor/bin/phpunit --testsuite=\"PHP Coding Standard Verification\" -c vendor/thesgroup/magento2-testing-framework/static/integrity/phpunit.xml\n```\n### Code Integrity Tests\nYou can run it exclusively using the following command:\n```bash\nvendor/bin/phpunit --testsuite=\"Code Integrity Tests\" -c vendor/thesgroup/magento2-testing-framework/static/integrity/phpunit.xml\n```\n\n### HTML Static Code Analysis\nYou can run it exclusively using the following command:\n```bash\nvendor/bin/phpunit --testsuite=\"HTML Static Code Analysis\" -c vendor/thesgroup/magento2-testing-framework/static/integrity/phpunit.xml\n```\n\n### Less Static Code Analysis\nYou can run it exclusively using the following command:\n```bash\nvendor/bin/phpunit --testsuite=\"Less Static Code Analysis\" -c vendor/thesgroup/magento2-testing-framework/static/integrity/phpunit.xml\n```\n\n### GraphQL Static Code Analysis\nYou can run it exclusively using the following command:\n```bash\nvendor/bin/phpunit --testsuite=\"GraphQL Static Code Analysis\" -c vendor/thesgroup/magento2-testing-framework/static/integrity/phpunit.xml\n```\n\n## PHP Code Beautifier and Fixer (PHPCBF)\nTo automatically fix as many sniff violations as possible, use the phpcbf command:\n```bash\nvendor/bin/phpcs --config-set installed_paths vendor/magento/magento-coding-standard/,vendor/phpcompatibility/php-compatibility/PHPCompatibility\nvendor/bin/phpcbf --standard=Magento2 .\n```\n\n## Ignoring Files and Folders\nSpecific files/folders can be added to blacklist at the module folder by adding \u003cglobPattern\u003e at new line\n\n#### PHPCS\n```bash\n{module_dir}/Test/_files/phpcs/ignorelist/*.txt \n```\n#### PHPMD\n```bash\n{module_dir}/Test/_files/phpmd/ignorelist/*.txt\n```\n#### PHPCPD\n```bash\n{module_dir}/Test/_files/phpcpd/blacklist/*.txt\n```\n#### Strict Type Declarations\n```bash\n{module_dir}/Test/_files/blacklist/strict_type.txt\n```\n#### PHPStan\n```bash\n{module_dir}/Test/_files/phpstan/blacklist/*.txt\n```\n  \n***\n\n## Information About Tests\n## Magento Specific Rules\n###### AllPurposeAction\nControllers (classes implementing ActionInterface) have to implement marker Http\u003cMethod\u003eActionInterface\nto restrict incoming requests by methods.\n\n###### CookieAndSessionMisuse\nSessions and cookies must only be used in classes directly responsible for HTML presentation because Web APIs do not\nrely on cookies and sessions. If you need to get current user use Magento\\Authorization\\Model\\UserContextInterface\n\n###### FinalImplementation\nFinal keyword is prohibited in Magento as this decreases extensibility and customizability.\nFinal classes and method are not compatible with plugins and proxies.\n\n## Code Integrity Tests\n \nThe command above will perform following tests:\n\n- Compiler test. Check compilation of DI definitions and code generation\n- Test block names exists\n- Test layout declaration and usage of block elements\n- Test format of layout files\n- Test layout declaration and usage of block elements\n- Test declarations of handles in theme layout updates\n- Test ACL in the admin area by various assertions.\n- Find adminhtml/system.xml files and validate them.\n- Find fieldset.xml files and validate them.\n- Check interfaces inherited from \\Magento\\Framework\\Api\\ExtensibleDataInterface.\n- Find webapi xml files and validate them.\n- Find widget.xml files and validate them.\n- Scan source code for references to classes and see if they indeed exist.\n- A test that enforces validity of composer.json files and any other conventions in Magento components.\n- Validates information on the dependency between the modules according to the declarative schema.\n- Oberver Implementation. (PAY ATTENTION: Current implementation does not support of virtual types)\n- Scan source code for incorrect or undeclared modules dependencies.\n- Check Magento modules structure for circular dependencies\n- Verify whether all payment methods are declared in appropriate modules\n- Tests to find obsolete install/upgrade schema/data scripts.\n- Coverage of obsolete nodes in layout\n- Static test for phtml template files.\n- Less Static Code Analysis\n- GraphQL Static Code Analysis\n- Scan source code for detects invocations of outdated __() method.\n- Scan source code for detects invocations of __() function or Phrase object, analyzes placeholders with arguments and see if they not equal.\n- Will check if phrase is empty.\n- xsi:noNamespaceSchemaLocation validation.\n- XML DOM Validation.\n \n## Contribute To The Module\nFeel free to Fork and contribute to this module and create a pull request so we will merge your changes to master branch.\n\n## Credits\nThanks the [the contributors](https://github.com/sashas777/magento2-testing-framework/graphs/contributors)\n\n## Related Resources\n- [Docker Images](https://github.com/sashas777/magento-docker/)\n- [Examples for pipeline configuration](https://github.com/sashas777/magento-docker-pipelines)\n- [Magento Code Standard](https://github.com/magento/magento-coding-standard)\n- [MFTF](https://github.com/magento/magento2-functional-testing-framework)\n- [Magento Coding Standard Severity](https://github.com/magento/magento-coding-standard/blob/v5/Magento2/ruleset.xml)\n- [PHPStan Output Format](https://phpstan.org/user-guide/output-format)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsashas777%2Fmagento2-testing-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsashas777%2Fmagento2-testing-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsashas777%2Fmagento2-testing-framework/lists"}