国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達(dá)式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務(wù)器之家 - 編程語言 - PHP教程 - 詳解Yaf框架PHPUnit集成測試方法

詳解Yaf框架PHPUnit集成測試方法

2021-07-24 16:30_xiaoxiong PHP教程

這篇文章主要介紹了詳解Yaf框架PHPUnit集成測試方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

本文介紹了詳解Yaf框架PHPUnit集成測試方法,分享給大家,具體如下:

測試目錄

?
1
2
3
4
5
6
7
8
9
10
test
├── TestCase.php
├── bootstrap.php
├── controller
│  ├── BaseControllerTest.php
│  └── IndexControllerTest.php
├── model
├── phpunit.xml
└── service
  └── TokenServiceTest.php

phpunit.xml

?
1
2
3
4
5
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.2/phpunit.xsd"
     extensionsDirectory="dbunit.phar" bootstrap="./bootstrap.php">
</phpunit>

bootstrap.php 測試框架入口文件

?
1
2
3
define("APP_PATH", realpath(dirname(__FILE__) . '/../'));
date_default_timezone_set("Asia/Shanghai");
define("TEST_DIR", __DIR__);

TestCase.php 測試文件基礎(chǔ)類

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
namespace test;
use PHPUnit\Framework\TestCase as Test;
use Yaf\Application;
class TestCase extends Test
{
  protected static $_application = null;
  protected function setUp()
  {
    self::$_application = $this->getApplication();
    parent::setUp();
  }
 
  public function testAppPath()
  {
    $this->assertEquals('/Users/xiong/Sites/kyYaf', APP_PATH);
  }
 
  public function testApp()
  {
    $this->assertEquals(Application::app(), self::$_application);
  }
 
  public function testApplication()
  {
    $this->assertNotNull(self::$_application);
  }
 
  public function getApplication()
  {
    if (self::$_application == null) {
      $this->setApplication();
    }
    return self::$_application;
  }
 
  public function setApplication()
  {
    $application = new Application(APP_PATH . '/conf/application.ini');
    $application->bootstrap();
    self::$_application = $application;
  }
}

TokenServiceTest.php service類例子

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
namespace Service;
use test\TestCase;
include TEST_DIR . '/TestCase.php';
include APP_PATH . '/application/library/Service/BaseService.php';
include APP_PATH . '/application/library/Service/TokenService.php';
class TokenServiceTest extends TestCase
{
  /**
   * @var TokenService
   */
  protected static $tokenService;
  public function setUp()
  {
    self::$tokenService = TokenService::getInstance();
    parent::setUp();
  }
 
  public function testCreateToken()
  {
    $token = self::$tokenService->createToken('22');
    $this->assertInternalType('array', $token);
    $this->assertInternalType('string', $token['token']);
  }
 
}

BaseControllerTest.php controller類例子

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
namespace test\controller;
include TEST_DIR .'/TestCase.php';
use test\TestCase;
class BaseControllerTest extends TestCase
{
  public function testGetConfigAction()
  {
    $request = new Simple('CLI', '', 'Index', 'getConfig');
    $response = self::$_application->getDispatcher()->returnResponse(true)->dispatch($request);
    $contents = $response->getBody();
    $data = json_decode($contents, true);
    $this->assertInternalType('array', $data);
  }
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。

原文鏈接:http://blog.csdn.net/xiaoxiong_web/article/details/78900463

延伸 · 閱讀

精彩推薦
Weibo Article 1 Weibo Article 2 Weibo Article 3 Weibo Article 4 Weibo Article 5 Weibo Article 6 Weibo Article 7 Weibo Article 8 Weibo Article 9 Weibo Article 10 Weibo Article 11 Weibo Article 12 Weibo Article 13 Weibo Article 14 Weibo Article 15 Weibo Article 16 Weibo Article 17 Weibo Article 18 Weibo Article 19 Weibo Article 20 Weibo Article 21 Weibo Article 22 Weibo Article 23 Weibo Article 24 Weibo Article 25 Weibo Article 26 Weibo Article 27 Weibo Article 28 Weibo Article 29 Weibo Article 30 Weibo Article 31 Weibo Article 32 Weibo Article 33 Weibo Article 34 Weibo Article 35 Weibo Article 36 Weibo Article 37 Weibo Article 38 Weibo Article 39 Weibo Article 40
主站蜘蛛池模板: 亚洲一区 | 免费在线a | 国产偷窥老熟盗摄视频 | 精品亚洲永久免费精品 | 国产成人精品一区二区三区视频 | 国产精品免费一区二区三区四区 | 久久久久国产一区二区三区四区 | 国产尤物一区 | 国产精品久久久久久久久久久天堂 | 日韩在线视频免费观看 | 久久精品日产第一区二区三区 | 午夜影院在线 | 美女一级毛片 | 日韩欧美国产精品综合嫩v 在线视频 中文字幕 | 在线观看特色大片免费网站 | 日韩精品一区二区三区中文字幕 | 日日久 | 国产 日韩 欧美 在线 | 毛片黄片| 久久久久中文字幕 | 国产中文字幕在线观看 | 国产激情 | www日韩| www中文字幕 | 久久久久久一区二区三区 | 黄色片在线免费观看 | jizzxxx日本| 成人免费视频网 | 亚洲精品一区二区 | 亚洲精选一区二区 | 99热在线精品播放 | 二区在线观看 | 日韩爱爱免费视频 | 中文av一区二区 | 日本精品视频一区二区 | 国产精品免费一区二区三区 | 欧美精品在线观看 | 精品一区二区久久久久久久网站 | 99精品网站 | 91最新| 一区二区精品视频 |