• Deepin下phpunit安装,以及执行过程中所遇到的问题


    Deepin下phpunit安装,以及执行过程中所遇到的问题

    安装phpunit步骤

    wget https://phar.phpunit.de/phpunit.phar
    
    chmod +x phpunit.phar
    
    sudo mv phpunit.phar /usr/local/bin/phpunit
    

    测试代码

    <?php
    require_once 'GetUser.class.php';
    class GetUserTest extends PHPUnit_Framework_TestCase
    {
        public function testGetUser()
        {
            $test = new GetUser();
            $test->getUserTest("sa");
        }
    }
    

    GetUser.class.php

    <?php
    /**
     * Created by PhpStorm.
     * User: linmouren
     * Date: 2016/12/6
     * Time: 23:40
     */
    header("content-type:text/html; charset=utf-8");
    class GetUser//modify here!
    {
        public function getUserTest($userName = ''){
            $con = new mysqli('localhost','root','beijingkaoya','buyTogether');//modify here!
            if($con->connect_error){
                die('Error : ('. $con->connect_errno .') '. $con->connect_error);
            }else{
                $con->query("SET NAMES utf8");
                $sql = "SELECT userName,phoneNumber,emailAddress,sex,name,birthday,school,occupation,headPortait,description FROM User WHERE userName='$userName';";
                $res = $con->query($sql);
                if($res){
                    $data = $res->fetch_assoc();
                    $success = true;
                    $message = '获取成功';
                }else{
                    $data = null;
                    $success = false;
                    $message = '请重试';
                }
                $arr = array(
                    'success' => $success,
                    'message' => $message,
                    'data' => $data
                );
    
                //echo json_encode($arr,JSON_UNESCAPED_UNICODE);
                //echo json_decode($arr);
                echo json_encode($arr,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
            }
            mysqli_close($con);
        }
    }
    

    测试过程

    遇到了问题

    Error: Class 'mysqli' not found
    

    解决方法

    sudo apt-get install php-mysqli
    

    成果

  • 相关阅读:
    About HDFS blocks
    Hadoop源代码分析(一)
    Hadoop源代码分析(三)
    MapReduce基础
    Pig安装与配置教程
    MapReduce数据流(三)
    MapReduce数据流(二)
    c++中的临时对象
    如何修改CMD命令行窗口下的默认路径
    VC2005: warning LNK4076: 无效的增量状态文件
  • 原文地址:https://www.cnblogs.com/wpqwpq/p/6175715.html
Copyright © 2020-2023  润新知