mirror of
https://github.com/adlawson/php-vfs.git
synced 2024-11-21 12:05:12 +00:00
Add functional tests
This commit is contained in:
parent
404b908bbd
commit
526d1445e8
30
test/functional/FileSystemFunctionalTest.php
Normal file
30
test/functional/FileSystemFunctionalTest.php
Normal 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));
|
||||
}
|
||||
}
|
41
test/src/FunctionalTestCase.php
Normal file
41
test/src/FunctionalTestCase.php
Normal 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());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user