33dedee5421898885998aea0f49963015781c2f8
[yaffs-website] / vendor / mikey179 / vfsStream / src / test / php / org / bovigo / vfs / vfsStreamWrapperDirSeparatorTestCase.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  * Test that using windows directory separator works correct.
13  *
14  * @since  0.9.0
15  * @group  issue_8
16  */
17 class vfsStreamWrapperDirSeparatorTestCase extends \PHPUnit_Framework_TestCase
18 {
19     /**
20      * root diretory
21      *
22      * @var  vfsStreamDirectory
23      */
24     protected $root;
25
26     /**
27      * set up test environment
28      */
29     public function setUp()
30     {
31         $this->root = vfsStream::setup();
32     }
33
34     /**
35      * @test
36      */
37     public function fileCanBeAccessedUsingWinDirSeparator()
38     {
39         vfsStream::newFile('foo/bar/baz.txt')
40                  ->at($this->root)
41                  ->withContent('test');
42         $this->assertEquals('test', file_get_contents('vfs://root/foo\bar\baz.txt'));
43     }
44
45
46     /**
47      * @test
48      */
49     public function directoryCanBeCreatedUsingWinDirSeparator()
50     {
51         mkdir('vfs://root/dir\bar\foo', true, 0777);
52         $this->assertTrue($this->root->hasChild('dir'));
53         $this->assertTrue($this->root->getChild('dir')->hasChild('bar'));
54         $this->assertTrue($this->root->getChild('dir/bar')->hasChild('foo'));
55     }
56
57     /**
58      * @test
59      */
60     public function directoryExitsTestUsingTrailingWinDirSeparator()
61     {
62         $structure = array(
63             'dir' => array(
64                 'bar' => array(
65                 )
66             )
67         );
68         vfsStream::create($structure, $this->root);
69
70         $this->assertTrue(file_exists(vfsStream::url('root/').'dir\\'));
71     }
72 }