{"action":"created","issue":{"url":"https://api.github.com/repos/consolidation/Robo/issues/544","repository_url":"https://api.github.com/repos/consolidation/Robo","labels_url":"https://api.github.com/repos/consolidation/Robo/issues/544/labels{/name}","comments_url":"https://api.github.com/repos/consolidation/Robo/issues/544/comments","events_url":"https://api.github.com/repos/consolidation/Robo/issues/544/events","html_url":"https://github.com/consolidation/Robo/issues/544","id":214718065,"number":544,"title":"Confirmation on how rollback and completions work for Collections","user":{"login":"jakenoble","id":2683244,"avatar_url":"https://avatars2.githubusercontent.com/u/2683244?v=3","gravatar_id":"","url":"https://api.github.com/users/jakenoble","html_url":"https://github.com/jakenoble","followers_url":"https://api.github.com/users/jakenoble/followers","following_url":"https://api.github.com/users/jakenoble/following{/other_user}","gists_url":"https://api.github.com/users/jakenoble/gists{/gist_id}","starred_url":"https://api.github.com/users/jakenoble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jakenoble/subscriptions","organizations_url":"https://api.github.com/users/jakenoble/orgs","repos_url":"https://api.github.com/users/jakenoble/repos","events_url":"https://api.github.com/users/jakenoble/events{/privacy}","received_events_url":"https://api.github.com/users/jakenoble/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-03-16T14:14:24Z","updated_at":"2017-03-16T15:07:21Z","closed_at":"2017-03-16T15:07:21Z","body":"> $collection = $this->collectionBuilder();\r\n> $collection->addTask(\r\n>     $this->taskCodecept('vendor/bin/codecept')\r\n>         ->dir('release/application')\r\n>         ->test('functional')\r\n>         ->configFile('src/AppBundle')\r\n>         ->html(\"functional_output.html\")\r\n> )->run();\r\n> \r\n> $collection->completion($this->complete());\r\n> \r\n> $collection->rollback($this->rollback());\r\n> \r\n\r\nGiven the above code, if my tests fail I want `rollback()` to be called only and not `complete()`. \r\n\r\nBut if the tests fail both `rollback()` and `complete()` are both called. \r\n\r\nIf the tasks succeed then just `complete()` runs.\r\n\r\nHow do I have just `rollback()` called if the tests failed? Have I done something wrong or is it expected for both the rollback and completion tasks to be executed when the collection fails?\r\n\r\nPHP5.6 on Mac OS Sierra\r\n"},"comment":{"url":"https://api.github.com/repos/consolidation/Robo/issues/comments/287086938","html_url":"https://github.com/consolidation/Robo/issues/544#issuecomment-287086938","issue_url":"https://api.github.com/repos/consolidation/Robo/issues/544","id":287086938,"user":{"login":"greg-1-anderson","id":612191,"avatar_url":"https://avatars1.githubusercontent.com/u/612191?v=3","gravatar_id":"","url":"https://api.github.com/users/greg-1-anderson","html_url":"https://github.com/greg-1-anderson","followers_url":"https://api.github.com/users/greg-1-anderson/followers","following_url":"https://api.github.com/users/greg-1-anderson/following{/other_user}","gists_url":"https://api.github.com/users/greg-1-anderson/gists{/gist_id}","starred_url":"https://api.github.com/users/greg-1-anderson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/greg-1-anderson/subscriptions","organizations_url":"https://api.github.com/users/greg-1-anderson/orgs","repos_url":"https://api.github.com/users/greg-1-anderson/repos","events_url":"https://api.github.com/users/greg-1-anderson/events{/privacy}","received_events_url":"https://api.github.com/users/greg-1-anderson/received_events","type":"User","site_admin":false},"created_at":"2017-03-16T15:07:21Z","updated_at":"2017-03-16T15:07:21Z","body":"Two changes are necessary:\r\n- You have to call `completion()` / `rollback()` *before* you call `run()`. Calling it afterwards is too late, because the collection has already finished, and therefore will no longer call completion or rollback functions.\r\n- You have to pass a function pointer to `completion()` / `rollback()`; calling the desired function will execute it immediately, and won't have any useful effect on the collection.\r\n\r\nSomething like this:\r\n```\r\n$collection = $this->collectionBuilder();\r\n$collection->addTask(\r\n$this->taskCodecept('vendor/bin/codecept')\r\n->dir('release/application')\r\n->test('functional')\r\n->configFile('src/AppBundle')\r\n->html(\"functional_output.html\")\r\n->rollbackCode([$this, 'rollbackMethod'])\r\n->run();\r\n```"}}
{"actor":{"display_login":"greg-1-anderson"}}