Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[BUG][FLEX][3.4] Problem to execute PhpUnit #27439

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

Closed
Nsbx opened this issue May 31, 2018 · 3 comments
Closed

[BUG][FLEX][3.4] Problem to execute PhpUnit #27439

Nsbx opened this issue May 31, 2018 · 3 comments

Comments

@Nsbx
Copy link
Contributor

Nsbx commented May 31, 2018

Symfony version(s) affected: Flex 3.4

Description
After installed symfony/test-pack i can't run phpunit

How to reproduce
Run : composer require --dev test
Write a test
Run : php ./bin/phpunit

Additional context
Logs error : https://hastebin.com/tuyebixizo.tex

Possible Solution
Nothing is indicated on the documentation but i think this is a problem linked to Windows

@Nsbx Nsbx changed the title Problem to execute PhpUnit [BUG][FLEX][3.4] Problem to execute PhpUnit May 31, 2018
@nicolas-grekas
Copy link
Member

ZipArchive::extractTo(): Invalid or uninitialized Zip object

this means the downloaded file is corrupted. Can you have a look at the file to see what it contains locally?
The fix could be to throw a meaningful exception when this occurs. (catching the first warning and turning it into an exception.)

Could you have a look?

@Nsbx
Copy link
Contributor Author

Nsbx commented Jun 5, 2018

OK after several tests I found the part that doesn't work, but this is a little bit strange so i want your advise before commit anything.

for begining i have edited the file in "\vendor\symfony\phpunit-bridge\bin\simple-phpunit" and i have added exceptions for the zip file

And after launch i have the exception "no such file"

So i looked the part that download the file :

if (extension_loaded('openssl') && ini_get('allow_url_fopen') && !isset($_SERVER['http_proxy']) && !isset($_SERVER['https_proxy'])) {
        $remoteZip = "https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip";
        $remoteZipStream = @fopen($remoteZip, 'rb');
        if (!$remoteZipStream) {
            throw new \RuntimeException("Could not find $remoteZip");
        }
        stream_copy_to_stream($remoteZipStream, fopen("$PHPUNIT_VERSION.zip", 'wb'));
    } else {
        @unlink("$PHPUNIT_VERSION.zip");
        passthru("wget -q https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip");
    }

and after testing, the script doesn't enter in the condition statement, so i deleted the statement and then everything works out.

the strange part is this test

!isset($_SERVER['http_proxy']) && !isset($_SERVER['https_proxy']) 

In my symfony test app i've got 1 & 1
But in command line i've got nothing so this is why i have this bug

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jun 6, 2018

The logic here is that when an http(s)_proxy is set, we assume that we cannot use fopen() because it won't get through the proxy (it's possible, but requires some non trivial amount of code).

When this happens, we fallback to using wget, which is not available on your setup I suppose.

We could use certutil instead on Windows:
certutil.exe -urlcache -split -f "https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip" $PHPUNIT_VERSION.zip

Would you like to have a try and submit a PR if it works?

@fabpot fabpot closed this as completed Jun 10, 2018
fabpot added a commit that referenced this issue Jun 10, 2018
This PR was submitted for the master branch but it was merged into the 3.4 branch instead (closes #27567).

Discussion
----------

[PhpUnitBridge] Fix error on some Windows OS

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #27439
| License       | MIT

Bug Fix on PHPUnit Bridge

Commits
-------

50979b5 [PhpUnitBridge] Fix error on some Windows OS
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

No branches or pull requests

3 participants