PHP code example of aspirantzhang / thinkphp6-unit-test
1. Go to this page and download the library: Download aspirantzhang/thinkphp6-unit-test 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/ */
aspirantzhang / thinkphp6-unit-test example snippets
$this->startRequest();
$yourController = new YourController($this->app);
$this->startApp();
public function testAdminHome()
{
$this->startRequest();
$adminController = new AdminController($this->app);
$response = $adminController->home();
$this->assertEquals(200, $response->getCode());
}
// get with no param
$this->startRequest();
// get with param
$this->startRequest('GET', ['trash' => 'onlyTrashed']);
// post with data
$this->startRequest('POST', ['type' => 'delete', 'ids' => [1]]);
// put with data
$this->startRequest('PUT', ['display_name' => 'Admin']);
// mock localization
$this->mockLang('zh-cn');
// close mock localization
$this->endMockLang();
$this->endRequest();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.