Skip to content

Commit

Permalink
Merge branch '5.4' into 6.4
Browse files Browse the repository at this point in the history
* 5.4:
  [FrameworkBundle] fixes #54402: Suppress PHP warning when is_readable() tries to access dirs outside of open_basedir restrictions
  return null when message with name is not set
  use local PHP web server to test HTTP stream wrappers
  Bump Symfony version to 5.4.39
  Update VERSION for 5.4.38
  Update CONTRIBUTORS for 5.4.38
  Update CHANGELOG for 5.4.38
  • Loading branch information
xabbuh committed Apr 3, 2024
2 parents 14762b8 + 31acbc4 commit f6816ec
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions Tests/Part/DataPartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,32 +138,35 @@ public function testFromPathWithNotAFile()

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

$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;
$this->assertEquals(substr(base64_encode($content), 0, $maxLineLength), substr($p->bodyToString(), 0, $maxLineLength));
$this->assertEquals(substr(base64_encode($content), 0, $maxLineLength), substr(implode('', iterator_to_array($p->bodyToIterable())), 0, $maxLineLength));
$this->assertEquals('image', $p->getMediaType());
$this->assertEquals('png', $p->getMediaSubType());
$this->assertEquals(new Headers(
new ParameterizedHeader('Content-Type', 'image/png', ['name' => 'logo_symfony_header.png']),
new UnstructuredHeader('Content-Transfer-Encoding', 'base64'),
new ParameterizedHeader('Content-Disposition', 'attachment', ['name' => 'logo_symfony_header.png', 'filename' => 'logo_symfony_header.png'])
), $p->getPreparedHeaders());
try {
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;
$this->assertEquals(substr(base64_encode($content), 0, $maxLineLength), substr($p->bodyToString(), 0, $maxLineLength));
$this->assertEquals(substr(base64_encode($content), 0, $maxLineLength), substr(implode('', iterator_to_array($p->bodyToIterable())), 0, $maxLineLength));
$this->assertEquals('image', $p->getMediaType());
$this->assertEquals('png', $p->getMediaSubType());
$this->assertEquals(new Headers(
new ParameterizedHeader('Content-Type', 'image/png', ['name' => 'logo_symfony_header.png']),
new UnstructuredHeader('Content-Transfer-Encoding', 'base64'),
new ParameterizedHeader('Content-Disposition', 'attachment', ['name' => 'logo_symfony_header.png', 'filename' => 'logo_symfony_header.png'])
), $p->getPreparedHeaders());
} finally {
$process->stop();
}
}

public function testHasContentId()
Expand Down

0 comments on commit f6816ec

Please sign in to comment.