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

Add tests for read/write (cursor) position on Stream #39

Merged
merged 3 commits into from Oct 10, 2023

Conversation

Zegnat
Copy link
Contributor

@Zegnat Zegnat commented Jan 3, 2019

Having Stream instances with different cursor positions come out of the factories depending on implementation breaks interoperability. Simple example: calling getContents() on a factory created Stream can give different results.

This adds tests to check interoperability between implementations. See [PSR-17] Define where the file position indicator (cursor) ends up to ensure Stream compatibility on the mailing list for more background.

Note that these tests are based on current implementations and not on any strict definitions by the PSR-17 Working Group. This is because nothing is written about file positions at all.

The test for StreamFactoryInterface::createStream() is marked as incomplete as there is no clear consensus among implementations. This can either be accepted into this repository as an incomplete test, or can not be merged by omitting 4f49487 from the merge.

Not sure what the policy is on these types of tests. But thought I would get the ball rolling with a PR anyway!

Assure that a Stream created from a file will have the file position in
the same place as a native PHP fopen call.
Assure that a Stream created from an existing resource will have the
file position in the same place as the original resource.
Assure that a Stream created from a string will have the file position
set to the end of the body. This matches the result of writing to a
temporary file stream resource.

The test is marked as incomplete as implementations are divided on the
file position and the PSR does not include a clear expectation.
@shadowhand shadowhand merged commit 5bbc4d7 into http-interop:master Oct 10, 2023
@shadowhand
Copy link
Collaborator

Thank you! Sorry it took so long to get this merged.

@Zegnat
Copy link
Contributor Author

Zegnat commented Oct 15, 2023

Amazing to see this land either way! Thanks! 2019 feels so long ago.

@Zegnat Zegnat deleted the stream-cursors branch October 15, 2023 13:17
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

2 participants