Skip to content

Commit 3ebf201

Browse files
mocked symlink method in Symfony filesystem component
1 parent 24be44d commit 3ebf201

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

tests/Deployment/DeploymentTest.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
use org\bovigo\vfs\vfsStream;
1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Filesystem\Filesystem;
1516
use ZendServer\DepH\Deployment\Deployment;
1617

1718
/**
@@ -26,6 +27,11 @@ class DeploymentTest extends TestCase
2627
*/
2728
private $deployment;
2829

30+
/**
31+
* @var \Symfony\Component\Filesystem\Filesystem|\PHPUnit_Framework_MockObject_MockObject
32+
*/
33+
private $fs;
34+
2935
/**
3036
* @var \org\bovigo\vfs\vfsStreamDirectory
3137
*/
@@ -70,8 +76,10 @@ protected function setUp()
7076
];
7177
$this->rootFs = vfsStream::setup('usr', null, $structure);
7278

79+
$this->fs = $this->getMockBuilder(Filesystem::class)->setMethods(['symlink'])->getMock();
7380

7481
$this->deployment = $this->getMockBuilder(Deployment::class)
82+
->setConstructorArgs([$this->fs])
7583
->setMethods([
7684
'getZendServerBaseDir',
7785
'getApplicationBaseDir',
@@ -398,18 +406,14 @@ public function testMakeWritableDir()
398406

399407
public function testMakePersitentWritableDir()
400408
{
401-
402-
if ('\\' === DIRECTORY_SEPARATOR) {
403-
$this->markTestSkipped("Symlinks not supported within windows OS.");
404-
}
405-
406409
$tmpTestDir = vfsStream::url('usr/local/zend/var/apps/__default__/0/1.0.0');
407410

408411
$appName = 'myapp';
409412
$this->deployment->method('getApplicationBaseDir')->willReturn($tmpTestDir);
410413
$this->deployment->method('getWebserverGid')->willReturn(getmygid());
411414
$this->deployment->method('getApplicationName')->willReturn($appName);
412415

416+
$this->fs->expects($this->once())->method('symlink')->with("$tmpTestDir/persitentDir/$appName/myWritableDir", "$tmpTestDir/myWritableDir");
413417

414418
$absolutePaths = $this->deployment->createPersitentApplicationDir(
415419
'myWritableDir',
@@ -420,15 +424,7 @@ public function testMakePersitentWritableDir()
420424
$absoluteLinkedPath = $absolutePaths['linkedDir'];
421425

422426
$this->assertEquals($tmpTestDir . "/persitentDir/$appName/myWritableDir", $absolutePersitentPath);
423-
$this->assertEquals($$tmpTestDir . '/myWritableDir', $absoluteLinkedPath);
424-
425-
$myFile = $tmpTestDir . '/myWritableDir/myFile';
426-
$myPersitentFile = $tmpTestDir . "/persitentDir/$appName/myWritableDir/myFile";
427-
touch($myFile);
428-
429-
$this->assertTrue(is_file($myFile));
430-
$this->assertTrue(is_file($myPersitentFile));
431-
427+
$this->assertEquals($tmpTestDir . '/myWritableDir', $absoluteLinkedPath);
432428
}
433429

434430
}

0 commit comments

Comments
 (0)