heybigname / phpspec-testbench
PHPSpec 扩展,用于与 orchestra/testbench 的 Laravel 固件一起使用
Requires
- heybigname/phpspec-laravel: ^4
- orchestra/testbench: ^3.0.0
This package is auto-updated.
Last update: 2024-08-29 04:48:31 UTC
README
从 heybigname/phpspec-testbench
分支,以整合更新的依赖项。
概述
PHPSpec Testbench 基于 benconstable/phpspec-laravel 构建,将通过使用 testbench 提供的 Laravel 应用程序固件来弥合 PHPSpec 和 orchestral/testbench 之间的差距,而不是需要自己完全准备好的 Laravel 应用程序。使用 phpspec-testbench
扩展,您可以轻松地对 Laravel 包进行规范,同时保留 phpspec-laravel
扩展带来的所有功能。
要求
PHPSpec Testbench 针对 Laravel 5 构建,因此依赖于 phpspec-laravel
和 orchestral-testbench
的相应 L5 兼容版本。**PHPSpec Testbench 与 Laravel 4 不兼容**。
安装
只需通过 composer 引入此包
composer require pixelindustries/phpspec-testbench --dev
使用
在您的 phpspec.yml
文件中,只需将 Pixelindustries\PhpspecTestbench\LaravelExtension
添加到 extension
数组中
extensions: - Pixelindustries\PhpspecTestbench\LaravelExtension
请注意,此扩展不应与 phpspec-laravel
扩展一起使用,而应作为替代品。
以上配置后,只需像往常一样编写规范,同时利用 phpspec-laravel
的功能。
自定义应用程序类
如果您需要对应用程序引导执行自定义程序,例如确保您自己的开发服务提供者已注册,您可以在 phpspec.yml
文件中的 laravel_extension
键下使用 app_classname
设置
laravel_extension: app_classname: Acme\Tests\MyCustomApp
这使您能够在 testbench 提供的 getEnvironmentSetUp()
方法中实现自己的程序。例如
<?php namespace Acme\Tests; use Pixelindustries\PhpspecTestbench\App as TestApp; class MyCustomApp extends TestApp { protected function getEnvironmentSetUp($app) { // Custom bootstrapping } }
请注意,您的自定义类 必须 继承 Pixelindustries\PhpspecTestbench\App
类。
感谢
感谢 @BenConstable 为 phpspec-laravel 做出的杰出工作,感谢 @crynobone 为 testbench 做出的出色工作,当然还要感谢其他贡献者和所有报告了这些项目问题与错误的人。