{"action":"created","issue":{"url":"https://api.github.com/repos/mageinferno/magento2-docker-compose/issues/41","repository_url":"https://api.github.com/repos/mageinferno/magento2-docker-compose","labels_url":"https://api.github.com/repos/mageinferno/magento2-docker-compose/issues/41/labels{/name}","comments_url":"https://api.github.com/repos/mageinferno/magento2-docker-compose/issues/41/comments","events_url":"https://api.github.com/repos/mageinferno/magento2-docker-compose/issues/41/events","html_url":"https://github.com/mageinferno/magento2-docker-compose/issues/41","id":194338781,"number":41,"title":"Running integration and unit tests","user":{"login":"Vinai","id":72463,"avatar_url":"https://avatars0.githubusercontent.com/u/72463?v=4","gravatar_id":"","url":"https://api.github.com/users/Vinai","html_url":"https://github.com/Vinai","followers_url":"https://api.github.com/users/Vinai/followers","following_url":"https://api.github.com/users/Vinai/following{/other_user}","gists_url":"https://api.github.com/users/Vinai/gists{/gist_id}","starred_url":"https://api.github.com/users/Vinai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vinai/subscriptions","organizations_url":"https://api.github.com/users/Vinai/orgs","repos_url":"https://api.github.com/users/Vinai/repos","events_url":"https://api.github.com/users/Vinai/events{/privacy}","received_events_url":"https://api.github.com/users/Vinai/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-08T13:42:40Z","updated_at":"2017-08-24T03:51:10Z","closed_at":null,"body":"Running M2 unit tests is possible via `docker-compose run --rm vendor/bin/phunit -c dev/tests/unit/phpunit.xml.dist`, but running integration tests fails because of three things.\r\n\r\n1. `bin/magento` has to be a PHP script as it is called to install and uninstall Magento into a test DB (reference #40)\r\n2. The current working directory has to be `dev/tests/integration`\r\n3. The command line `mysql` and `mysqldump` utilities have to be available because the testing framework uses those to create a dump after the initial install and import that on subsequent runs.\r\n\r\nI've fiddled with the mageinferno images to get this working, which it now seems to do.\r\n\r\nSolving the issue of `bin/magento` not being a PHP script please refer to #40 \r\n\r\nTo solve the second and third issue I've done the following (with the help and hand-holding of James Cowie and Anton Siniorg):\r\n\r\nCreate the file `Docker/integration-test-container/Dockerfile` with the following contents:\r\n\r\n```Dockerfile\r\nFROM mageinferno/magento2-php:7.0-fpm-0\r\n\r\nMAINTAINER contact@vinaikopp.com\r\n\r\nRUN apt-get update\r\n\r\nRUN apt-get install -y mysql-client\r\n\r\nWORKDIR /var/www/html/dev/tests/integration\r\n\r\nENTRYPOINT [\"/usr/local/bin/php\", \"../../../vendor/bin/phpunit\"]\r\n\r\nCMD [\"\"]\r\n```\r\n\r\nAdd this to the `docker-compose.yml` file:\r\n\r\n```\r\nintegration:\r\n  build: Docker/integration-test-container\r\n  volumes_from:\r\n    - appdata\r\n  links:\r\n    - db\r\n\r\nunit:\r\n  image: mageinferno/magento2-php:7.0-fpm-0\r\n  command: php vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist\r\n  volumes_from:\r\n    - appdata\r\n```\r\n\r\nThe `unit` service isn't really required, but I like it because it can be run using `docker-compose run unit` which reads nice.\r\nIt also enforces good practice by not linking to the DB since that should not happen in unit tests anyway.\r\n\r\nThe integration test suite can be run using\r\n\r\n```bash\r\n$ docker-compose run --rm integration\r\n```\r\n\r\nBecause the current working directory is `dev/tests/integration`, individual tests can be started by specifying the path relative to that directory\r\n\r\n```bash\r\n$ docker-compose run --rm integration ../../../app/code/Example/Module/Test/Integration`\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/mageinferno/magento2-docker-compose/issues/comments/324525547","html_url":"https://github.com/mageinferno/magento2-docker-compose/issues/41#issuecomment-324525547","issue_url":"https://api.github.com/repos/mageinferno/magento2-docker-compose/issues/41","id":324525547,"user":{"login":"Gujarats","id":10476678,"avatar_url":"https://avatars0.githubusercontent.com/u/10476678?v=4","gravatar_id":"","url":"https://api.github.com/users/Gujarats","html_url":"https://github.com/Gujarats","followers_url":"https://api.github.com/users/Gujarats/followers","following_url":"https://api.github.com/users/Gujarats/following{/other_user}","gists_url":"https://api.github.com/users/Gujarats/gists{/gist_id}","starred_url":"https://api.github.com/users/Gujarats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gujarats/subscriptions","organizations_url":"https://api.github.com/users/Gujarats/orgs","repos_url":"https://api.github.com/users/Gujarats/repos","events_url":"https://api.github.com/users/Gujarats/events{/privacy}","received_events_url":"https://api.github.com/users/Gujarats/received_events","type":"User","site_admin":false},"created_at":"2017-08-24T03:51:10Z","updated_at":"2017-08-24T03:51:10Z","body":"@Vinai I'm trying to do the same thing here and trying to do the exact thing you mention above. But it doesn't work and cannot connect to local MySQL : \r\n`ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /var/www/html/vendor/magento/framework/Shell.php:61\r\n`\r\nI was kinda wondering did you face the same problem ?"}}
{"actor":{"display_login":"Gujarats"}}