Skip to content

Commit

Permalink
Update #24, add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dusta committed Dec 17, 2018
1 parent e9e5835 commit 2d2eb83
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 3 deletions.
5 changes: 4 additions & 1 deletion tests/Bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<?php

require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../vendor/autoload.php';

define('APP_NAME', 'Dframe');
define('APP_DIR', __DIR__.'/');
63 changes: 63 additions & 0 deletions tests/FakeDriver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace Dframe\FileStorage\Tests;

use Dframe\FileStorage\Drivers\DatabaseDriverInterface;

/**
* Class FakeDriver
*
* @package Dframe\FileStorage\Tests
*/
class FakeDriver implements DatabaseDriverInterface
{
/**
* @param $adapter
* @param $path
* @param bool $cache
*
* @return mixed
*/
public function get($adapter, $path, $cache = false)
{
// TODO: Implement get() method.
}

/**
* @param $adapter
* @param $path
* @param $mine
* @param $stream
*
* @return mixed
*/
public function put($adapter, $path, $mine, $stream)
{
// TODO: Implement put() method.
}

/**
* @param $adapter
* @param $originalId
* @param $path
* @param $mine
* @param $stream
*
* @return mixed
*/
public function cache($adapter, $originalId, $path, $mine, $stream)
{
// TODO: Implement cache() method.
}

/**
* @param $adapter
* @param $path
*
* @return mixed
*/
public function drop($adapter, $path)
{
// TODO: Implement drop() method.
}
}
14 changes: 12 additions & 2 deletions tests/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
class FileTest extends TestCase
{

/** @var Storage */
protected $Storage;

public function setUp()
{
clearstatcache();
Expand All @@ -23,7 +26,7 @@ public function setUp()
$fs->write('file.txt', 'contents', new \League\Flysystem\Config());
$local = new Filesystem($fs);

$driver = false;
$driver = new FakeDriver();
$config = [
'pluginsDir' => __DIR__ . '/plugins',
'adapters' => [
Expand All @@ -35,7 +38,14 @@ public function setUp()
}

public function testHas(){
$this->assertTrue($this->setup()->Storage->getManager()->has('file.txt'));

$this->assertTrue($this->Storage->getManager()->has('local://file.txt'));
}

public function testPut(){

$put = $this->Storage->put('local', __DIR__.'/file.txt', 'files/file.txt');
$this->assertTrue($put['return']);
}

}
1 change: 1 addition & 0 deletions tests/file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
contents

0 comments on commit 2d2eb83

Please sign in to comment.