Skip to content

Commit bf1097e

Browse files
committed
Test File returns new file with the to path
1 parent 50ed36a commit bf1097e

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/Node/File.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ public function time()
8686
*/
8787
public function rename($toFilename)
8888
{
89-
return $this->adapter->rename($this->path, $toFilename);
89+
return $this->adapter->rename($this->path, $toFilename)->then(function () use ($toFilename) {
90+
return $this->filesystem->file($toFilename);
91+
});
9092
}
9193

9294
/**

tests/Node/FileTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace React\Tests\Filesystem\Node;
44

5+
use React\EventLoop\Factory;
56
use React\Filesystem\Filesystem;
67
use React\Filesystem\Node\Directory;
78
use React\Filesystem\Node\File;
@@ -58,16 +59,17 @@ public function testRename()
5859
$pathFrom = 'foo.bar';
5960
$pathTo = 'bar.foo';
6061
$filesystem = $this->mockAdapter();
61-
$promise = $this->getMock('React\Promise\PromiseInterface');
6262

6363
$filesystem
6464
->expects($this->once())
6565
->method('rename')
6666
->with($pathFrom, $pathTo)
67-
->will($this->returnValue($promise))
67+
->will($this->returnValue(new FulfilledPromise()))
6868
;
6969

70-
$this->assertSame($promise, (new File($pathFrom, Filesystem::createFromAdapter($filesystem)))->rename($pathTo));
70+
$newFile = \Clue\React\Block\await((new File($pathFrom, Filesystem::createFromAdapter($filesystem)))->rename($pathTo), Factory::create());
71+
$this->assertInstanceOf('React\Filesystem\Node\FileInterface', $newFile);
72+
$this->assertSame($pathTo, $newFile->getPath());
7173
}
7274

7375
public function testExists()

0 commit comments

Comments
 (0)