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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -