{"id":15063282,"url":"https://github.com/atoum/atoumbundle","last_synced_at":"2025-07-22T22:05:34.065Z","repository":{"id":5488198,"uuid":"6686179","full_name":"atoum/AtoumBundle","owner":"atoum","description":"This bundle provides a simple integration of atoum into Symfony 2.","archived":false,"fork":false,"pushed_at":"2018-04-06T11:25:42.000Z","size":161,"stargazers_count":44,"open_issues_count":14,"forks_count":25,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-04-08T04:19:38.909Z","etag":null,"topics":["atoum","bundle","php","symfony","symfony-bundle","test"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atoum.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2012-11-14T10:34:01.000Z","updated_at":"2024-11-09T02:43:52.000Z","dependencies_parsed_at":"2022-08-06T18:16:14.929Z","dependency_job_id":null,"html_url":"https://github.com/atoum/AtoumBundle","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/atoum/AtoumBundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atoum%2FAtoumBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atoum%2FAtoumBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atoum%2FAtoumBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atoum%2FAtoumBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atoum","download_url":"https://codeload.github.com/atoum/AtoumBundle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atoum%2FAtoumBundle/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266580393,"owners_count":23951217,"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-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["atoum","bundle","php","symfony","symfony-bundle","test"],"created_at":"2024-09-24T23:54:28.104Z","updated_at":"2025-07-22T22:05:34.042Z","avatar_url":"https://github.com/atoum.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"AtoumBundle\n===========\n\n[![Build Status](https://secure.travis-ci.org/atoum/AtoumBundle.png)](http://travis-ci.org/atoum/AtoumBundle)\n\nThis bundle provides a (very) simple integration of [atoum](https://github.com/atoum/atoum), the simple, modern and intuitive unit testing framework for PHP, from [mageekguy](https://github.com/mageekguy) into Symfony2.\n\n## Installation\n\n## 1 - With composer\n\n```json\n{\n    \"require\": {\n        \"atoum/atoum-bundle\": \"^1.4\"\n    }\n}\n```\n\nIn most of the cases you don't need AtoumBundle in your production environment.\n\n```json\n{\n    \"require-dev\": {\n        \"atoum/atoum-bundle\": \"^1.4\"\n    }\n}\n```\n\n## 2 - Command\n\nAtoumBundle is provided with a Symfony command. You can launch atoum tests on specific bundles.\n\n### 2-a Registering in the kernel\n\nYou have to define AtoumBundle on `AppKernel`\n\n```php\nif (in_array($this-\u003egetEnvironment(), array('dev', 'test'))) {\n    //.....\n    $bundles[] = new atoum\\AtoumBundle\\AtoumAtoumBundle();\n}\n```\n\n### 2-b Configuration\n\nDefine your bundles on configuration (if you want to use it only in test environment, in `config_test.yml` only):\n\n```yaml\natoum:\n    bundles:\n        # note that the full name, including vendor, is required\n        AcmeFooBundle: ~ # FooBundle is defined with directories Tests/Units, Tests/Controller\n        MeBarBundle:\n            directories: [Tests/Units, Tests/Functional, ...]\n```\n\n### 2-c Command-line usage\n\nThen you can use:\n\n```shell\n$ php app/console atoum FooBundle --env=test # launch tests of FooBundle\n$ php app/console atoum FooBundle BarBundle --env=test # launch tests of FooBundle and BarBundle\n$ php app/console atoum acme_foo --env=test # launch tests of bundle where alias is acme_foo\n$ php app/console atoum --env=test # launch tests from configuration.\n```\n\n## Simple Usage\n\nMake your test class extend the ```atoum\\AtoumBundle\\Test\\Units\\Test``` class of the bundle.\n\n*Don't forget to load this class with your favorite method (require, autoload, ...) if you don't use composer.*\n\n```php\n\u003c?php\n\n// src/Acme/MyBundle/Tests/Units/Entity/HelloWorld.php\n\nnamespace Acme\\MyBundle\\Tests\\Units\\Entity;\n// if you don't use a bootstrap file, (or composer) you need to require the application autoload\n//require __DIR__ . '/../../../../../../app/autoload.php';\n\n// use path of the atoum.phar as bellow if you don't want to use atoum via composer\n//require_once __DIR__ . '/../../../../../vendor/mageekguy.atoum.phar';\n\nuse atoum\\AtoumBundle\\Test\\Units;\n\nclass helloWorld extends Units\\Test\n{\n}\n```\n\n## Web test case\n\nYou can easily create a kernel environment:\n\n```php\n\u003c?php\n\nrequire __DIR__ . '/../../../../../../../app/autoload.php';\n\nuse atoum\\AtoumBundle\\Test\\Units;\n\nclass helloWorld extends Units\\WebTestCase\n{\n    public function testMyTralala()\n    {\n        $client = $this-\u003ecreateClient();\n    }\n}\n```\n\n## Command test case\n\nYou can also easily test a command:\n\n```php\n\u003c?php\n\nnamespace My\\Bundle\\FoobarBundle\\Tests\\Units\\Command;\n\nuse atoum\\AtoumBundle\\Test\\Units as AtoumBundle;\nuse mageekguy\\atoum;\nuse Symfony\\Bundle\\FrameworkBundle\\Console\\Application;\nuse Symfony\\Component\\Console\\Tester\\CommandTester;\n\n// Assuming that this command will display \"Success\" if succes, and returns a boolean\nuse My\\Bundle\\FoobarBundle\\Command\\FoobarCommand as Base;\n\nclass FoobarCommand extends AtoumBundle\\CommandTestCase\n{\n    public function testExecute()\n    {\n        $this\n            -\u003egiven(\n                $command = new Base()\n            )\n            -\u003eif($commandTester = $this-\u003ecreateCommandTester($command))\n            -\u003ethen\n                -\u003eboolean($commandTester-\u003eexecute())\n                    -\u003eisTrue()\n                -\u003estring($commandTester-\u003egetDisplay())\n                    -\u003econtains(\"Success\")\n        ;\n    }\n}\n```\n\n### Known issues\n\n- The path of the AppKernel cannot be found, override the method ```getKernelDirectory```\nand add the path to your ```app``` directory.\n\n## Test a controller\n\nYou can test your controller with the ```ControllerTest``` class (it extends `WebTestCase` - each file must correspond to a Symfony2 controller):\n\n```php\n\u003c?php\n\nnamespace vendor\\FooBundle\\Tests\\Controller;\n\nuse atoum\\AtoumBundle\\Test\\Units\\WebTestCase;\nuse atoum\\AtoumBundle\\Test\\Controller\\ControllerTest;\n\nclass BarController extends ControllerTest\n{\n    public function testGet()\n    {\n        $this\n            -\u003erequest(array('debug' =\u003e true))\n                -\u003eGET('/demo/' . uniqid())\n                    -\u003ehasStatus(404)\n                    -\u003ehasCharset('UTF-8')\n                    -\u003ehasVersion('1.1')\n                -\u003ePOST('/demo/contact')\n                    -\u003ehasStatus(200)\n                    -\u003ehasHeader('Content-Type', 'text/html; charset=UTF-8')\n                    -\u003ecrawler\n                        -\u003ehasElement('#contact_form')\n                            -\u003ehasChild('input')-\u003eexactly(3)-\u003eend()\n                            -\u003ehasChild('input')\n                                -\u003ewithAttribute('type', 'email')\n                                -\u003ewithAttribute('name', 'contact[email]')\n                            -\u003eend()\n                            -\u003ehasChild('input[type=submit]')\n                                -\u003ewithAttribute('value', 'Send')\n                            -\u003eend()\n                            -\u003ehasChild('textarea')-\u003eend()\n                        -\u003eend()\n                        -\u003ehasElement('li')\n                            -\u003ewithContent('The CSRF token is invalid. Please try to resubmit the form.')\n                            -\u003eexactly(1)\n                        -\u003eend()\n                        -\u003ehasElement('title')\n                            -\u003ehasNoChild()\n                        -\u003eend()\n                        -\u003ehasElement('meta')\n                            -\u003ehasNoContent()\n                        -\u003eend()\n                        -\u003ehasElement('link')\n                            -\u003eisEmpty()\n                        -\u003eend()\n        ;\n    }\n}\n```\n\n## Test a form type\n\nYou can test your form types with the ```FormTestCase``` class as the [official symfony 2 documentation](http://symfony.com/doc/current/cookbook/form/unit_testing.html \"How to unit test your forms\") shows it.\nBut as the official documentation fits the PHPUnit testing framework, here comes this documentation\nfirst example atoum-translated :\n\n```php\n\u003c?php\n\nnamespace Acme\\DemoBundle\\Tests\\Form;\n\nuse Acme\\DemoBundle\\Entity\\TestEntity;\nuse atoum\\AtoumBundle\\Test\\Form;\nuse Acme\\DemoBundle\\Form\\TestEntityType as MyTypeToTest;\n\nclass TestEntityType extends Form\\FormTestCase{\n\n    public function testToutCourt()\n    {\n        $formData = array(\n            'texte1' =\u003e 'test 1',\n            'texte2' =\u003e 'test 2',\n        );\n\n        $type = new MyTypeToTest();\n        $form = $this-\u003efactory-\u003ecreate($type);\n\n        $object = new TestEntity();\n        $object-\u003efromArray($formData);\n\n        // submit the data to the form directly\n        $form-\u003esubmit($formData);\n\n        $this-\u003eboolean($form-\u003eisSynchronized())-\u003eisTrue();\n        $this-\u003evariable($object)-\u003eisEqualTo($form-\u003egetData());\n\n        $view = $form-\u003ecreateView();\n        $children = $view-\u003echildren;\n\n        foreach (array_keys($formData) as $key) {\n            $this-\u003earray($formData)-\u003ehasKey($key);\n        }\n    }\n\n}\n```\n\n## Faker data\n\nAtoumBundle integrates with [Faker](https://github.com/fzaninotto/Faker) library.\n\nIn your tests classes, you have access to a ```Faker\\Generator``` instance with the ```faker``` asserter.\n\n```php\npublic function testMyAmazingFeature()\n{\n    //.....\n    $randomName = $this-\u003efaker-\u003ename;\n\n    $dateTimeBetweenYesterdayAndNow = $this-\u003efaker-\u003edateTimeBetween('-1 day', 'now');\n    //.....\n}\n```\n\nSee [Faker's documentation](https://github.com/fzaninotto/Faker#basic-usage) about its usage.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatoum%2Fatoumbundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatoum%2Fatoumbundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatoum%2Fatoumbundle/lists"}