{"action":"created","issue":{"url":"https://api.github.com/repos/nette/tester/issues/312","repository_url":"https://api.github.com/repos/nette/tester","labels_url":"https://api.github.com/repos/nette/tester/issues/312/labels{/name}","comments_url":"https://api.github.com/repos/nette/tester/issues/312/comments","events_url":"https://api.github.com/repos/nette/tester/issues/312/events","html_url":"https://github.com/nette/tester/issues/312","id":153746587,"number":312,"title":"Assertions aggregation into a named block","user":{"login":"milo","id":439140,"avatar_url":"https://avatars.githubusercontent.com/u/439140?v=3","gravatar_id":"","url":"https://api.github.com/users/milo","html_url":"https://github.com/milo","followers_url":"https://api.github.com/users/milo/followers","following_url":"https://api.github.com/users/milo/following{/other_user}","gists_url":"https://api.github.com/users/milo/gists{/gist_id}","starred_url":"https://api.github.com/users/milo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/milo/subscriptions","organizations_url":"https://api.github.com/users/milo/orgs","repos_url":"https://api.github.com/users/milo/repos","events_url":"https://api.github.com/users/milo/events{/privacy}","received_events_url":"https://api.github.com/users/milo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-09T10:26:51Z","updated_at":"2016-05-12T21:00:06Z","closed_at":null,"body":"### Idea\r\nIn Nette components test suits is quite common to use a `test()` function:\r\n```php\r\ntest(function () {\r\n    Assert::...()\r\n    Assert::...()\r\n    Assert::...()\r\n});\r\n```\r\nSometimes, I'm using it too and I would like to make it official & supported. **Plus** add possibility to name such blocks of assertions. For example:\r\n```php\r\nAssert::block('Invariability', function () {\r\n    Assert::...()\r\n    Assert::...()\r\n    Assert::...()\r\n});\r\n```\r\n\r\nThe description of block will be shown in stack trace, e.g.:\r\n```\r\n-- FAILED: tests\\RunnerOutput\\JUnitPrinter.phpt\r\n   Invariability\r\n      Exited with error code 255 (expected 0)\r\n      E_NOTICE: Undefined property: .....\r\n\r\n      in src\\Framework\\Dumper.php(265)\r\n      in src\\Framework\\Environment.php(127) Tester\\Dumper::dumpException()\r\n```\r\nIt should be nested, it can be used for [testMethods()](https://github.com/nette/tester/blob/93c1724ae63a9683d5f6b705d80586f0429bd163/src/Framework/TestCase.php#L163), it could solve the #293, related to #133.\r\n\r\nActually, it emulates `TestCase` methods stack trace a little bit.\r\n\r\n### Implementation\r\n```php\r\npublic static function block($name, \\Closure $cb)\r\n{\r\n    try {\r\n        $cb();\r\n    } catch (\\Exception $e) {\r\n        throw new AssertBlockException($name, $e);\r\n    }\r\n}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/nette/tester/issues/comments/218884241","html_url":"https://github.com/nette/tester/issues/312#issuecomment-218884241","issue_url":"https://api.github.com/repos/nette/tester/issues/312","id":218884241,"user":{"login":"dg","id":194960,"avatar_url":"https://avatars.githubusercontent.com/u/194960?v=3","gravatar_id":"","url":"https://api.github.com/users/dg","html_url":"https://github.com/dg","followers_url":"https://api.github.com/users/dg/followers","following_url":"https://api.github.com/users/dg/following{/other_user}","gists_url":"https://api.github.com/users/dg/gists{/gist_id}","starred_url":"https://api.github.com/users/dg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dg/subscriptions","organizations_url":"https://api.github.com/users/dg/orgs","repos_url":"https://api.github.com/users/dg/repos","events_url":"https://api.github.com/users/dg/events{/privacy}","received_events_url":"https://api.github.com/users/dg/received_events","type":"User","site_admin":false},"created_at":"2016-05-12T21:00:06Z","updated_at":"2016-05-12T21:00:06Z","body":"I plan to replace `test(function() { … })` with `(function () { … })()` in PHP 7, so for me it is not useful, but it seems good to me."}}