cristimocean
4 months ago
1058
22
Laravel

policy called only in tests but not from the front end

Posted 4 months ago by cristimocean

In the "make a forum with TDD" tutorial (episode 54) I have that problem from title.

  • In controller > store $this->authorize('create', new Reply); // -- this always gets run

  • In policy file public function create(User $user){ // -- this point is only reached when running tests

So again ... the authorize function does not call the policy when running from front-end (manual browser) but it does run when running tests. Both the tests and the browser make a post request to the controller > store endpoint, in which the authorize is.

Please sign in or create an account to participate in this conversation.