2457304eb3d1f16880ba5cd9787c5e4a39b0c0ab
[yaffs-website] / vendor / mikey179 / vfsStream / src / test / php / org / bovigo / vfs / vfsStreamWrapperUnregisterTestCase.php
1 <?php
2 /**
3  * This file is part of vfsStream.
4  *
5  * For the full copyright and license information, please view the LICENSE
6  * file that was distributed with this source code.
7  *
8  * @package  org\bovigo\vfs
9  */
10 namespace org\bovigo\vfs;
11
12 /**
13  * Test for org\bovigo\vfs\vfsStreamWrapper.
14  */
15 class vfsStreamWrapperUnregisterTestCase extends \PHPUnit_Framework_TestCase
16 {
17
18     /**
19      * Unregistering a registered URL wrapper.
20      *
21      * @test
22      */
23     public function unregisterRegisteredUrlWrapper()
24     {
25         vfsStreamWrapper::register();
26         vfsStreamWrapper::unregister();
27         $this->assertNotContains(vfsStream::SCHEME, stream_get_wrappers());
28     }
29
30     /**
31      * Unregistering a third party wrapper for vfs:// fails.
32      * 
33      * @test
34      * @expectedException org\bovigo\vfs\vfsStreamException
35      * @runInSeparateProcess
36      */
37     public function unregisterThirdPartyVfsScheme()
38     {
39         // Unregister possible registered URL wrapper. 
40         vfsStreamWrapper::unregister();
41
42         $mock = $this->getMock('org\\bovigo\\vfs\\vfsStreamWrapper');
43         stream_wrapper_register(vfsStream::SCHEME, get_class($mock));
44         
45         vfsStreamWrapper::unregister();
46     }
47     
48     /**
49      * Unregistering when not in registered state will fail.
50      *
51      * @test
52      * @expectedException org\bovigo\vfs\vfsStreamException
53      * @runInSeparateProcess
54      */
55     public function unregisterWhenNotInRegisteredState()
56     {
57         vfsStreamWrapper::register();
58         stream_wrapper_unregister(vfsStream::SCHEME);
59         vfsStreamWrapper::unregister();
60     }
61
62     /**
63      * Unregistering while not registers won't fail.
64      *
65      * @test
66      */
67     public function unregisterWhenNotRegistered()
68     {
69         // Unregister possible registered URL wrapper. 
70         vfsStreamWrapper::unregister();
71         
72         $this->assertNotContains(vfsStream::SCHEME, stream_get_wrappers());
73         vfsStreamWrapper::unregister();
74     }
75 }