ksfraser/famock 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ksfraser/famock

Composer 安装命令:

composer require ksfraser/famock

包简介

FrontAccounting function mocks for unit testing

README 文档

README

FrontAccounting function mocks for unit testing PHP modules that depend on FrontAccounting functions.

Purpose

When writing unit tests for FrontAccounting modules, you often need to mock FA-specific functions that are not available in the test environment. FAMock provides stub implementations of these functions so your tests can run without requiring a full FA installation.

Installation

Option 1: Packagist (when published)

composer require ksfraser/famock --dev

Option 2: GitHub Repository (requires authentication)

Add to your composer.json:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/ksfraser/FAMock.git"
        }
    ],
    "require-dev": {
        "ksfraser/famock": "dev-main"
    }
}

Note: Requires GitHub authentication token for private repositories.

Option 3: Local Path (recommended for development)

{
    "repositories": [
        {
            "type": "path",
            "url": "../path/to/FAMock-repo"
        }
    ],
    "require-dev": {
        "ksfraser/famock": "*"
    }
}

Usage

In your test bootstrap or test file:

require_once 'vendor/ksfraser/famock/php/FAMock.php';

This will load all FA function stubs.

Available Stubs

Database Functions (FaDbStubs.php)

  • db_query() - Mock database queries
  • db_escape() - Mock string escaping
  • db_fetch() - Mock result fetching

UI Functions (FaUIStubs.php)

  • start_form(), end_form() - Form HTML output
  • start_table(), end_table() - Table HTML output
  • text_row(), check_row() - Form input helpers
  • display_notification(), display_error() - Message display
  • page(), end_page() - Page structure

Hook System (FaHookStubs.php)

  • fa_hooks() - Mock hook manager
  • $path_to_root - Mock global path variable

Security Functions (FaSecurityStubs.php)

  • user_check_access() - Always returns true
  • add_access_extensions() - No-op

Session/Company (FaSessionStubs.php)

  • get_company_pref() - Mock company preferences
  • $_SESSION['wa_current_user'] - Mock user session

Preferences (FaUpdateOnlyStubs.php)

  • get_company_prefs() - Get mock preferences
  • update_company_prefs() - Update mock preferences

Mock Classes

  • Ksfraser\FAMock\MockDatabase - PHPUnit mock implementing DatabaseInterface

Contributing

When adding new FA function mocks:

  1. Create a new stub file following the SRP pattern (e.g., FaNewCategoryStubs.php)
  2. Use if (!function_exists('function_name')) to check if already defined
  3. Add the file to FAMock.php
  4. Update this README

Publishing

To publish to Packagist:

  1. Push to GitHub: git push origin main
  2. Go to https://packagist.org/packages/submit
  3. Submit the GitHub repository URL: https://github.com/ksfraser/FAMock
  4. Tag a release: git tag v0.2.0 && git push --tags

Once published, users can install with: composer require ksfraser/famock --dev

Current Status: FAMock is ready for publishing but currently uses local path installation for development.

ksfraser/famock 适用场景与选型建议

ksfraser/famock 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 33 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 ksfraser/famock 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ksfraser/famock 我们能提供哪些服务?
定制开发 / 二次开发

基于 ksfraser/famock 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 33
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 26
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-06