Skills Plugins MCP Prompt Model 博客 我的中心

phpunit-skill

Generates PHPUnit tests in PHP. Covers assertions, data providers, mocking, and test doubles. Use when user mentions "PHPUnit", "TestCase", "assertEquals", "PHP test". Triggers on: "PHPUnit", "TestCase PHP", "assertEquals PHP", "PHP unit test".

DeepseekModel 官方收录技能 质量 优秀 · 78 v1.0.0

获取

https://deepseekmodel.com/api/download.php?id=lambdatest-agent-skills-phpunit-skill-skill-md&format=skill
下载 .skill 标准格式,含 system_prompt 与 model_config,导入任意 Agent 框架即可使用
.skill 文件中 system_prompt 字段的实际内容。
name phpunit-skill description Generates PHPUnit tests in PHP. Covers assertions, data providers, mocking, and test doubles. Use when user mentions "PHPUnit", "TestCase", "assertEquals", "PHP test". Triggers on: "PHPUnit", "TestCase PHP", "assertEquals PHP", "PHP unit test". languages ["PHP"] category unit-testing license MIT metadata {"author":"TestMu AI","version":"1.0"} PHPUnit Testing Skill Core Patterns Basic Test <?php use PHPUnit \ Framework \ TestCase ; class CalculatorTest extends TestCase { private Calculator $calculator ; protected function setUp ( ): void { $this ->calculator = new Calculator (); } public function testAddition ( ): void { $this -> assertEquals ( 5 , $this ->calculator-> add ( 2 , 3 )); } public function testDivideByZero ( ): void { $this -> expectException ( \DivisionByZeroError :: class ); $this ->calculator-> divide ( 10 , 0 ); } public function testMultipleAssertions ( ): void { $this -> assertSame ( 4 , $this ->calculator-> add ( 2 , 2 )); $this -> assertSame ( 0 , $this ->calculator-> subtract ( 2 , 2 )); $this -> assertSame ( 6 , $this ->calculator-> multiply ( 2 , 3 )); } } Data Providers /** * @dataProvider additionProvider */ public function testAdd ( int $a , int $b , int $expected ): void { $this -> assertEquals ( $expected , $this ->calculator-> add ( $a , $b )); } public static function additionProvider ( ): array { return [ 'positive numbers' => [ 2 , 3 , 5 ], 'negative numbers' => [- 1 , - 1 , - 2 ], 'zeros' => [ 0 , 0 , 0 ], 'mixed' => [ 10 , - 5 , 5 ], ]; } Assertions $this -> assertEquals ( $expected , $actual ); $this -> assertSame ( $expected , $actual ); // Strict type $this -> assertNotEquals ( $unexpected , $actual ); $this -> assertTrue ( $condition ); $this -> assertFalse ( $condition ); $this -> assertNull ( $value ); $this -> assertNotNull ( $value ); $this -> assertCount ( 3 , $array ); $this -> assertContains ( 'item' , $array ); $this -> assertArrayHasKey ( 'key' , $array ); $this -> assertInstanceOf ( MyClass :: class , $obj ); $this -> assertStringContainsString ( 'sub' , $string ); $this -> assertMatchesRegularExpression ( '/\d+/' , $string ); $this -> assertEmpty ( $collection ); $this -> assertGreaterThan ( 5 , $value ); $this -> assertJsonStringEqualsJsonString ( $expected , $actual ); Mocking public function testCreateUser ( ): void { $mockRepo = $this -> createMock ( UserRepository :: class ); $mockRepo -> expects ( $this -> once ()) -> method ( 'save' ) -> with ( $this -> isInstanceOf ( User :: class )) -> willReturn ( new User ( 1 , 'Alice' )); $mockEmail = $this -> createMock ( EmailService :: class ); $mockEmail -> expects ( $this -> once ()) -> method ( 'sendWelcome' ) -> with ( 'alice@test.com' ); $service = new UserService ( $mockRepo , $mockEmail ); $result = $service -> createUser ( 'alice@test.com' , 'Alice' ); $this -> assertEquals ( 1 , $result -> getId ()); } Lifecycle public static function setUpBeforeClass ( ): void { } // Once before all protected function setUp ( ): void { } // Before each test protected function tearDown ( ): void { } // After each test public static function tearDownAfterClass ( ): void { } // Once after all Anti-Patterns Bad Good Why assertEquals for strict assertSame for type+value Type coercion No data providers @dataProvider DRY Global state setUp() / tearDown() Isolation No groups @group smoke Run subsets Setup: composer require --dev phpunit/phpunit Run: ./vendor/bin/phpunit or ./vendor/bin/phpunit --group smoke Config: phpunit.xml with testsuites and coverage Deep Patterns See reference/playbook.md for production-grade patterns: Section What You Get §1 Project Setup composer.json, phpunit.xml with suites, coverage config, project structure §2 Test Patterns Assertions, #[DataProvider], Generator yields, strict comparisons §3 Mocking createMock with callbacks, Mockery spies, consecutive returns §4 Test Doubles In-memory fakes, repository pattern, test helpers §5 Faker & Fixtures TestDataFactory with overrides, bulk generation §6 Exception Testing Detailed exception assertions, warning testing §7 HTTP & API Testing Symfony WebTestCase, auth, validation, pagination §8 Database Testing Transaction rollback, repository integration, Doctrine §9 CI/CD Integration GitHub Actions with MySQL/Redis, coverage thresholds §10 Debugging Table 12 common problems with causes and fixes §11 Best Practices 14-item production PHP testing checklist
Agent 识别该技能的关键词,点击任意一个即可复制。

该技能未提供触发词。

下载的 .skill 包内含以下字段。
字段 说明
format格式标识(skill/v1)
skill_id技能唯一 ID
name技能名称
version版本号
description技能描述
category所属分类(数组)
trigger_words触发词列表
tags标签列表
source来源标识
source_url来源链接(本页地址)
exported_at导出时间(每次下载生成)
system_prompt系统提示词正文
model_config模型参数:provider / model / temperature / max_tokens / top_p
examples示例
install_guide各平台导入说明(Coze / Dify / Claude / 自定义框架)
同一份技能可按不同平台格式导出。
.skill 标准格式,含 system_prompt 与 model_config,导入任意 Agent 框架即可使用 下载
.skillpro 增强格式,额外含脚本 / 工具 / 依赖 / 钩子占位 下载
.json 纯 JSON 导出,只含 system_prompt 与模型参数 下载
Coze 带 frontmatter 的 Markdown,Coze 平台导入用 下载
Dify Dify DSL,创建应用后直接导入 下载

每日精选 Skill 推荐,免费送到你邮箱

输入邮箱,每天接收一个精选 AI Agent 技能推荐。完全免费,持续更新。

验证码 --

提交后我们会发送一封确认邮件,点击邮件里的链接才会开始收信。

完全免费,取消任意时间。我们不会发送垃圾邮件。