Skip to content

Commit

Permalink
Fix Filesystem tests failing in Windows (#32975)
Browse files Browse the repository at this point in the history
* testPutWithStreamInterface() leaves an fopen()
  stream resource that must be explicitly closed
  before temp directories can be deleted in
  Windows.
* testReplaceStoresFiles() fails for multiple
  reasons under Windows. chmod() / umask() write
  permissions don't change and symlink() attempts
  fail in most Windows environments.
  • Loading branch information
derekmd authored May 26, 2020
1 parent a4f74b8 commit cfed253
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 4 additions & 2 deletions tests/Filesystem/FilesystemAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,10 @@ public function testPutWithStreamInterface()
$spy = m::spy($this->filesystem);

$filesystemAdapter = new FilesystemAdapter($spy);
$stream = new Stream(fopen($this->tempDir.'/foo.txt', 'r'));
$filesystemAdapter->put('bar.txt', $stream);
$stream = fopen($this->tempDir.'/foo.txt', 'r');
$guzzleStream = new Stream($stream);
$filesystemAdapter->put('bar.txt', $guzzleStream);
fclose($stream);

$spy->shouldHaveReceived('putStream');
$this->assertEquals('some-data', $filesystemAdapter->get('bar.txt'));
Expand Down
16 changes: 15 additions & 1 deletion tests/Filesystem/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,22 @@ public function testPutStoresFiles()
$this->assertStringEqualsFile($this->tempDir.'/file.txt', 'Hello World');
}

public function testReplaceStoresFiles()
public function testReplaceCreatesFile()
{
$tempFile = "{$this->tempDir}/file.txt";

$filesystem = new Filesystem;

$filesystem->replace($tempFile, 'Hello World');
$this->assertStringEqualsFile($tempFile, 'Hello World');
}

public function testReplaceWhenUnixSymlinkExists()
{
if (windows_os()) {
$this->markTestSkipped('Skipping since operating system is Windows');
}

$tempFile = "{$this->tempDir}/file.txt";
$symlinkDir = "{$this->tempDir}/symlink_dir";
$symlink = "{$symlinkDir}/symlink.txt";
Expand Down

0 comments on commit cfed253

Please sign in to comment.