macrominds/website-testing
Composer 安装命令:
composer require --dev macrominds/website-testing
包简介
Cross-Platform Helper for functional testing of websites.
关键字:
README 文档
README
Start built-in php server from php unit test
macrominds/website-testing allows you to start the built-in php server directly inside unit tests or other php scripts. Especially useful for functional testing. Helps to reduce external dependencies and to make your project self-contained.
Usage example
A rough usage overview. See below for a detailed example.
$this->testServer = new EmbeddedServerController(HOST,PORT,DOCROOT,'./tests/web/router.php'); $this->testServer->start(); //... $this->testServer->stopAndWaitForConnectionLoss();
See this projects' phpunit.xml to learn how you can define HOST, PORT and DOCROOT for your own project.
Installing macrominds/website-testing
Recommended: Composer
The recommended installation way is through Composer.
Run the Composer command to add the latest stable version of macrominds/website-testing to your development dependencies:
composer require --dev macrominds/website-testing
or add it to the appropriate section of your composer.json:
"require-dev": { "macrominds/website-testing": "^0.1.0", }
Without Composer
You may as well use macrominds/website-testing without Composer. Just fetch src/EmbeddedServerController.php and then in your php file
require_once('path-to-your/src/EmbeddedServerController.php');
There you go. Ready for the detailed example?
Detailed usage example
Testing the behavior of your web application. This example uses Guzzle as the HTTP client and phpunit. It requires the usage of Composer.
Your composer.json should contain this section:
"require-dev": { "phpunit/phpunit": "^5.3", "macrominds/website-testing": "^0.1.0", "guzzlehttp/guzzle": "^6.2" }
Make sure to update composer:
composer update
use GuzzleHttp\Client; use GuzzleHttp\RequestOptions; use macrominds\website\testing\EmbeddedServerController; class FunctionalPageTest extends \PHPUnit_Framework_TestCase{ /** * * @var EmbeddedServerController */ private static $serverController; private static $client; // setup server public static function setupBeforeClass() { //see phpunit.xml for configuration of PORT, DOCROOT, ROUTERSCRIPT self::$serverController = new EmbeddedServerController('0.0.0.0',PORT,DOCROOT,ROUTERSCRIPT); self::$serverController->start(); $host = self::$serverController->getHost(); $port = PORT; self::$client = new Client([ 'base_uri' => "http://$host:$port" ]); } // tear down server public static function tearDownAfterClass() { if (self::$serverController !== null) { self::$serverController->stopAndWaitForConnectionLoss(); } self::$serverController = null; } // arbitrary tests /** * @test */ public function shouldSendCorrectRedirectHeaders() { // we expect a temporary redirect $this->assertCorrectnessOfRedirectHeader(302); // we expect a permanent redirect $this->assertCorrectnessOfRedirectHeader(301); } private function assertCorrectnessOfRedirectHeader($code) { // our test scenario is setup to answer requests to /301.html // or /302.html with the corresponding redirect. $response = self::$client->get("/$code.html", [ RequestOptions::ALLOW_REDIRECTS=>false ]); $this->assertEquals($code, $response->getStatusCode()); } }
Troubleshooting
If you've got any issues or feature-requests, just add it to the Issues section.
Running the tests from your project root in the first place could help tracking down any issues related to your system.
bin/phpunit -c vendor/macrominds/website-testing/phpunit.xml
Have fun.
macrominds/website-testing 适用场景与选型建议
macrominds/website-testing 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 31 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 04 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「testing」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 macrominds/website-testing 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 macrominds/website-testing 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 macrominds/website-testing 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Testing Suite For Lumen like Laravel does.
The PHP SDK for Checkmango
The testing extension of TYPO3voilà.
Auto-generate dummy data with realistic relationships per Model-like config classes
Dusk extensions for testing
Provided middleware for generating of swagger-documentation file by run testing of RESTful API.
统计信息
- 总下载量: 31
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-04-22