{"id":15014535,"url":"https://github.com/iblues/atu","last_synced_at":"2025-07-22T06:04:23.556Z","repository":{"id":56988298,"uuid":"233238243","full_name":"iblues/atu","owner":"iblues","description":"Laravel ATU : a fast test framework base on phpdoc Annotation and laravel","archived":false,"fork":false,"pushed_at":"2020-04-07T08:13:00.000Z","size":146,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-19T04:50:42.706Z","etag":null,"topics":["annotations","atu","laravel","phpunit","test-unit"],"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/iblues.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":"2020-01-11T13:43:38.000Z","updated_at":"2023-04-13T07:38:52.000Z","dependencies_parsed_at":"2022-08-21T12:50:27.453Z","dependency_job_id":null,"html_url":"https://github.com/iblues/atu","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/iblues/atu","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iblues%2Fatu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iblues%2Fatu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iblues%2Fatu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iblues%2Fatu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iblues","download_url":"https://codeload.github.com/iblues/atu/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iblues%2Fatu/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266437369,"owners_count":23928235,"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-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["annotations","atu","laravel","phpunit","test-unit"],"created_at":"2024-09-24T19:45:44.643Z","updated_at":"2025-07-22T06:04:23.534Z","avatar_url":"https://github.com/iblues.png","language":"PHP","readme":"\u003ch1 align=\"center\"\u003e Annotation-test-unit (ATU) \u003c/h1\u003e\n\n\u003cp align=\"center\"\u003eLaravel ATU : A phpunit Tool Base on annotation and laravel. 一个基于注解和laravel的单元测试包. \n\n\u003c/p\u003e\n\n### 这个扩展包有啥用? \n\u003cp\u003e\n1.改变你的开发方式. 改完代码,切换浏览器/postman 请求接口 烦不烦? \n    \n2.顺带完成高覆盖测试.\n    \n后面配个视频在这里!~\n\nqq交流群:814333044\n\n兼容laravel5.5+/6/7\n\u003c/p\u003e\n\n## Installing\n\n1.composer 安装\n```shell\n$ composer require iblues/atu --dev\n```\n2.配置好单元测试,教程:\n\u003chttps://www.w3cschool.cn/intellij_idea_doc/using_phpunit_framework.html\u003e\nPS:有效的设置测试环境 phpunit.xml 其中:\n \n    a.SESSION_DRIVER会设置为array, 避免脏环境.\n    b.QUEUE_DRIVER自动覆盖为sync, 方便测试和发现问题.\n    c.CACHE_DRIVER会设置为array, 避免脏环境.\n    d.也可以单独设置测试专用数据库\n\n3.找一个控制器.增加注解.\n\n```php\n    //请确保use以下\n    use Iblues\\AnnotationTestUnit\\Annotation as ATU;\n\n    //请确认有匹配的路由, 程序是根据路由的映射表进行查找. 如果路由映射错误, 会无法执行. 后期会处理这种问题\n    /**\n     * @ATU\\Api(\n     *     @ATU\\Now(),\n     * )\n     */\n    public function index(Request $request){//...}\n\n    /**\n     * 请确保 xx/xx/1有数据\n     * @ATU\\Api(\n     *     \"path\":1,\n     *      @ATU\\Now(),\n     * )\n     */\n    public function show(Request $request){//...}\n\n   /**\n     * @ATU\\Api(\n     *     @ATU\\Now(),\n     *     @ATU\\Request({\"title\":122}),\n     *     @ATU\\Response({\n     *      \"data\":{\"id\":true,\"title\":122}\n     *     })\n     * )\n     */\n    public function store($id,Request $request){//...}\n```\n4.执行以下命令,会创建tests/api/AtuTest.php. 测试该文件即可. Tips: ctrl+r / 开启toggle auto test 即可重新运行测试,加快效率!\n```shell script\nphp artisan vendor:publish --tag ATU\n```\n[See File](https://github.com/iblues/annotation-test-unit/blob/master/src/Publish/tests/Api/AtuTest.php).\n    \n## 如何更爽快的coding?\n### 怎么爽快?\n\u003cp\u003e\n 1.有完整的代码提示.\n \n 2.可以注解快速跳转.方便快速查看代码和文档\n\u003c/p\u003e\n\n### 安装插件\n1.安装phpstorm插件.\n\n https://plugins.jetbrains.com/plugin/index?xmlId=de.espend.idea.php.annotation\n \n 2.设置插件\n language \u0026 framew -\u003e php -\u003eannotations -\u003eUse Alias 新增\n Iblues\\AnnotationTestUnit\\Annotation  as  ATU\n \n \n## Usage\n\n[详细DEMO](https://github.com/iblues/atu/blob/master/DEMO.md)\n\n### 文档说明\n```\n注意事项:\n受第三方扩展限制\n\n1.必须逗号分隔, 否则报错 got '@' at position\n\n2.类似以下数组[1,2,3]需要改写为{1,2,3}\n\n3.字符串必须适应双引号. 如{\"title\":1} , 否则报错 got ''' \n\n@ATU\\Api (代表是api的测试)\n@ATU\\Api( path = http://baidu.com , method=GET , title=\"测试\" , author=\"xx\")\n@ATU\\Api( path = /api/test/test/1 , method=POST)\n@ATU\\Api( path = 1) (会自动寻找匹配的路由 等于 /api/test/test/1)\n@ATU\\Api( path = [1,2,3]) (会依次匹配: /api/{x1}/{x2}/{x3} )\n\n@ATU\\Now //代表执行的测试要执行这个.避免全部执行很慢. 在Test\\Api中\n\n@ATU\\Debug //返回的内容都打印出来\n\n@ATU\\Tag(\"tag1\")  //用于标记分类.\n@ATU\\Tag([\"tag1\",\"tag2\"]) \n\n@ATU\\Request({1:21})   //json参数\n//@ATU\\Request({file:@storage(12.txt)} ) //代表文件路径的 未完成\n\n@ATU\\Before({test/test::class,\"call\"},{\"param1\"}); //调对应类的方法\n@ATU\\Before(\"call\",{\"param1\"}); //调test类本身的方法. 可以在方法中调用setParam存储. 再@GetPrarm()调用\n@ATU\\Before(@ATU\\Tag(\"user.admin\")); //调用其他的tag进行关联性测试\n\n@ATU\\After(\"setParam\",{\"userAdmin\",@ATU\\GetResponse()}), //配合before+tag使用\n\n@ATU\\Login(false|100|0) // false的时候不登录,  100指定用户id为100的  0随意获取一个用户 \n\n@ATU\\Response( 413 )  //默认就是200\n@ATU\\Response( {\"id\":1} ) \n@ATU\\Response( {\"id\":\"/^测试.*?/i\"} )  //支持正则表达式\n@ATU\\Response(200,{\n  \"data\":true,\n  \"data\":{\n    {\"id\":true}\n   },\n   @ATU\\Assert(\"assertJsonMissingExact\",{\"tt\":1}), //等于response进行断言. 参考 https://learnku.com/docs/laravel/6.x/http-tests/5183#available-assertions\n}),\n\n//可以传入@Response和@request 会处理成对应值返回.\n@ATU\\Assert(\"assertDatabaseHas\",{\"user\",\n    { \"title\" : @ATU\\Response('data.title\") }\n}),\n@ATU\\Assert(\"assertDatabaseHas\",{\"user\",\n    { \"title\" :{\"id\":1} }\n}),\n\n关于@ATU\\Assert\n在Api中支持超的函数\nhttps://phpunit.readthedocs.io/zh_CN/latest/assertions.html#assertarrayhaskey\n\n数据库相关.\nassertDatabaseHas($table, array $data);    断言数据库表中包含给定的数据。\nassertDatabaseMissing($table, array $data);    断言数据库中的表不包含给定数据。\nassertSoftDeleted($table, array $data);    断言给定记录已被软删除。\n\n也可以在类中自行增加自定义函数.\n```\n\n[详细DEMO](https://github.com/iblues/atu/DEMO.md)\n\n## FAQ\nQ: 报错 got '@' at position\nA: 注解错误,  经常是少了逗号.\n\n\nQ: 报错  got ''' \nA: 注解中请用双引号. 单引号不行. 如@ATU\\Before(\"login\");\n\nQ: 报错 Illuminate\\Contracts\\Container\\BindingResolutionException : Target class [env] does not exist.\nA: telescope冲突 解决办法件 TELESCOPE.md\n## TodoList\n@ATU\\\n  v1.0版本\n- [x] Api\n- [x] Now\n- [x] Request\n- [x] Response,正则支持\n- [x] getRequest\n- [x] Response\n- [x] getResponse\n- [x] Before\n- [x] Degbug\n- [x] Assert\n- [x] Response\n- [x] GetParam\n- [x] Tag\n- [x] response 关于 GetRequest和GetParam\n- [x] request 关于 getParam\n- [x] before 关于 getParam\n- [x] Assert 关于 getParam\n- [x] Ignore\n- [x] RouteIgnore 忽略路由检查,(第三方扩展包中:写了注释,但是不一定绑定路由的用)\n- [x] title\n- [x] 全局debug (在测试文件中启动)\n- [x] Telescope初步集成\n- [x] before 高级: 在before中调用其他tag.进行关联性测试\n- [x] 增加关于日志的断言\n\n  v1.1\n- [ ] artisan的测试\n- [ ] Request 文件上传,随机种子\n\n  v1.2\n- [ ] Template 测试模板的定义和调用\n\n  v1.3\n- [ ] event断言\n- [ ] Telescope完美集成\n\n## Contributing\n\nYou can contribute in one of three ways:\n\n1. File bug reports using the [issue tracker](https://github.com/iblues/atu/issues).\n2. Answer questions or fix bugs on the [issue tracker](https://github.com/iblues/atu/issues).\n3. Contribute new features or update the wiki.\n\n_The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable._\n\n## License\n\nMIT","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiblues%2Fatu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiblues%2Fatu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiblues%2Fatu/lists"}