Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REST] Module does not reset client before each request #96

Open
ihorsamusenko opened this issue Nov 29, 2017 · 8 comments
Open

[REST] Module does not reset client before each request #96

ihorsamusenko opened this issue Nov 29, 2017 · 8 comments

Comments

@ihorsamusenko
Copy link

What are you trying to achieve?

I write a test which makes several request

$I->sendPOST('/my/url/test');
$I->sendGET('/my/url/test');

What do you get instead?

When I call $I->sendGET('/my/url/test'); it goes to '/my/url/my/url/test' instead of '/my/url/test'

I use REST as follows:

REST:
    depends: Symfony
@Naktibalda
Copy link
Member

Are you sure that you haven't missed a leading / in the second request?

@ihorsamusenko
Copy link
Author

Absolutely sure

@Naktibalda
Copy link
Member

What version of Codeception are you using?

@ihorsamusenko
Copy link
Author

Sorry for not providing the version at the first place.
2.3.6

@ihorsamusenko
Copy link
Author

ihorsamusenko commented Nov 30, 2017

@Naktibalda any thoughts so far? I think we need to reset the client inside REST module before each sendPOST, sendGET and other send* methods.

@Naktibalda
Copy link
Member

Works for me.

I have tried to reproduce your issue: Naktibalda/codeception-symfony-tests@11e34fb

$I->sendGET('/posts/1');
$I->seeResponseEquals('Show Post Codeception/Codeception#1');
$I->sendPOST('/doctrine/create-user',['name' => 'John']);
$I->seeResponseEquals('User created');
$I->seeCurrentUrlEquals('/doctrine/create-user');

but I got expected result:

./vendor/bin/codecept run tests/functional/SecondUriIsNotAppendedToFirstUriCept.php --steps
Codeception PHP Testing Framework v2.3.6
Powered by PHPUnit 4.8.36 by Sebastian Bergmann and contributors.

Functional Tests (1) -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Testing functional
SecondUriIsNotAppendedToFirstUriCept: 
Signature: SecondUriIsNotAppendedToFirstUriCept
Test: tests/functional/SecondUriIsNotAppendedToFirstUriCept.php
Scenario --
 I send get "/posts/1"
 I see response equals "Show Post Codeception/Codeception#1"
 I send post "/doctrine/create-user",{"name":"John"}
 I see response equals "User created"
 I see current url equals "/doctrine/create-user"
 PASSED 

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

@Naktibalda
Copy link
Member

There was a similar issue report before: Codeception/Codeception#2987
But he had no leading / in uri.

@jackd248
Copy link

Hej there,
I having the same problem like @ihorsamusenko. I wanted to test an array of different filter options for an api route.
Unfortunately there seems to be an issue with sending multiple (get?) requests within one function. The response is not resetted, so the response data (and also the execution time) will be increase exponentially. The solution seems to be that all requests need to declared in a separate declared function.
(And there is a leading / within the uri)

@Naktibalda Naktibalda reopened this Mar 30, 2023
@Naktibalda Naktibalda transferred this issue from Codeception/Codeception Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants