Skip to content

Commit

Permalink
minor #54360 [Mime] use local PHP web server to test HTTP stream wrap…
Browse files Browse the repository at this point in the history
…pers (xabbuh)

This PR was merged into the 5.4 branch.

Discussion
----------

[Mime] use local PHP web server to test HTTP stream wrappers

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Issues        |
| License       | MIT

Commits
-------

7d8f195 use local PHP web server to test HTTP stream wrappers
  • Loading branch information
fabpot committed Mar 21, 2024
2 parents 26ba359 + 7d8f195 commit 914ce1e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/Symfony/Component/Mime/Tests/Fixtures/web/index.php
@@ -0,0 +1 @@
<?php
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 12 additions & 4 deletions src/Symfony/Component/Mime/Tests/Part/DataPartTest.php
Expand Up @@ -18,6 +18,8 @@
use Symfony\Component\Mime\Header\ParameterizedHeader;
use Symfony\Component\Mime\Header\UnstructuredHeader;
use Symfony\Component\Mime\Part\DataPart;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;

class DataPartTest extends TestCase
{
Expand Down Expand Up @@ -134,16 +136,22 @@ public function testFromPathWithNotAFile()
DataPart::fromPath(__DIR__.'/../Fixtures/mimetypes/');
}

/**
* @group network
*/
public function testFromPathWithUrl()
{
if (!\in_array('https', stream_get_wrappers())) {
$this->markTestSkipped('"https" stream wrapper is not enabled.');
}

$p = DataPart::fromPath($file = 'https://symfony.com/images/common/logo/logo_symfony_header.png');
$finder = new PhpExecutableFinder();
$process = new Process(array_merge([$finder->find(false)], $finder->findArguments(), ['-dopcache.enable=0', '-dvariables_order=EGPCS', '-S', '127.0.0.1:8057']));
$process->setWorkingDirectory(__DIR__.'/../Fixtures/web');
$process->start();

do {
usleep(50000);
} while (!@fopen('http://127.0.0.1:8057', 'r'));

$p = DataPart::fromPath($file = 'http://localhost:8057/logo_symfony_header.png');
$content = file_get_contents($file);
$this->assertEquals($content, $p->getBody());
$maxLineLength = 76;
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/Mime/composer.json
Expand Up @@ -26,6 +26,7 @@
"egulias/email-validator": "^2.1.10|^3.1|^4",
"phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0",
"symfony/dependency-injection": "^4.4|^5.0|^6.0",
"symfony/process": "^5.4|^6.4",
"symfony/property-access": "^4.4|^5.1|^6.0",
"symfony/property-info": "^4.4|^5.1|^6.0",
"symfony/serializer": "^5.4.35|~6.3.12|^6.4.3"
Expand Down

0 comments on commit 914ce1e

Please sign in to comment.