create-mock-repository
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "create-mock-repository" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-40c17e056bcb013c7a6fb4d731a895f4922e98c02ecd5e587a768136e2b80563. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Generate an in-memory repository implementation for PHP 8.4 tests. Create a mock repository that uses arrays as storage and supports CRUD operations and queries without a real database.
Introduction source: third_party · dykyi-roman · 0.0.1 Reference
SkillPi interpretation
- Tasks
- Generates InMemory repository implementations for PHP 8.4 testing. Creates fake repositories with array storage, supporting CRUD operations and queries without database.
- Testing
- Not tested
Browse files
Frontmatter
name: create-mock-repository
description: Generates InMemory repository implementations for PHP 8.4 testing. Creates fake repositories with array storage, supporting CRUD operations and queries without database.Mock Repository Generator
Generates InMemory (Fake) repository implementations for testing.
Characteristics
- No database — stores entities in memory
- Fast — no I/O operations
- Isolated — fresh state per test
- Deterministic — predictable behavior
- Implements interface — same contract as real repository
Template
<?php
declare(strict_types=1);
namespace Tests\Fake;
use {RepositoryInterface};
use {Entity};
use {EntityId};
final class InMemory{Entity}Repository implements {RepositoryInterface}
{
/** @var array<string, {Entity}> */
private array $entities = [];
public function save({Entity} $entity): void
{
$this->entities[$entity->id()->toString()] = $entity;
}
public function findById({EntityId} $id): ?{Entity}
{
return $this->entities[$id->toString()] ?? null;
}
public function delete({Entity} $entity): void
{
unset($this->entities[$entity->id()->toString()]);
}
/** @return list<{Entity}> */
public function findAll(): array
{
return array_values($this->entities);
}
public function clear(): void
{
$this->entities = [];
}
}
Generation Instructions
-
Read the repository interface:
- Extract all method signatures
- Identify entity type
- Identify ID type
-
Generate InMemory implementation:
- Array storage keyed by ID
- Implement all interface methods
- Add
clear()for test cleanup
-
Handle complex queries:
- Use
array_filterfor criteria - Support specifications if used
- Implement pagination with
array_slice
- Use
-
Add test helpers (optional):
getAll()— access internal statehas(Id $id)— check existencecount()— entity count
-
File placement:
tests/Fake/InMemory{Entity}Repository.php- Or
tests/Double/directory
Best Practices
- Match interface exactly — same method signatures
- Isolate per test — use
clear()in tearDown - Avoid complexity — simple in-memory logic
- Document deviations — if behavior differs from real impl
- Consider thread safety — for parallel tests (usually not needed)
References
references/examples.md— Complete repository examples (User, Order, Product)references/other-fakes.md— EventDispatcher, Mailer, Clock fakes
Current listing version
0.0.1
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 为 PHP 开发者提供测试专用的内存存储库生成方案
- 支持 CRUD 操作和查询,无需数据库依赖
- 适用于单元测试和集成测试场景
Areas to improve
-
description 重复 Reported severity: Minor
description 在 frontmatter 和 body 开头重复出现
Recommendation: 移除 body 开头的自然语言 description,保留 frontmatter 中的即可
Highlights
- 触发词覆盖全面,包含 PHP 8.4、测试、内存存储库等关键词
- 功能边界清晰,不易与其他代码生成类 Skill 混淆
Areas to improve
-
缺少 When to Use 章节 Reported severity: Minor
文档结构完整但缺少明确的使用场景说明章节
Recommendation: 添加 When to Use 章节,说明适用场景和使用时机
Highlights
- 提供完整的 PHP 代码模板,包含命名空间、类型声明等现代 PHP 特性
- Generation Instructions 分步清晰,便于理解和执行
- 包含最佳实践和文件放置建议
Areas to improve
-
复杂查询异常处理不足 Reported severity: Minor
对 array_filter 和 array_slice 等复杂查询场景的异常处理说明不够详细
Recommendation: 补充复杂查询场景下的边界条件处理和异常情况说明
Highlights
- 提供 clear() 方法确保测试隔离性
- 使用严格类型声明和数组类型提示,提高代码质量
- 支持测试辅助方法扩展
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.