2017-10-23 11 views
0

これは私の方法GuzzleHttp Clientクラスのオブジェクトを文字列に変換できなかった理由を教えてください。

class MyClass 
{ 
    protected client; 
    public function setCl($clientArg) 
    { 
    // check for invalid argument type - client has to be a guzzle client 
    if ($clientArg.get_class() != $this->client.get_class() || 
     !($clientArg instanceof GuzzleHttp\Client)) 
     throw new InvalidArgumentException("Argument type must be of Guzzle client"); 

    $this->client = $clientArg; 
    } 
} 

あるテストは、次のような、このメソッドを呼び出した:

class TestClass extends \PHPUnit_Framework_TestCase 
{ 
    protected $myClass 
    public function testSetCl() { 
    $cl = new Client(); 
    $res = $this->myClass->setCl($cl); // why does a setter need to return something? 

    $this->assertInstanceOf(Client::class, $res); 
    } 
} 

タイトルで掲載エラーは、私がテストを実行したときに、私が受け取るものです。どうして? PHPで

$clientArg.get_class() != $this->client.get_class() 

、:これが発生

答えて

0

理由はラインです。したがって、連結されている場合:

$clientArg->get_class() != $this->client->get_class() 

これは機能します。

関連する問題