R
R
rumasterov2015-10-16 16:29:08
Yii
rumasterov, 2015-10-16 16:29:08

Codeception and Yii2: how to get the user's ip in a functional test?

I want to test user authentication in REST API. Access to api is allowed only from certain ip addresses. The $request->getUserIP() method is called in the code, after which it checks whether the given ip is among the allowed ones.
But in functional tests I have $_SERVER['REMOTE_ADDR'] empty. Accordingly, the test never passes the test.
Has anyone encountered such a situation? Or maybe you need to use acceptance tests? But I would like to somehow check this functionality through a functional test.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Donkovtsev, 2015-10-16
@Demetriy

Probably in this case you need to use Mock objects

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question