|
14 | 14 | use Symfony\Component\Filesystem\Exception\InvalidArgumentException;
|
15 | 15 | use Symfony\Component\Filesystem\Exception\IOException;
|
16 | 16 | use Symfony\Component\Filesystem\Path;
|
| 17 | +use Symfony\Component\Process\PhpExecutableFinder; |
| 18 | +use Symfony\Component\Process\Process; |
17 | 19 |
|
18 | 20 | /**
|
19 | 21 | * Test class for Filesystem.
|
@@ -162,23 +164,32 @@ public function testCopyCreatesTargetDirectoryIfItDoesNotExist()
|
162 | 164 | $this->assertStringEqualsFile($targetFilePath, 'SOURCE FILE');
|
163 | 165 | }
|
164 | 166 |
|
165 |
| - /** |
166 |
| - * @group network |
167 |
| - */ |
168 | 167 | public function testCopyForOriginUrlsAndExistingLocalFileDefaultsToCopy()
|
169 | 168 | {
|
170 |
| - if (!\in_array('https', stream_get_wrappers())) { |
171 |
| - $this->markTestSkipped('"https" stream wrapper is not enabled.'); |
| 169 | + if (!\in_array('http', stream_get_wrappers())) { |
| 170 | + $this->markTestSkipped('"http" stream wrapper is not enabled.'); |
172 | 171 | }
|
173 |
| - $sourceFilePath = 'https://symfony.com/images/common/logo/logo_symfony_header.png'; |
174 |
| - $targetFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_target_file'; |
175 | 172 |
|
176 |
| - file_put_contents($targetFilePath, 'TARGET FILE'); |
| 173 | + $finder = new PhpExecutableFinder(); |
| 174 | + $process = new Process(array_merge([$finder->find(false)], $finder->findArguments(), ['-dopcache.enable=0', '-dvariables_order=EGPCS', '-S', '127.0.0.1:8057'])); |
| 175 | + $process->setWorkingDirectory(__DIR__.'/Fixtures/web'); |
177 | 176 |
|
178 |
| - $this->filesystem->copy($sourceFilePath, $targetFilePath, false); |
| 177 | + $process->start(); |
179 | 178 |
|
180 |
| - $this->assertFileExists($targetFilePath); |
181 |
| - $this->assertEquals(file_get_contents($sourceFilePath), file_get_contents($targetFilePath)); |
| 179 | + do { |
| 180 | + usleep(50000); |
| 181 | + } while (!@fopen('http://127.0.0.1:8057', 'r')); |
| 182 | + |
| 183 | + try { |
| 184 | + $sourceFilePath = 'http://localhost:8057/logo_symfony_header.png'; |
| 185 | + $targetFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_target_file'; |
| 186 | + file_put_contents($targetFilePath, 'TARGET FILE'); |
| 187 | + $this->filesystem->copy($sourceFilePath, $targetFilePath, false); |
| 188 | + $this->assertFileExists($targetFilePath); |
| 189 | + $this->assertEquals(file_get_contents($sourceFilePath), file_get_contents($targetFilePath)); |
| 190 | + } finally { |
| 191 | + $process->stop(); |
| 192 | + } |
182 | 193 | }
|
183 | 194 |
|
184 | 195 | public function testMkdirCreatesDirectoriesRecursively()
|
|
0 commit comments