unit testing - PHPUnit mock concatenated function -
i writing test , wondering how mock next concatenated funciton call:
$validator->errors()->all()   i not need errors collection, want emmpty $this->logerror isn't called.
is possible mock $validator->errors()->all() in 1 call ?
something like
    validator::shouldreceive('errors()->all()')         ->once()         ->andreturn(array());   code: // class      $validator = validator::make(             ['participant' => $participant'],             $programvalidator->getrules()     );      if($validator->fails()) {         foreach($validator->errors()->all() $error) {            $this->logerror($record, $error);     }   // test validator::shouldreceive('make')             ->once()             ->andreturn(mockery::mock(array('fails' => true)));      
have tried:
validator::shouldreceive('errors->all')     ->once()     ->andreturn(array());   this answer might relevant: https://stackoverflow.com/a/22435748/5072503
Comments
Post a Comment