laravel学院:http://laravelacademy.org/post/238.html

简书:https://www.jianshu.com/p/d8b3ac2c4623

问题解决:https://stackoverflow.com/questions/21726963/laravel-fatal-error-for-testcase-not-found

 

之前添加了这篇文章,一直没有写,今天做下补充

lumen 单元测试

lumen项目根目录下有一个tests文件夹,TestCase.php

<?php

class TestCase extends Laravel\Lumen\Testing\TestCase
{
    /**
     * Creates the application.
     *
     * @return \Laravel\Lumen\Application
     */
    public function createApplication()
    {
        return require __DIR__.'/../bootstrap/app.php';
    }
}

  

新建一个类,实现以下方法

namespace Tests\Admin\User;

class UserTest extends \TestCase
{
public function testUserName()
    {
        $params = [
            'user_id' => 1,
            'nickname' => '测试',
        ];
        $this->json('POST', '/admin/user/nickname/', $params)->seeJson();
        $responseData = json_decode($this->response->content(), true);
        print_r($responseData);
        return $responseData;
    }
}

  

右键类或者方法 RUN 即可

  

 

相关文章:

  • 2022-03-07
  • 2022-12-23
  • 2022-12-23
  • 2022-01-07
  • 2022-01-20
猜你喜欢
  • 2022-12-23
  • 2022-01-11
  • 2021-10-09
  • 2022-01-20
  • 2021-06-27
  • 2022-12-23
  • 2021-12-21
相关资源
相似解决方案