xiaohuilam / ultimate-debug-tool
Installs: 620
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 1
Language:HTML
Requires
- php: >=5.6
- ext-json: *
Requires (Dev)
- phpunit/phpcov: ~2.0|~3.0
- phpunit/phpunit: ~4.0|~5.0
README
The perfect function based test toolkit fot PHP composer projects.
Instsallation
composer require xiaohuilam/ultimate-debug-tool:"dev-master"
往 config/app.php
的 providers
添加如下
Xiaohuilam\UltDebug\ServiceProvider::class,
Usage
<?php use Xiaohuilam\UltDebug\App; use Xiaohuilam\UltDebug\RegExp; use Xiaohuilam\UltDebug\Store; use Xiaohuilam\UltDebug\StoreGet; use Xiaohuilam\UltDebug\StoreSet;
public function YourControllerAction() { $debug = new App(); $debug->appendGroup('Group 1', [ [ 'Register' => [ 'Captcha' => [ 'url' => '/user/captcha', 'data' => [ ], 'done' => [ Store::set('captcha_ticket', 'json.data.captcha_ticket'), // After success, response data will be named into `json`, and store `json.data.captcha_ticket` into captcha_ticket as this line demands. ] ], 'Sms' => [ 'url' => '/user/register/sms', 'data' => [ 'phone' => RegExp::make('/^1[34578][\d]{9}$/'), // UltDebugKit will generate a mokery data for you 'captcha' => '1234', // Static string data 'captcha_ticket' => Store::get('captcha_ticket'), // Previously saved data named captcha_ticket in the step of 'Captcha' ], 'done' => [ Store::set('phone', 'param.phone'), Store::set('sms_ticket', 'json.data.sms_ticket'), ] ], 'Submit Register' => [ 'url' => '/user/register', 'data' => [ 'phone' => Store::get('phone'), 'password' => RegExp::make('/^[\w]{16}$/'), 'code' => '1234', 'sms_ticket' => Store::get('sms_ticket'), ], 'done' => [ Store::set('uid', 'json.data.user.id'), Store::set('password', 'param.password'), // Save data from parameters of this step-request ] ], ], 'Login' => [ 'Captcha' => [ 'url' => '/user/captcha', 'data' => [ ], 'done' => [ Store::set('captcha_ticket', 'json.data.captcha_ticket'), ] ], 'Submit Login' => [ 'url' => '/user/login', 'data' => [ 'username' => Store::get('phone'), 'password' => Store::get('password'), 'captcha' => '1234', 'captcha_ticket' => Store::get('captcha_ticket'), ], 'done' => [ Store::set('authorization', 'json.data.authorization'), ] ] ], ] ]); echo $debug->render(); }