{"action":"created","issue":{"url":"https://api.github.com/repos/xp-forge/assert/issues/7","labels_url":"https://api.github.com/repos/xp-forge/assert/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/xp-forge/assert/issues/7/comments","events_url":"https://api.github.com/repos/xp-forge/assert/issues/7/events","html_url":"https://github.com/xp-forge/assert/pull/7","id":88185004,"number":7,"title":"Custom assertions","user":{"login":"thekid","id":696742,"avatar_url":"https://avatars.githubusercontent.com/u/696742?v=3","gravatar_id":"","url":"https://api.github.com/users/thekid","html_url":"https://github.com/thekid","followers_url":"https://api.github.com/users/thekid/followers","following_url":"https://api.github.com/users/thekid/following{/other_user}","gists_url":"https://api.github.com/users/thekid/gists{/gist_id}","starred_url":"https://api.github.com/users/thekid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thekid/subscriptions","organizations_url":"https://api.github.com/users/thekid/orgs","repos_url":"https://api.github.com/users/thekid/repos","events_url":"https://api.github.com/users/thekid/events{/privacy}","received_events_url":"https://api.github.com/users/thekid/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-14T13:30:29Z","updated_at":"2015-06-14T13:35:33Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/xp-forge/assert/pulls/7","html_url":"https://github.com/xp-forge/assert/pull/7","diff_url":"https://github.com/xp-forge/assert/pull/7.diff","patch_url":"https://github.com/xp-forge/assert/pull/7.patch"},"body":"This pull request lets users add custom assertions. The implementation is based on extension methods.\r\n\r\n## Implementing a custom assertion\r\nYou implement a custom assertion by extending from `unittest.Assertion`:\r\n\r\n```php\r\n<?php namespace example\\tests;\r\n\r\nuse unittest\\assert\\Value;\r\n\r\nclass TestCaseAssertion extends \\unittest\\assert\\Assertion {\r\n  \r\n  public static function hasName(Value $self, $name) {\r\n    return $self->isInstanceOf('unittest.TestCase')->extracting('name')->isEqualTo($name);\r\n  }\r\n\r\n  public static function isIgnored(Value $self, $name) {\r\n    // TBI\r\n  }\r\n}\r\n```\r\n\r\n## Using a custom assertion\r\n```php\r\n<?php namespace example\\tests;\r\n\r\nuse unittest\\assert\\Assert;\r\nuse unittest\\assert\\Assertions;\r\nnew import('example.test.TestCaseAssertion');\r\n\r\n#[@action(new Assertions())]\r\nclass CustomAssertionsTest extends \\unittest\\TestCase {\r\n\r\n  #[@test]\r\n  public function hasName() {\r\n    Assert::that($this)->hasName($this->name);\r\n  }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/xp-forge/assert/issues/comments/111827410","html_url":"https://github.com/xp-forge/assert/pull/7#issuecomment-111827410","issue_url":"https://api.github.com/repos/xp-forge/assert/issues/7","id":111827410,"user":{"login":"thekid","id":696742,"avatar_url":"https://avatars.githubusercontent.com/u/696742?v=3","gravatar_id":"","url":"https://api.github.com/users/thekid","html_url":"https://github.com/thekid","followers_url":"https://api.github.com/users/thekid/followers","following_url":"https://api.github.com/users/thekid/following{/other_user}","gists_url":"https://api.github.com/users/thekid/gists{/gist_id}","starred_url":"https://api.github.com/users/thekid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thekid/subscriptions","organizations_url":"https://api.github.com/users/thekid/orgs","repos_url":"https://api.github.com/users/thekid/repos","events_url":"https://api.github.com/users/thekid/events{/privacy}","received_events_url":"https://api.github.com/users/thekid/received_events","type":"User","site_admin":false},"created_at":"2015-06-14T13:35:33Z","updated_at":"2015-06-14T13:35:33Z","body":":-1: I don't like the implementation, AssertJ [does this more elegantly](http://joel-costigliola.github.io/assertj/assertj-core-custom-assertions.html)"}}