定制 axitbv/laravel-blueprint-streamlined-test-addon 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

axitbv/laravel-blueprint-streamlined-test-addon

Composer 安装命令:

composer require axitbv/laravel-blueprint-streamlined-test-addon

包简介

Swap Blueprint's TestGenerator with my own *too fancy* and *too specific*, *streamlined* tests for API Resource Controllers

README 文档

README

Latest Version on Packagist Build Status Quality Score Total Downloads

Swaps Blueprint's TestGenerator with my own too fancy and too specific, streamlined tests for API Resource Controllers.

Installation

You can install the package via composer:

composer require laravel-shift/blueprint axitbv/laravel-blueprint-streamlined-test-addon

Usage

Create your blueprint draft.yaml as usual. In order to generate the streamlined tests that this package provides, be sure to include the resource: api shorthand in your controllers: section:

models:
  Certificate:
    name: string
    certificate_type_id: id
    reference: string
    document: string
    expiry_date: date
    remarks: nullable text
  CertificateType:
    name: string
    relationships:
      hasMany: Certificate

controllers:
  Certificate:
    resource: api
  CertificateType:
    resource: api

This resource: api shorthand expands to generate an API resource controller, form requests, resources and resource collections. Yet, instead of the broken tests that currently come out of the box with Blueprint, it will provide you with a very opinionated, yet working testsuite for the geneated code, with 100% code coverage.

php artisan blueprint:build

Which will yield:

- database/migrations/2020_07_01_073301_create_certificates_table.php
- database/migrations/2020_07_01_073302_create_certificate_types_table.php
- app/Certificate.php
- app/CertificateType.php
- database/factories/CertificateFactory.php
- database/factories/CertificateTypeFactory.php
- app/Http/Controllers/CertificateController.php
- app/Http/Controllers/CertificateTypeController.php
- app/Http/Requests/CertificateStoreRequest.php
- app/Http/Requests/CertificateUpdateRequest.php
- app/Http/Requests/CertificateTypeStoreRequest.php
- app/Http/Requests/CertificateTypeUpdateRequest.php
- app/Http/Resources/CertificateCollection.php
- app/Http/Resources/Certificate.php
- app/Http/Resources/CertificateTypeCollection.php
- app/Http/Resources/CertificateType.php
- tests/Feature/Http/Controllers/CertificateControllerTest.php
- tests/Feature/Http/Controllers/CertificateTypeControllerTest.php

Then, either run php artisan test:

❯ php artisan test                                                            

   PASS  Tests\Unit\ExampleTest
  ✓ basic test

   PASS  Tests\Feature\ExampleTest
  ✓ basic test

   PASS  Tests\Feature\Http\Controllers\CertificateControllerTest
  ✓ index behaves as expected
  ✓ store uses form request validation
  ✓ store saves
  ✓ show behaves as expected
  ✓ update uses form request validation
  ✓ update behaves as expected
  ✓ destroy deletes and responds with

   PASS  Tests\Feature\Http\Controllers\CertificateTypeControllerTest
  ✓ index behaves as expected
  ✓ store uses form request validation
  ✓ store saves
  ✓ show behaves as expected
  ✓ update uses form request validation
  ✓ update behaves as expected
  ✓ destroy deletes and responds with

  Tests:  16 passed
  Time:   0.55s

Or use phpunit:

❯ phpunit --coverage-text                                                                                                                                                                                                         72%
PHPUnit 8.5.8 by Sebastian Bergmann and contributors.

................                                                  16 / 16 (100%)

Time: 668 ms, Memory: 30.00 MB

OK (16 tests, 28 assertions)


Code Coverage Report:
  2020-07-01 07:41:44

 Summary:
  Classes: 51.85% (14/27)
  Methods: 64.58% (31/48)
  Lines:   63.16% (60/95)

\App\Console::App\Console\Kernel
  Methods:  50.00% ( 1/ 2)   Lines:  75.00% (  3/  4)
\App\Http\Controllers::App\Http\Controllers\CertificateController
  Methods: 100.00% ( 5/ 5)   Lines: 100.00% (  9/  9)
\App\Http\Controllers::App\Http\Controllers\CertificateTypeController
  Methods: 100.00% ( 5/ 5)   Lines: 100.00% (  9/  9)
\App\Http\Requests::App\Http\Requests\CertificateStoreRequest
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% (  2/  2)
\App\Http\Requests::App\Http\Requests\CertificateTypeStoreRequest
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% (  2/  2)
\App\Http\Requests::App\Http\Requests\CertificateTypeUpdateRequest
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% (  2/  2)
\App\Http\Requests::App\Http\Requests\CertificateUpdateRequest
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% (  2/  2)
\App\Http\Resources::App\Http\Resources\Certificate
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  7/  7)
\App\Http\Resources::App\Http\Resources\CertificateCollection
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  1/  1)
\App\Http\Resources::App\Http\Resources\CertificateType
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  2/  2)
\App\Http\Resources::App\Http\Resources\CertificateTypeCollection
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  1/  1)
\App\Providers::App\Providers\AppServiceProvider
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% (  2/  2)
\App\Providers::App\Providers\AuthServiceProvider
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  2/  2)
\App\Providers::App\Providers\EventServiceProvider
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  2/  2)
\App\Providers::App\Providers\RouteServiceProvider
  Methods: 100.00% ( 4/ 4)   Lines: 100.00% ( 14/ 14)

For code coverage reporting, install PCOV using pecl install pcov and invoke phpunit with --coverage-text.

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email j.jacobs@xit.nl instead of using the issue tracker.

Credits

Big Thank You To

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

  • Stars: 13
  • Watchers: 2
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-07-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固