vendredi 25 septembre 2015

How to unit test my Service implementation Laravel 5?

I want to unit test my ServiceImpl but i dont know how ?

This is my Service :

interface CommentService { public function findAll($class, $classId, ApiRequest $request = null); }

This is my Service Implemantation:

class CommentServiceImpl implements CommentService
{    
public function findAll($class, $classId, ApiRequest $request = null)
    {
        $model = NamespaceConstants::NAMESPACE_CONST . $class;

        $comment = Comment::where('commentable_type', $model)->where('commentable_id', $classId)->get();

        if ($request != null) {
            $comment->load($request->getRelations());
        }

        return $comment;
    }
}

Aucun commentaire:

Enregistrer un commentaire