From 526d1445e8263212f207a903d1e197232634bd30 Mon Sep 17 00:00:00 2001 From: adlawson Date: Sun, 6 Jul 2014 17:32:01 +0100 Subject: [PATCH] Add functional tests --- test/functional/FileSystemFunctionalTest.php | 30 ++++++++++++++ test/src/FunctionalTestCase.php | 41 ++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 test/functional/FileSystemFunctionalTest.php create mode 100644 test/src/FunctionalTestCase.php diff --git a/test/functional/FileSystemFunctionalTest.php b/test/functional/FileSystemFunctionalTest.php new file mode 100644 index 0000000..fa3cf28 --- /dev/null +++ b/test/functional/FileSystemFunctionalTest.php @@ -0,0 +1,30 @@ +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)); + } +} diff --git a/test/src/FunctionalTestCase.php b/test/src/FunctionalTestCase.php new file mode 100644 index 0000000..145c5cb --- /dev/null +++ b/test/src/FunctionalTestCase.php @@ -0,0 +1,41 @@ + + * + * 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()); + } +}