{"id":24716725,"url":"https://github.com/baylorrae/php-huck","last_synced_at":"2025-07-28T11:03:51.122Z","repository":{"id":137877251,"uuid":"3029315","full_name":"BaylorRae/PHP-Huck","owner":"BaylorRae","description":"A PHP Testing Framework based on Jasmine","archived":false,"fork":false,"pushed_at":"2014-04-18T03:55:28.000Z","size":165,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T02:51:14.550Z","etag":null,"topics":["bdd","php","unit-testing"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BaylorRae.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2011-12-21T19:56:44.000Z","updated_at":"2019-10-19T03:19:02.000Z","dependencies_parsed_at":"2023-03-13T10:55:41.572Z","dependency_job_id":null,"html_url":"https://github.com/BaylorRae/PHP-Huck","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BaylorRae/PHP-Huck","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaylorRae%2FPHP-Huck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaylorRae%2FPHP-Huck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaylorRae%2FPHP-Huck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaylorRae%2FPHP-Huck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BaylorRae","download_url":"https://codeload.github.com/BaylorRae/PHP-Huck/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaylorRae%2FPHP-Huck/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267505099,"owners_count":24098346,"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-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":["bdd","php","unit-testing"],"created_at":"2025-01-27T09:14:01.947Z","updated_at":"2025-07-28T11:03:51.091Z","avatar_url":"https://github.com/BaylorRae.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Huck\n**A PHP Testing Framework**\n\n```php\n\u003c?php\ndescribe('Huck Fin', function() {\n   \n   it('should be Huck', function() {\n      expect('Huck')-\u003etoBe('Huck'); \n   });\n   \n   it('should not be Huck', function() {\n      expect('Tom')-\u003enot-\u003etoBe('Huck'); \n   });\n    \n});\n?\u003e\n```\n\nHuck is a BDD (Behavior Driven Development) framework based on [Jasmine for\nJS][jasmine_url]. It is designed for with a simple syntax to give it a low\nlearning curve.\n\n---\n\n**WARNING**: This project should be considered _very dangerous_ and not be\nused on any real projects. It is an experimental testing suite for PHP and may\nbreak everything.\n\nDO NOT DEPEND ON IT FOR ANYTHING IMPORTANT.\n\n## Features\n\nHuck includes the `let` syntax from RSpec. Because tests are defined in a\nprocedural style, it's not possible to share common variables without using `global`.\nTo get around this you can define a variable with `let()` and the value will be\npassed into your test.\n\n```php\ndescribe(\"let() syntax\", function() {\n\n  // define the variable \"user\"\n  let('user', User::create(array('name' =\u003e 'Huck')));\n\n  it(\"gets the user object\", function($spec) {\n    expect($spec-\u003euser-\u003ename)-\u003etoEqual('Huck');\n  });\n\n  // it resolves closures\n  let('user_new_name', function($spec) {\n    $user = $spec-\u003euser;\n    $user-\u003ename = 'Tom';\n    return $user;\n  });\n\n  it(\"gets the value from a closure\", function($spec) {\n    expect($spec-\u003euser_new_name-\u003ename)-\u003etoEqual('Tom');\n  });\n});\n```\n\n## How to Use\nHuck can be executed via `bin/huck` and it can run against a directory or a\nfile.\n\n```bash\n$ bin/huck spec\n$ bin/huck spec/huck_suite_spec.php\n```\n\n## Available Matchers\nHuck includes most of the [matchers available in Jasmine][jasmine_matchers].\n\n\u003e `expect($x)-\u003etoEqual($y);` checks to see if `$x` and `$y` have the same value\n\u003e\n\u003e `expect($x)-\u003etoBe($y);` checks to see if `$x` and `$y` are identical. e.g. `1 !== '1'`\n\u003e\n\u003e `expect($x)-\u003etoMatch($pattern);` compares `$x` to regular expression `$pattern`\n\u003e\n\u003e `expect($x)-\u003etoBeNull();` checks to see if `$x === null`\n\u003e\n\u003e `expect($x)-\u003etoBeTruthy();` checks if `$x === true`\n\u003e\n\u003e `expect($x)-\u003etoBeFalsy();` checks if `$x === false`\n\u003e\n\u003e `expect($x)-\u003etoContain($y);` checks to see if `(array) $x` contains `$y`. Runs [array_key_exists][array_key_exists] \u0026\u0026 [in_array][in_array]\n\u003e\n\u003e `expect($x)-\u003etoBeLessThan($y);` checks to see if `$x \u003c $y`\n\u003e\n\u003e `expect($x)-\u003etoBeGreaterThan($y);` checks to see if `$x \u003e $y`\n\u003e\n\u003e `expect($x)-\u003etoBeEmpty();` runs [empty][empty]\n\u003e\n\u003e `expect($x)-\u003etoBeString();` runs [is_string][is_string]\n\u003e\n\u003e `expect($x)-\u003etoBeInteger();` runs [is_int][is_int]\n\u003e\n\u003e `expect($x)-\u003etoBeArray();` runs [is_array][is_array]\n\u003e\n\u003e `expect($x)-\u003etoBeInstanceOf();` runs [instanceof type operator][instanceof]\n\nYou can invert any of the matches by using\n\n\u003ccode\u003eexpect($x)\u003cstrong\u003e-\u003enot\u003c/strong\u003e-\u003etoEqual($y)\u003c/code\u003e\n\n## Custom Matchers\nTo create custom matchers run this in your spec file.\n\n```php\n\u003c?php\n\n/**\n * Checks to match length\n *\n * @param $actual the value passed into expect()\n * @param $expected the value passed into -\u003etoBeLength()\n * @author Baylor Rae'\n */\nHuck::addMatcher('toBeLength', function($actual, $expected) {\n    if( !is_array($actual) \u0026\u0026 !is_array($expected) )\n        return false;\n    \n    return count($actual) === count($expected);\n});\n\n?\u003e\n```\n\n[jasmine_url]: https://github.com/pivotal/jasmine\n[jasmine_matchers]: https://github.com/pivotal/jasmine/wiki/Matchers\n[array_key_exists]: http://php.net/array_key_exists\n[in_array]: http://php.net/in_array\n[empty]: http://php.net/empty\n[is_string]: http://php.net/is_string\n[is_int]: http://php.net/is_int\n[is_array]: http://php.net/is_array\n[instanceof]: http://php.net/manual/en/language.operators.type.php\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaylorrae%2Fphp-huck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaylorrae%2Fphp-huck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaylorrae%2Fphp-huck/lists"}