Remove all keys before running tests
Currently, in the tests (especially KeysAndPermissionsTest.php) we manually remove the created keys using $this->client->deleteKey. This is good, but we can do better.
The idea of this issue is to create a way of doing that for every test. We can use setUp() hook for that.
This will probably break some tests where we rely on the default keys created by Meilisearch automatically, those tests now should set up their own keys before asserting on them.
The expectation is to not use $this->client->deleteKey in every test cases?
As the deleteKey should be executed after completing running the tests, shouldn't we use tearDown hook?
The expectation is to not use $this->client->deleteKey in every test cases?
Yes, we can use hooks for this kind of setup/teardown.
As the deleteKey should be executed after completing running the tests, shouldn't we use tearDown hook?
I agree with you! But we can have the same behavior by using the setUp, I really like this reference from cypress when it comes to why using after hooks is not that good, https://docs.cypress.io/guides/references/best-practices#Using-after-or-afterEach-hooks