Skip to content

Allow UploadedFile to be of size zero #48

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

Merged
merged 3 commits into from
Apr 7, 2023
Merged

Conversation

Zegnat
Copy link
Contributor

@Zegnat Zegnat commented Mar 9, 2021

Q A
Bug fix? yes
New feature? no
BC breaks? no?
Deprecations? no
Related tickets none
Documentation n/a
License MIT

What's in this PR?

Patch to allow an UploadedFile instance to pass testing when it returns a (valid) integer of 0 (zero) as its size.

Why?

I ran into a problem when I was giving the integration tests an UploadedFile instance with an empty Stream within. At this point getSize() will return 0, which does not pass the first if, and therefor fails the test as 0 !== null.

Example Usage

class UploadedFileTest extends \Http\Psr7Test\UploadedFileIntegrationTest
{
    public function createSubject()
    {
        $stream = (new \Nyholm\Psr7\Factory\Psr17Factory())->createStream();
        return (new \Nyholm\Psr7\Factory\Psr17Factory())->createUploadedFile($stream);
    }
}

// 1) UploadedFileTest::testGetSize
// Failed asserting that 0 is null.

Copy link
Contributor

@dbu dbu left a comment

Choose a reason for hiding this comment

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

thank you!

@dbu dbu merged commit 201aeb5 into php-http:master Apr 7, 2023
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.

2 participants