Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHPUnit抗辩人_Php_Phpunit - Fatal编程技术网

PHPUnit抗辩人

PHPUnit抗辩人,php,phpunit,Php,Phpunit,我对PHPUnit比较陌生,我一直在尝试做一个简单的测试,在成功登录时返回true/false。下面是我的源代码 <?php include 'user.php'; class test extends PHPUnit\Framework\TestCase { public function login($username, $password) { $user = new user(); $login = $user-&

我对PHPUnit比较陌生,我一直在尝试做一个简单的测试,在成功登录时返回true/false。下面是我的源代码

 <?php
 include 'user.php';

 class test extends PHPUnit\Framework\TestCase
 {
   
    public function login($username, $password)
    {
        $user = new user(); 
        $login = $user-> login($username = 'username1', $password = '123456';
    
        if ($login)
        {
            return true; 
        }
    }  
   
    public function testTrue($username, $password)
    {
        
        if ($actual = (new login())-> login('username1', '123456'))
            
            $this->assertSame($expected = true, $actual);
        else
             
            $this->assertSame($expected = fail, $actual);
        
    }
} 
?>
而不是

if ($actual = (new login())-> login('username1', '123456'))
使用

if ($actual = ($this->login('username1', '123456'))