如何在php

时间:2019-02-11 06:55:17

标签: php unit-testing cookies

如何为类代码编写单元测试? 我编写测试时也遇到此错误
“ session_start():标头已发送时无法启动会话”

class Cookie
{
    function __construct()
    {
        session_start();
    }
    public static function isthere($name)
    {
        return (isset($_COOKIE[$name])) ? true : false;
    }

    public static function get($name)
    {
        return $_COOKIE[$name];
    }

    public static function create($name,$valu,$time)
    {
        if(setcookie($name,$valu,time() + $time,'/')){
            return true;
        }else{
            return false;
        }
    }

    public static function delete($name)
    {
        self::create($name,'',time()-1);
    }
}

0 个答案:

没有答案