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

Structure tests #60

Closed
wants to merge 40 commits into from
Closed

Structure tests #60

wants to merge 40 commits into from

Conversation

tvbeek
Copy link
Contributor

@tvbeek tvbeek commented Oct 1, 2018

After #39 I have been thinking about structuring the tests. In this PR are new test, structure changes and small changes in checks to prevent failures.

What I have done:

  • Move the test to corresponding directories, in fact move all the test for checks to tests/Checks
  • Ignore the phpunit.xml in .gitignore, there is already a phpunit.xml.dist and the phpunit.xml is only to overwrite that file so I suspect it can be safely ignored.
  • Edit the DirectoriesHaveCorrectPermissions, ExampleEnvironmentVariablesAreSet, ExampleEnvironmentVariablesAreUpToDate, LocalesAreInstalled and ServersArePingable check so you don't get an error if you call the message function before the check function on that classes. (Normally that shouldn't happen but it isn't forced so I think it is good to prevent any error)
  • Change a mock result in StorageDirectoryIsLinkedTest to match the real result.
  • Add tests for the next checks:
    • ComposerWithDevDependenciesIsUpToDate
    • ComposerWithoutDevDependenciesIsUpToDate
    • ConfigurationIsCached
    • ConfigurationIsNotCached
    • DebugModeIsNotEnabled
    • MaintenanceModeNotEnabled
    • RoutesAreCached
    • RoutesAreNotCached
  • Add test for the message and name functions on already existing tests
  • Add @group annotations to the tess

Some questions I have:

  • It is possible to use a trait in the test for the message and name function test of the most checks. I didn't do it to make it clear and readable. Is that good or is the use of a trait wanted?
  • Is it wanted that I add a message to the assertInternalType calls for the message and name checks? Now I just be sure that it is working without any problem.
  • I added the group checks to the tests for the checks and also groups for connected tests (Like @group routes ) Is this wanted or not? With the current size of the project I wasn't very sure if it wanted to add.
  • Currently everything is in one PR. Is it wanted to split it? (Like PRs for the changes on the checks, a PR for the structure changes and PRs for the new tests?) And if wanted I can create a new one with more clear commits because I understand some of them aren't very clear.

Todo:

  • Add a test for the PhpExtensionsAreInstalled check, this is the only check without tests so I should like to also add that one.

I should really like to get some feedback on the work that is done. Is something missing? Something done that isn't wanted? Do you see something strange in the code?

tvbeek added 30 commits July 19, 2018 23:06
…r running the other tests, need to find out)
…ck function isn't called and also cover the message and name function in a test
…est and also test the custom database connections config
…a test and update the valid check test with a correct mock result
…essage function is called before the check function
…reSet in a test and prevent an error if the message function is called before the check function
…reUpToDate check in a test and prevent an error if the message function is called before the check function. Also move the test to the directory matching the namespace of the check.
… a test and prevent an error if the message function is called before the check function
@Namoshek
Copy link
Contributor

Namoshek commented Oct 2, 2018

Directory and file based tests could also be tested using vfsStream. Otherwise, nice cleanup!

@tvbeek
Copy link
Contributor Author

tvbeek commented Oct 5, 2018

@Namoshek thanks for the feedback, I totally forgot that package. I have changed it in f3d1267 or did you see other test that could use it?

@tvbeek
Copy link
Contributor Author

tvbeek commented Oct 5, 2018

I have created a test for the PhpExtensionsAreInstalled check, this doesn't cover the whole check because I'm waiting on #61

…rt (Waiting on input from #61 ) and prevent an error if the message function is called before the check function.
…essage function is used before the check function.
Copy link
Contributor

@Namoshek Namoshek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the usage of vfsStream is good. But after having another look at the changes in general, I noticed two things which are commented below.

One test that could receive some more test attention is ServersArePingable, but to be honest, I'm unsure how to cover it without performing actual requests in its current state. It would probably require a rewrite to utilize a PingFactory and stubs or something like that.

tests/Checks/AppKeyIsSetTest.php Show resolved Hide resolved
public function it_find_an_available_function()
{
$systemFunctions = new SystemFunctions();
$this->assertFalse($systemFunctions->isFunctionAvailable('print'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assert does not match the function description, I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, the test was incorrect, I fixed it in f3e3815

@tvbeek
Copy link
Contributor Author

tvbeek commented Oct 9, 2018

@Namoshek thanks for all the feedback, my idea with this PR was to add test and structure but not rewriting existing tests. I feel the problem you describe with the ServersArePingable check and the test for that class. Because it already exist I didn't want to change it yet, and I'm also not sure yet what is the best approach for that check.

@Namoshek
Copy link
Contributor

Namoshek commented Oct 9, 2018

Alright, that sounds reasonable. I'll see if I can improve the ServersArePingable check and its test coverage after the PR got merged.

@tvbeek
Copy link
Contributor Author

tvbeek commented Oct 9, 2018

@Namoshek that sounds like a good idea

I have add more test to also test the include_composer_extensions config flag for the PhpExtensionsAreInstalled check.

@mpociot Do you have any feedback on this PR?

@tvbeek tvbeek changed the title Structure tests, feedback wanted Structure tests Oct 24, 2018
@tvbeek
Copy link
Contributor Author

tvbeek commented Oct 24, 2018

I have merged master in this branch and resolve the merge conflict for composer.json

Is there anything else I need to do?

@tvbeek tvbeek mentioned this pull request Feb 27, 2019
@mpociot
Copy link
Member

mpociot commented Feb 27, 2019

@tvbeek sorry for ignoring the pr so long..I will look at this in depth later today, as the PR is quite big :)

@tvbeek
Copy link
Contributor Author

tvbeek commented Feb 28, 2019

@mpociot that is nice, just let me know if something isn't clear or need to be changed.

@tvbeek
Copy link
Contributor Author

tvbeek commented Jun 24, 2020

@mpociot while cleaning up my GitHub I found this PR. Do you want to take a look or should I just remove it? (Both is fine for me)

@tvbeek
Copy link
Contributor Author

tvbeek commented Aug 18, 2021

Closed because no interaction.

@tvbeek tvbeek closed this Aug 18, 2021
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

Successfully merging this pull request may close these issues.

None yet

3 participants