Skip to content

Commit

Permalink
Merge branch '7.0' into 7.1
Browse files Browse the repository at this point in the history
* 7.0:
  preserve the file modification time when mirroring directories
  use local PHP web server to test HTTP stream wrappers
  • Loading branch information
xabbuh committed Mar 22, 2024
2 parents 292008b + ed617c8 commit bff8e08
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/Symfony/Component/Filesystem/Filesystem.php
Expand Up @@ -72,6 +72,9 @@ public function copy(string $originFile, string $targetFile, bool $overwriteNewe
// Like `cp`, preserve executable permission bits
self::box('chmod', $targetFile, fileperms($targetFile) | (fileperms($originFile) & 0111));

// Like `cp`, preserve the file modification time
self::box('touch', $targetFile, filemtime($originFile));

if ($bytesCopied !== $bytesOrigin = filesize($originFile)) {
throw new IOException(sprintf('Failed to copy the whole content of "%s" to "%s" (%g of %g bytes copied).', $originFile, $targetFile, $bytesCopied, $bytesOrigin), 0, null, $originFile);
}
Expand Down
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(), true)) {
$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 @@ -25,6 +25,7 @@
"league/html-to-markdown": "^5.0",
"phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0",
"symfony/dependency-injection": "^6.4|^7.0",
"symfony/process": "^6.4|^7.0",
"symfony/property-access": "^6.4|^7.0",
"symfony/property-info": "^6.4|^7.0",
"symfony/serializer": "^6.4|^7.0"
Expand Down

0 comments on commit bff8e08

Please sign in to comment.