globegroup/api-test-case 问题修复 & 功能扩展

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

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

globegroup/api-test-case

Composer 安装命令:

composer require globegroup/api-test-case

包简介

GlobeGroup Functional Unit Tests Library for Symfony ^4.3

README 文档

README

composer require globegroup/api-test-case --dev

Every Functional test that you make for your API should extend GlobeGroup\ApiTest\ApiTestCase

This library allows you to easily load fixtures per every test, and restarts the database on before each test.

Installation

Create services.yml file under config/packages/test/

touch config/packages/test/services.yaml

Paste configuration to your newly created services.yml:

services:
  # Here comes configuration for oAuth
  test.oauth.user:
    class: App\Entity\User\User #your user entity
    public: true
    autowire: true

  test.oauth.client:
    class: App\Entity\OAuth2\Client #your oauth client entity
    public: true
    autowire: true

  test.oauth.token:
    class: App\Entity\OAuth2\AccessToken #your oauth access token entity
    public: true
    autowire: true

Using

Create new test case that will test one endpoint (ws) that name will tell what is does like:

  • ListingModelTest for testing lists,
  • CreatingModelTest for testing creation of entities or models,
  • DeletingModelTest for removing, marking as deleted or unassigning,
  • FetchingModelTest for showing one model/entity,


Every test has to explain what it does in use-case, good practice is to write them as `snake_case` Here are some examples:
/** @test */
function only_authorized_user_can_list_products() {
 ... your test goes here
}
  /** @test */
  function name_is_required() {
   ... your test goes here
  }
/** @test */
function not_found_when_no_category_provided() {
 ... your test goes here
}

Changelog:

  • v0.1 - ApiTestCase, Traits, loading fixtures, asserting json, asserting status code
  • v1.0 - added oauth login, fixed array subset assertion, debug trait, changed to work in transaction
  • v1.1 - changed to webtestcase
  • v1.2 - added new fixtures way and fixed few problems

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固