-
Notifications
You must be signed in to change notification settings - Fork 175
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
[API] New branch for adding the testsuite for the API + addressed comments #6671
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some change requested.
Overall, I see that you are trying to programatically test each endpoints from an array on strings. Whilst this could be a good way to save lines of code, it creates two really convoluted functions (_allNamesGet and _allNamesPost)
Since we are using PHPUnit to run our test, it is good practice to have a test for each functionality/feature. I would prefer to have a test... function for each endpoint that would allow more specific handling and more control over the cyclomatic complexity of our code. (@johnsaigle)
ex:
public function testCandidatesPOST(): void
{
$payload = ['DoB': "2010-01-01", ....];
$response = $this->_client->request('POST', $this->_base_uri . '/candidates', $payload);
$this->assertEquals($response->getStatus(), '201', 'Candidate not created');
$body = json_decode($response->getBody()->getContent(), true);
$this->assertArrayHasKey($body, 'CandID');
}
Otherwise, if you want to keep the array of endpoints, PHPUnit also provides a Data provider functionality that allows to create an array of parameters and expected results to pass as parameters of tests functions.
see: https://phpunit.readthedocs.io/en/9.0/writing-tests-for-phpunit.html?highlight=generator#data-providers
Thank you for your feedback @xlecours , I'll address your comments soon |
@spell00 will this be ready for the 23 release or should it be rebased to |
@christinerogers It will not be ready for the 23 release |
Ok. please rebase to |
Rebase to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are some comments and suggestions.
It is much more explicit than the previous version 👍
I would recommend changing LorisApiTest.php for LorisApiAuthenticatedTest.php and to use the setUp mechanics of phpUnit so that guzzleLogin do not need to be explicitly called at the begining of each test.
af361d5
to
e7a325e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More changes.
If it is too much to make all the changes, remove the response content shape assertion and we will add them in a subsequent PR.
0cf898a
to
4ba825c
Compare
Many incomplete tests are Incomplete because their is no |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So change requests. Good work so far. Let's keep going!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And some more :)
cde457e
to
f1193b6
Compare
@xlecours as we discussed, the JWT key is now modified in |
…isApiAuthenticatedTest
@driusan This should be good to go. |
oops.. somehow I accidentally dismissed @xlecour's review, not mine.
@spell00 crongrats ! |
Add test suite which uses raisinbread and guzzle to perform integration tests for the API.
Add test suite which uses raisinbread and guzzle to perform integration tests for the API.
Add test suite which uses raisinbread and guzzle to perform integration tests for the API.
Creation of a test suite for the API.