{"id":15014482,"url":"https://github.com/beyondit/opencart-test-suite","last_synced_at":"2025-08-17T01:06:30.606Z","repository":{"id":7948218,"uuid":"9342470","full_name":"beyondit/opencart-test-suite","owner":"beyondit","description":"Testing Suite for OpenCart Development","archived":false,"fork":false,"pushed_at":"2018-03-15T10:10:27.000Z","size":69,"stargazers_count":68,"open_issues_count":2,"forks_count":36,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-08-14T06:17:24.265Z","etag":null,"topics":["opencart","opencart-development","phpunit","testing"],"latest_commit_sha":null,"homepage":"","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/beyondit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-10T09:14:24.000Z","updated_at":"2024-10-14T10:29:51.000Z","dependencies_parsed_at":"2022-08-19T07:40:49.036Z","dependency_job_id":null,"html_url":"https://github.com/beyondit/opencart-test-suite","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/beyondit/opencart-test-suite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyondit%2Fopencart-test-suite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyondit%2Fopencart-test-suite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyondit%2Fopencart-test-suite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyondit%2Fopencart-test-suite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beyondit","download_url":"https://codeload.github.com/beyondit/opencart-test-suite/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyondit%2Fopencart-test-suite/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270792043,"owners_count":24645959,"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","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["opencart","opencart-development","phpunit","testing"],"created_at":"2024-09-24T19:45:41.037Z","updated_at":"2025-08-17T01:06:30.515Z","avatar_url":"https://github.com/beyondit.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/beyondit/opencart-test-suite.svg?branch=master)](https://travis-ci.org/beyondit/opencart-test-suite)\n\n# OpenCart Testing Suite\n\n## Supported OpenCart Versions\n\n| OpenCart version | opencart-test-suite version |build status|\n|---|---|---|\n| ~3.0   | ~3.0   | [![Build Status](https://travis-ci.org/beyondit/opencart-test-suite.svg?branch=3.0)](https://travis-ci.org/beyondit/opencart-test-suite) |\n| ~2.2.0 | ~2.2.0 | [![Build Status](https://travis-ci.org/beyondit/opencart-test-suite.svg?branch=2.2)](https://travis-ci.org/beyondit/opencart-test-suite) |\n| ~2.3.0 | ~2.3.0 | [![Build Status](https://travis-ci.org/beyondit/opencart-test-suite.svg?branch=2.3)](https://travis-ci.org/beyondit/opencart-test-suite) |\n\n## Motivation\nThe intend of this project is to provide a simple approach for setting up a test suite for custom OpenCart development. \n\n## Getting started from scratch\n\n - Create a new OpenCart instance (maybe follow this [guide](https://medium.com/@stefan.huber/installing-opencart-with-composer-74fe0ba121b1))\n - Add `opencart-test-suite` as a dependency `composer require beyondit/opencart-test-suite --dev`\n - Use `composer require beyondit/opencart-test-suite:3.0 --dev` for OpenCart version 3.0 respectively\n - Create a `tests` folder and add respective tests (see examples below)\n - Add a `phpunit.xml` which includes testsuites (e.g. admin and catalog) and set an env variable to the opencart root directory (see example phpunit.xml below)\n - Now tests can be run via `vendor/bin/phpunit --testsuite catalog-tests` command\n\n__Our [OpenCart project template](https://github.com/beyondit/opencart-project-template) might simplify setup for you.__\n\n## Example of a phpunit.xml\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cphpunit bootstrap=\"vendor/autoload.php\"\u003e\n    \u003ctestsuites\u003e\n        \u003ctestsuite name=\"catalog-tests\"\u003e\n            \u003cdirectory suffix=\"Test.php\"\u003e./tests/catalog/\u003c/directory\u003e\n        \u003c/testsuite\u003e\n        \u003ctestsuite name=\"admin-tests\"\u003e\n            \u003cdirectory suffix=\"AdminTest.php\"\u003e./tests/admin/\u003c/directory\u003e\n        \u003c/testsuite\u003e\n    \u003c/testsuites\u003e\n    \u003cphp\u003e\n        \u003cenv name=\"OC_ROOT\" value=\"/../opencart/root-folder\" /\u003e\n        \u003cenv name=\"HTTP_SERVER\" value=\"http://localhost:8080/\" /\u003e\n        \u003cenv name=\"TEST_CONFIG\" value=\"test-config\" /\u003e\n    \u003c/php\u003e\n\u003c/phpunit\u003e\n```\n\n## Test Examples\n\n### Testing a Model\n\n```php\nnamespace Tests;\n\nclass ModelCatalogManufacturerTest extends OpenCartTest\n{\n    public function testASpecificManufacturer()\n    {\n        // load the manufacturer model\n        $model = $this-\u003eloadModel(\"catalog/manufacturer\");\n        $manufacturer = $model-\u003egetManufacturer(5);\n\n        // test a specific assertion\n        $this-\u003eassertEquals('HTC', $manufacturer['name']);\n\n    }\n}\n```\n\n### Testing a Controller\n```php\nnamespace Tests;\n\nclass ControllerCheckoutCartTest extends OpenCartTest\n{\n    public function testAddingASpecificProductToTheCart()\n    {\n        $response = $this-\u003edispatchAction('checkout/cart/add','POST',['product_id' =\u003e 28]);\n        $output = json_decode($response-\u003egetOutput(),true);\n        \n        $this-\u003eassertTrue(isset($output['success']) \u0026\u0026 isset($output['total']));\n        $this-\u003eassertRegExp('/HTC Touch HD/', $output['success']);\n    }\n}\n```\n\n### Testing with logged in Customers\n```php\nclass ControllerAccountEditTest extends OpenCartTest {  \n    public function testEditAccountWithLoggedInCustomer() {\n\n        $this-\u003elogin('somebody@test.com','password');\n        \n        $response = $this-\u003edispatchAction('account/edit');\n        $this-\u003eassertRegExp('/Your Personal Details/',$response-\u003egetOutput());\n        \n        $this-\u003elogout();\n        \n    }   \n}\n```\n\n### Testing with logged in Users inside Admin\n\nIn order to test classes inside the admin folder just call your test class ending with `AdminTest` e.g. `ModelCatalogCategoryAdminTest`\n\n```php\nclass ControllerCommonDashboardAdminTest extends OpenCartTest {  \n    public function testShowDashboardWithLoggedInUser() {\n\n        $this-\u003elogin('admin','admin');\n        \n        $response = $this-\u003edispatchAction('common/dashboard');\n        $this-\u003eassertRegExp('/Total Sales/', $response-\u003egetOutput());\n        \n        $this-\u003elogout();\n        \n    }   \n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeyondit%2Fopencart-test-suite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeyondit%2Fopencart-test-suite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeyondit%2Fopencart-test-suite/lists"}