{"id":13720952,"url":"https://github.com/digitalpianism/testframework","last_synced_at":"2026-04-09T14:02:18.949Z","repository":{"id":56968846,"uuid":"62049971","full_name":"digitalpianism/testframework","owner":"digitalpianism","description":"A simple test framework repo for Magento 1","archived":false,"fork":false,"pushed_at":"2018-03-13T13:02:38.000Z","size":15,"stargazers_count":49,"open_issues_count":5,"forks_count":13,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-10-13T19:07:10.089Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/digitalpianism.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}},"created_at":"2016-06-27T11:05:29.000Z","updated_at":"2023-08-26T07:19:38.000Z","dependencies_parsed_at":"2022-08-21T06:40:13.266Z","dependency_job_id":null,"html_url":"https://github.com/digitalpianism/testframework","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/digitalpianism%2Ftestframework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalpianism%2Ftestframework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalpianism%2Ftestframework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalpianism%2Ftestframework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digitalpianism","download_url":"https://codeload.github.com/digitalpianism/testframework/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224604618,"owners_count":17339172,"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-08-03T01:01:10.380Z","updated_at":"2025-12-12T20:15:04.861Z","avatar_url":"https://github.com/digitalpianism.png","language":"PHP","funding_links":[],"categories":["Testing"],"sub_categories":["Free"],"readme":"# Digital Pianism Test Framework\n\nA simple test framework module that can be used to create unit and integration tests on Magento 1.\n\n## Prepare your module for your tests\n\n - Create a `Test` folder under your module folder\n - Under this `Test` folder create the following files:\n\n`phpunit.xml` with the following content:\n\n    \u003c?xml version=\"1.0\"?\u003e\n    \u003cphpunit xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n             xsi:noNamespaceSchemaLocation=\"http://schema.phpunit.de/4.1/phpunit.xsd\"\n             colors=\"true\"\n             bootstrap=\"bootstrap.php\"\n             backupGlobals=\"false\"\n             verbose=\"true\"\n    \u003e\n        \u003ctestsuites\u003e\n            \u003ctestsuite name=\"Magento Integration Tests\"\u003e\n                \u003cdirectory\u003e.\u003c/directory\u003e\n            \u003c/testsuite\u003e\n        \u003c/testsuites\u003e\n\n    \u003c/phpunit\u003e\n\nNote that you can change most of the file here, the important part being the `bootstrap.php` file declaration.\n\n`bootstrap.php` with the following content:\n\n    \u003c?php\n\n    require __DIR__ . '/../../../../../../lib/DigitalPianism/TestFramework/Helper/Magento.php';\n    DigitalPianism_TestFramework_Helper_Magento::bootstrap();\n\nPlease note that you may have to adapt the link to `lib/DigitalPianism/TestFramework/Helper/Magento.php` depending on your Magento structure.\n\n## Controller test sample\n\nHere is a sample of a controller test:\n\nUnder your `Test` folder create a `MyTest.php` (your test files must be nammed accordingly to the declaration in your `phpunit.xml.dist` file, in the example above we declared a `Test.php` suffix):\n\n    \u003c?php\n\n    class Vendor_Module_Test_MyTest extends \\PHPUnit_Framework_TestCase {\n\n        public function setUp()\n        {\n            // Stub response to avoid headers already sent problems\n            $stubResponse = new \\DigitalPianism_TestFramework_Controller_HttpResponse();\n            Mage::app()-\u003esetResponse($stubResponse);\n\n            // Possible parameter\n            // Mage::app()-\u003egetRequest()-\u003esetParam('myparameter', 'myvalue');\n\n            // Use the controller helper\n            $controllerTestHelper = new \\DigitalPianism_TestFramework_Helper_ControllerTestHelper($this);\n\n            // Dispatch a GET request\n            $controllerTestHelper-\u003edispatchGetRequest('route', 'controller', 'action');\n            // Dispatch a POST request\n            //$controllerTestHelper-\u003edispatchPostRequest('route', 'controller', 'action');\n        }\n\n        public function testSomething()\n        {\n            // Get the body\n            $body = Mage::app()-\u003egetResponse()-\u003egetBody(true);\n\n            // Get the headers\n            $headers = Mage::app()-\u003egetResponse()-\u003egetHeaders();\n\n            // Get a block\n            $block = Mage::app()-\u003egetLayout()-\u003egetBlock('block_name');\n\n            // Do your tests here\n        }\n    }\n\n## Using test doubles\n\nAs you may have noticed, the `bootstrap.php` injects a custom instance of the config class `DigitalPianism_TestFramework_Model_Config`\n\nThis class declares several new methods:\n\n - `setModelTestDouble` for model test doubles\n - `setResourceModelTestDouble` for resource model test doubles\n - `setHelperTestDouble` for helper test doubles\n\nTo use test doubles you can do the following in your `setUp` method.\n\nLet's say you want to check what template ID is assigned to `Mage_Core_Model_Email_Template_Mailer` when the new customer account email is sent:\n\n    $mailer = Mage::getModel('core/email_template_mailer');\n    Mage::getConfig()-\u003esetModelTestDouble('core/email_template_mailer', $mailer);\n\n    $customer-\u003esendNewAccountEmail();\n\n    $this-\u003eassertSame($expectedEmailTemplateId, $mailer-\u003egetTemplateId());\n\n## Fixtures\n\nYou can create fixtures programmatically in your code.\n\nA good recommendation to avoid having to manually delete your fixtures is to call `Mage::getSingleton('core/resource')-\u003egetConnection('core_write')-\u003ebeginTransaction();` in the `setUp` method and then call `Mage::getSingleton('core/resource')-\u003egetConnection('core_write')-\u003erollBack();` in the `tearDown` method\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalpianism%2Ftestframework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitalpianism%2Ftestframework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalpianism%2Ftestframework/lists"}