Add functional tests

This commit is contained in:
adlawson 2014-07-06 17:32:01 +01:00
parent 404b908bbd
commit 526d1445e8
2 changed files with 71 additions and 0 deletions

View File

@ -0,0 +1,30 @@
<?php
namespace Vfs;
use RuntimeException;
use Vfs\Test\FunctionalTestCase;
class FileSystemFunctionalTest extends FunctionalTestCase
{
public function testMount()
{
$this->assertFalse($this->isMounted($this->scheme));
$this->fs->mount();
$this->assertTrue($this->isMounted($this->scheme));
}
public function testUnmount()
{
$this->assertFalse($this->isMounted($this->scheme));
$this->fs->mount();
$this->assertTrue($this->isMounted($this->scheme));
$this->fs->unmount();
$this->assertFalse($this->isMounted($this->scheme));
}
}

View File

@ -0,0 +1,41 @@
<?php
/*
* This file is part of VFS
*
* Copyright (c) 2014 Andrew Lawson <http://adlawson.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Vfs\Test;
use PHPUnit_Framework_TestCase as TestCase;
use RuntimeException;
use Vfs\FileSystemBuilder;
class FunctionalTestCase extends TestCase
{
protected $scheme = 'foo';
public function setUp()
{
$builder = new FileSystemBuilder($this->scheme);
$this->fs = $builder->build();
}
public function tearDown()
{
if ($this->isMounted($this->scheme)) {
$this->fs->unmount();
if ($this->isMounted($this->scheme)) {
throw new RuntimeException('Problem unmounting file system ' . $this->scheme);
}
}
}
protected function isMounted($scheme)
{
return in_array($scheme, stream_get_wrappers());
}
}