{"id":15046923,"url":"https://github.com/v2e4lisp/preview","last_synced_at":"2025-10-09T16:08:01.833Z","repository":{"id":11591317,"uuid":"14082211","full_name":"v2e4lisp/preview","owner":"v2e4lisp","description":"mocha.js and rspec inspired php bdd test framework.","archived":false,"fork":false,"pushed_at":"2017-01-21T12:46:01.000Z","size":624,"stargazers_count":5,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-23T18:01:41.650Z","etag":null,"topics":[],"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/v2e4lisp.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":"2013-11-03T09:24:19.000Z","updated_at":"2017-01-21T12:46:03.000Z","dependencies_parsed_at":"2022-08-20T17:50:42.129Z","dependency_job_id":null,"html_url":"https://github.com/v2e4lisp/preview","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/v2e4lisp/preview","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v2e4lisp%2Fpreview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v2e4lisp%2Fpreview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v2e4lisp%2Fpreview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v2e4lisp%2Fpreview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/v2e4lisp","download_url":"https://codeload.github.com/v2e4lisp/preview/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v2e4lisp%2Fpreview/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001762,"owners_count":26083171,"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-10-09T02:00:07.460Z","response_time":59,"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":[],"created_at":"2024-09-24T20:53:45.528Z","updated_at":"2025-10-09T16:08:01.789Z","avatar_url":"https://github.com/v2e4lisp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Preview\n[![Stories in Ready](https://badge.waffle.io/v2e4lisp/preview.png?label=ready)](http://waffle.io/v2e4lisp/preview)\n[![Build Status](https://travis-ci.org/v2e4lisp/preview.png?branch=master)](https://travis-ci.org/v2e4lisp/preview)\n\nBDD test for php.\n\nHeavily inspired by [mocha.js](http://mochajs.org/)\nand [Rspec](https://github.com/rspec)\n\n## [Document](./docs)\n\n## Sample Code\n### BDD rspec-like syntax\n```php\n\u003c?php\nnamespace Preview\\DSL\\BDD;\n\nrequire_once 'stack.php';\nrequire_once __DIR__.'/../ok.php';\n\ndescribe(\"Stack\", function () {\n    before_each(function () {\n        $this-\u003estack = new \\Stack(array(1,2,3));\n    });\n\n    describe(\"#size\", function () {\n        it(\"returns the size of stack\", function () {\n            ok($this-\u003estack-\u003esize() == 3);\n        });\n    });\n\n    describe(\"#peek\", function () {\n        it(\"returns the last element\", function () {\n            ok($this-\u003estack-\u003epeek() == 3);\n        });\n    });\n\n    describe(\"#push\", function () {\n        it(\"pushes an element to stack\", function () {\n            $this-\u003estack-\u003epush(4);\n            ok($this-\u003estack-\u003epeek() == 4);\n            ok($this-\u003estack-\u003esize() == 4);\n        });\n    });\n\n    describe(\"#pop\", function () {\n        it(\"pops out the last element\", function () {\n            ok($this-\u003estack-\u003epop() == 3);\n            ok($this-\u003estack-\u003esize() == 2);\n        });\n    });\n});\n```\n\n### TDD is aliases for bdd\n```php\n\u003c?php\nnamespace Preview\\DSL\\TDD;\n\nrequire_once 'stack.php';\nrequire_once __DIR__.'/../ok.php';\n\nsuite(\"Stack\", function () {\n    setup(function () {\n        $this-\u003estack = new \\Stack(array(1,2,3));\n    });\n\n    suite(\"#size\", function () {\n        test(\"returns the size of stack\", function () {\n            ok($this-\u003estack-\u003esize() == 3);\n        });\n    });\n\n    suite(\"#peek\", function () {\n        test(\"returns the last element\", function () {\n            ok($this-\u003estack-\u003epeek() == 3);\n        });\n    });\n\n    suite(\"#push\", function () {\n        test(\"pushes an element to stack\", function () {\n            $this-\u003estack-\u003epush(4);\n            ok($this-\u003estack-\u003epeek() == 4);\n            ok($this-\u003estack-\u003esize() == 4);\n        });\n    });\n\n    suite(\"#pop\", function () {\n        test(\"pops out the last element\", function () {\n            ok($this-\u003estack-\u003epop() == 3);\n            ok($this-\u003estack-\u003esize() == 2);\n        });\n    });\n});\n```\n\n### Qunit for simple test\n```php\n\u003c?php\nnamespace Preview\\DSL\\Qunit;\n\nrequire_once 'stack.php';\nrequire_once __DIR__.'/../ok.php';\n\nsuite(\"Stack\");\n\nsetup(function () {\n    $this-\u003estack = new \\Stack(array(1,2,3));\n});\n\ntest(\"#size returns the size of stack\", function () {\n    ok($this-\u003estack-\u003esize() == 3);\n});\n\ntest(\"#peek eturns the last element\", function () {\n    ok($this-\u003estack-\u003epeek() == 3);\n});\n\ntest(\"#push pushes an element to stack\", function () {\n    $this-\u003estack-\u003epush(4);\n    ok($this-\u003estack-\u003epeek() == 4);\n    ok($this-\u003estack-\u003esize() == 4);\n});\n\ntest(\"#pop pops out the last element\", function () {\n    ok($this-\u003estack-\u003epop() == 3);\n    ok($this-\u003estack-\u003esize() == 2);\n});\n```\n\n### Export an array of tests.\n```php\n\u003c?php\nnamespace Preview\\DSL\\Export;\n\nrequire_once 'stack.php';\nrequire_once __DIR__.'/../ok.php';\n\n$suite = array(\n    \"before each\" =\u003e function () {\n        $this-\u003estack = new \\Stack(array(1,2,3));\n    },\n\n    \"#sizereturns the size of stack\" =\u003e function () {\n        ok($this-\u003estack-\u003esize() == 3);\n    },\n\n    \"#peek eturns the last element\" =\u003e function () {\n        ok($this-\u003estack-\u003epeek() == 3);\n    },\n\n    \"#push pushes an element to stack\" =\u003e function () {\n        $this-\u003estack-\u003epush(4);\n        ok($this-\u003estack-\u003epeek() == 4);\n        ok($this-\u003estack-\u003esize() == 4);\n    },\n\n    \"#pop pops out the last element\" =\u003e function () {\n        ok($this-\u003estack-\u003epop() == 3);\n        ok($this-\u003estack-\u003esize() == 2);\n    }\n);\n\nexport(\"Stack\", $suite);\n```\n\n### Testify syntax from [this repo](https://github.com/marco-fiset/Testify.php)\n```php\n\u003c?php\nnamespace Preview\\DSL\\Testify;\n\nrequire_once 'stack.php';\nrequire_once __DIR__.'/../ok.php';\n\n$suite = new Suite(\"Stack[testify]\");\n\n$suite-\u003ebefore_each(function () {\n    $this-\u003estack = new \\Stack(array(1,2,3));\n\n})-\u003etest(\"#size returns the size of stack\", function () {\n    ok($this-\u003estack-\u003esize() == 3);\n\n})-\u003etest(\"#peek eturns the last element\", function () {\n    ok($this-\u003estack-\u003epeek() == 3);\n\n})-\u003etest(\"#push pushes an element to stack\", function () {\n    $this-\u003estack-\u003epush(4);\n    ok($this-\u003estack-\u003epeek() == 4);\n    ok($this-\u003estack-\u003esize() == 4);\n\n})-\u003etest(\"#pop pops out the last element\", function () {\n    ok($this-\u003estack-\u003epop() == 3);\n    ok($this-\u003estack-\u003esize() == 2);\n\n})-\u003eload();\n```\n\n## Contributors\n* Yan Wenjun(@v2e4lisp)\n* Noritaka Horio(@holyshared)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fv2e4lisp%2Fpreview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fv2e4lisp%2Fpreview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fv2e4lisp%2Fpreview/lists"}