For service methods that call repository methods to interact with database how could I unit test these service methods?
For example,
public function updateSlideshow($data){
// do some logic and method calls (I can test those methods,
// but for this method that call repository ...)
$r = $this->blockRepo->update($data, $config, $slides);
}
How can I check that this method work correctly or at least send right data to update method?
And what about a scenario that method first fetch data from repository and do logic on it?
updateSlideshow
, you are not testing theRepository::update
method. If you want to test that one, create a specific test only for it. You can also use integration testing to test the whole flow, note that integration tests have side effects.