Skip to content

Commit

Permalink
Remove dependency on php unit mocking hacks.
Browse files Browse the repository at this point in the history
  • Loading branch information
frankdejonge committed Oct 13, 2019
1 parent 90e3f83 commit ff1c940
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 23 deletions.
7 changes: 5 additions & 2 deletions tests/FlysystemStreamTests.php
@@ -1,6 +1,9 @@
<?php

use League\Flysystem\Adapter\Local;
use League\Flysystem\AdapterInterface;
use League\Flysystem\Filesystem;
use League\Flysystem\FilesystemInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;

Expand All @@ -26,7 +29,7 @@ public function testWriteStream()
*/
public function testWriteStreamFail()
{
$filesystem = new Filesystem($this->createMock('League\Flysystem\AdapterInterface'));
$filesystem = new Filesystem(new Local(__DIR__));
$filesystem->writeStream('file.txt', 'not a resource');
}

Expand All @@ -51,7 +54,7 @@ public function testUpdateStream()
*/
public function testUpdateStreamFail()
{
$filesystem = new Filesystem($this->createMock('League\Flysystem\AdapterInterface'));
$filesystem = new Filesystem(new Local(__DIR__));
$filesystem->updateStream('file.txt', 'not a resource');
}

Expand Down
5 changes: 3 additions & 2 deletions tests/MountManagerTests.php
Expand Up @@ -18,7 +18,7 @@ public function testInstantiable()

public function testConstructorInjection()
{
$mock = $this->createMock('League\Flysystem\FilesystemInterface');
$mock = $this->prophesize(FilesystemInterface::class)->reveal();
$manager = new MountManager([
'prefix' => $mock,
]);
Expand All @@ -30,8 +30,9 @@ public function testConstructorInjection()
*/
public function testInvalidPrefix()
{
$filesystem = $this->prophesize(FilesystemInterface::class)->reveal();
$manager = new MountManager();
$manager->mountFilesystem(false, $this->createMock('League\Flysystem\FilesystemInterface'));
$manager->mountFilesystem(false, $filesystem);
}

/**
Expand Down
18 changes: 0 additions & 18 deletions tests/PHPUnitHacks.php
Expand Up @@ -13,22 +13,4 @@ public function expectException($exception)

parent::setExpectedException($exception);
}

/**
* Returns a test double for the specified class.
*
* @param string $originalClassName
*
* @return PHPUnit_Framework_MockObject_MockObject
*
* @throws PHPUnit_Framework_Exception
*/
protected function createMock($originalClassName)
{
if (is_callable('parent::createMock')) {
return parent::createMock($originalClassName);
}

return $this->getMock($originalClassName);
}
}
3 changes: 2 additions & 1 deletion tests/PluginTests.php
@@ -1,5 +1,6 @@
<?php

use League\Flysystem\Adapter\Local;
use League\Flysystem\File;
use League\Flysystem\Filesystem;
use League\Flysystem\FilesystemInterface;
Expand Down Expand Up @@ -63,7 +64,7 @@ class PluginTests extends TestCase

public function setup()
{
$this->filesystem = new Filesystem($this->createMock('League\Flysystem\AdapterInterface'));
$this->filesystem = new Filesystem(new Local(__DIR__));
}

/**
Expand Down

0 comments on commit ff1c940

Please sign in to comment.