搜索

PythonReactSEOPDF
GitHub Skill

create-functional-test

Create functional test for HTTP controllers and LiveComponents. Use when testing web endpoints, form submissions, API responses, or LiveComponent interactions. Tests make HTTP requests and verify responses/DOM.

Dev-Int☆ 0 仓库 Stars0 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

Create Functional Test

Generate functional test for HTTP controllers and LiveComponents.


When to Use

  • HTTP endpoints (GET/POST/PUT/DELETE)
  • Form submissions
  • LiveComponents
  • API responses

Inputs/Outputs

Input Example Output
controller_class GetArticlesController BC/Tests/Adapters/Controller/.../ControllerNameTest.php
route /admin/articles -
method GET, POST -
fixtures ['ArticleFactory' => 5] -

Process

Step Action
Create Use template: test-functional.php.tpl
Run php bin/phpunit path/to/Test.php
Validate make cs-fixer && make stan && make ta

Structure

Functional Test (extends BaseFunctionalTestCase):

final class ControllerNameTest extends BaseFunctionalTestCase {
    use Factories;

    public function testMethodName(): void {
        // Setup with Foundry (auto-persists)
        EntityFactory::createOne(['name' => 'Test']);

        // Request (use $this->client, NOT static::createClient())
        $this->client->request('GET', '/route');

        // Assertions
        self::assertResponseIsSuccessful();
        self::assertSelectorExists('.element');
    }
}

See: docs/GLOSSARY.md#functional-test for detailed definition


Rules

Setup:

  • Use Foundry (NOT DataBuilder)
  • Foundry auto-persists and commits
  • NO manual repository->save() or $em->flush()

Assertions:

  • HTTP: assertResponseIsSuccessful(), assertResponseRedirects(), assertResponseStatusCodeSame(404)
  • DOM: assertSelectorExists('.class'), assertSelectorTextContains('h1', 'Title'), assertSelectorCount(3, '.item')

CRITICAL:

  • Use $this->client (NOT static::createClient())
  • Extends BaseFunctionalTestCase
  • Use trait Factories
  • Performance: ~550ms/test (DB purge + HTTP request)

Templates

  • test-functional.php.tpl

Location: .claude/templates/


References

  • Functional test definition: docs/GLOSSARY.md#functional-test
  • Testing strategy: docs/testing.md#functional
  • Base test case: src/Shared/Tests/BaseFunctionalTestCase.php

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-01-20
索引更新时间
2026-01-26
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!