PHP code example of andyoung / think-tests

1. Go to this page and download the library: Download andyoung/think-tests 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/ */

    

andyoung / think-tests example snippets


   public function __construct(?string $name = null, array $data = [], string $dataName = '') {
       // 引入需要的环境
       lication/')->initialize();
   
       parent::__construct($name, $data, $dataName);
   }
   

   protected $baseUrl = '';
   

   
   namespace tests;
   
   class BasicTest extends \tests\TestCase {
       public function testBasicFunctions() {
           $this->assertTrue(true);
           $this->assertEquals(2, 1+1);
           $app = new \app\index\controller\Index();
           // 假设 index/index/index 方法返回的字符串中包含 "index"
           $this->assertStringContainsString('index', $app->index());
       }
   
       public function testThinkPHPStyleTests() {
           // 假设我访问 "/" 会看到 "index"
           $this->visit('/')->see('index');
       }
   }
   

   throw new \PHPUnit\Framework\ExpectationFailedException($message);