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 9919b55 + 4303603 commit c882f88
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
33 changes: 22 additions & 11 deletions Tests/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use Symfony\Component\Filesystem\Exception\InvalidArgumentException;
use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Filesystem\Path;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;

/**
* Test class for Filesystem.
Expand Down Expand Up @@ -162,23 +164,32 @@ public function testCopyCreatesTargetDirectoryIfItDoesNotExist()
$this->assertStringEqualsFile($targetFilePath, 'SOURCE FILE');
}

/**
* @group network
*/
public function testCopyForOriginUrlsAndExistingLocalFileDefaultsToCopy()
{
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.');
}
$sourceFilePath = 'https://symfony.com/images/common/logo/logo_symfony_header.png';
$targetFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_target_file';

file_put_contents($targetFilePath, 'TARGET FILE');
$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');

$this->filesystem->copy($sourceFilePath, $targetFilePath, false);
$process->start();

$this->assertFileExists($targetFilePath);
$this->assertEquals(file_get_contents($sourceFilePath), file_get_contents($targetFilePath));
do {
usleep(50000);
} while (!@fopen('http://127.0.0.1:8057', 'r'));

try {
$sourceFilePath = 'http://localhost:8057/logo_symfony_header.png';
$targetFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_target_file';
file_put_contents($targetFilePath, 'TARGET FILE');
$this->filesystem->copy($sourceFilePath, $targetFilePath, false);
$this->assertFileExists($targetFilePath);
$this->assertEquals(file_get_contents($sourceFilePath), file_get_contents($targetFilePath));
} finally {
$process->stop();
}
}

public function testMkdirCreatesDirectoriesRecursively()
Expand Down
1 change: 1 addition & 0 deletions Tests/Fixtures/web/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php
Binary file added Tests/Fixtures/web/logo_symfony_header.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"require": {
"php": ">=8.1",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-mbstring": "~1.8"
"symfony/polyfill-mbstring": "~1.8",
"symfony/process": "^5.4|^6.4"
},
"autoload": {
"psr-4": { "Symfony\\Component\\Filesystem\\": "" },
Expand Down

0 comments on commit c882f88

Please sign in to comment.