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

Update http-factory-tests #113

Closed
wants to merge 3 commits into from

Conversation

danopz
Copy link
Member

@danopz danopz commented Aug 2, 2019

Updated the library for our PSR-17 implementation, fixed failing unit tests

@coveralls
Copy link

coveralls commented Aug 2, 2019

Coverage Status

Coverage decreased (-0.0007%) to 99.731% when pulling bc69106 on danopz:http-factory-tests-060 into 3b8dc24 on slimphp:master.

@@ -41,7 +41,7 @@ public function createStream(string $content = ''): StreamInterface
*/
public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface
{
$resource = fopen($filename, $mode);
$resource = @fopen($filename, $mode);
Copy link
Member

Choose a reason for hiding this comment

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

Why is this being silenced?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I know I dont like it too, but fopen is logging a warning in some of the tests which leads phpunit to fail the test.
Also in the next lines we are checking the response of fopen where we are throwing an Exception is case we didnt get a resource.

Copy link
Member

@l0gicgate l0gicgate Aug 3, 2019

Choose a reason for hiding this comment

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

Alright makes sense. Thanks for the explanation.

Edit:
Actually, is there no other way around this? And could you show what the warnings are? Because they’re not showing up on the CI checks.

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently I don't know if we can do something else (more elegenat) here. As we have the PhpFactoryFUnctionOverrides.php we could suppress the warnings just for PHPUnit. Also we are able to disable the transformation of warnings to errors in PHPUnit, either per file, test or in general. (https://stackoverflow.com/a/8412996/3893182)
Until now the warnings are not there because the tests producing the warnings are added with the new version (0.6) of the http-factory-tests library.

The warnings are:

  • fopen(/tmp/http_factory_tests_FChC1g): failed to open stream: No such file or directory
  • fopen(): Filename cannot be empty

Copy link
Member

@l0gicgate l0gicgate Aug 6, 2019

Choose a reason for hiding this comment

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

@danopz Shouldn't we add a file_exists() instead of suppressing the warning?

Copy link
Member Author

Choose a reason for hiding this comment

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

@l0gicgate just had a quick look, using file_exists we would still have the problem that a file exists we just don't have access on. For example the file belongs to a different user and there are no permission for our php user.

Copy link
Member

Choose a reason for hiding this comment

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

@danpopz I'm confused as to why it's trying to open a file that doesn't exist though (/tmp/http_factory_tests_FChC1g). It should exist during the test no? and why are we trying to do fopen() without specifying a filename?

If these tests are written to create failures, then that's just a bad test.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sry should have explained a bit better. The problem Im describing is not about the tests but general. Someone could just use it like I described which would then again produce a warning - sure they should take care about their file system.
If you prefer I could still just add the file_exists.

Copy link
Member

Choose a reason for hiding this comment

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

I'd rather make things as robust as possible with logic rather than silence warnings. They're typically there for a reason and tests should fail in the event that those warnings arise. Let's use file_exists()

Copy link
Member Author

Choose a reason for hiding this comment

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

Now I have the problem of handling php://input and some tests with wrong file mode..

@l0gicgate
Copy link
Member

Closing. #125 was merged.

@l0gicgate l0gicgate closed this Aug 22, 2019
@danopz danopz deleted the http-factory-tests-060 branch August 23, 2019 23:32
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.

4 participants