1. Go to this page and download the library: Download yunbuye/thinkphp-testing library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yunbuye / thinkphp-testing example snippets
namespace Tests;
use Yunbuye\ThinkTesting\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
protected $app_path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'application';//指定应用目录
protected $baseUrl = 'http://localhost';
public function __construct($name = null, array $data = [], $dataName = '')
{
use Mockery;
use Mockery\Mock;
$this->instance('think\Cache', Mockery::mock('think\Cache', function ($mock) {
/**
* @var Mock $mock
*/
$return='return';
$key='key';
return $mock->shouldReceive('get')->with($key)->andReturn($return);
}));
use Mockery;
use Mockery\Mock;
$this->mock('think\Cache', function ($mock) {
/**
* @var Mock $mock
*/
$return='return';
$key='key';
return $mock->shouldReceive('get')->with($key)->andReturn($return);
});
use App\Service;
use Mockery\Mock;
$this->spy('think\Cache', function ($mock) {
/**
* @var Mock $mock
*/
$return='return';
$key='key';
return $mock->shouldReceive('get')->with($key)->andReturn($return);
});
namespace Tests;
use Yunbuye\ThinkTesting\TestCase as BaseTestCase;
use Yunbuye\ThinkTesting\Traits\DatabaseTransactions;
abstract class TestCase extends BaseTestCase
{
use DatabaseTransactions;//每次测试回滚数据
protected $app_path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'application';//指定应用目录
protected $baseUrl = 'http://localhost';
public function __construct($name = null, array $data = [], $dataName = '')
{
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.