PHPUnit :: Nasıl ki bir dizi işlev ve kurabiye almak, test edebilirsiniz?

0 Cevap php

PHPUnit :: Nasıl test, bu seti işlev ve tanımlama bilgilerini alabilirsiniz olmadan hatayı alıyorum: başlıklar zaten tarafından gönderilen?

Example bu hata verir:

PHPUnit_Framework_Error_Warning: başlık bilgileri değiştirilemiyor - zaten tarafından gönderilen başlıklar

MyCookie.php

class MyCookie{
public static function createCookie(){
        $uid = null;
        $cookieName='test_cookie';
        if(!isset($_COOKIE[$cookieName])){
            $uid = unique_hash();
            setcookie($cookieName, $uid, 0, '', '', false, true);
        }
        else{
            $uid=$_COOKIE[$cookieName];
        }
        return $uid;
    }
}

MyCookieTest.php

class MyCookieTest extends PHPUnit_Framework_TestCase{
    public function test_createCookie(){
            MyCookie::createCookie();
            assertThat(isset($_COOKIE['test_cookie']), is(true));
            unset($_COOKIE['test_cookie']);
            MyCookie::createCookie();
            assertThat(isset($_COOKIE['test_cookie']), is(true));
    }
}

Teşekkürler

0 Cevap