Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / mikey179 / vfsStream / src / test / php / org / bovigo / vfs / vfsStreamWrapperLargeFileTestCase.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 use org\bovigo\vfs\content\LargeFileContent;
12 /**
13  * Test for large file mocks.
14  *
15  * @package     bovigo_vfs
16  * @subpackage  test
17  * @since       1.3.0
18  * @group       issue_79
19  */
20 class vfsStreamWrapperLargeFileTestCase extends \PHPUnit_Framework_TestCase
21 {
22     /**
23      * large file to test
24      *
25      * @var  vfsStreamFile
26      */
27     private $largeFile;
28
29     /**
30      * set up test environment
31      */
32     public function setUp()
33     {
34         $root = vfsStream::setup();
35         $this->largeFile = vfsStream::newFile('large.txt')
36                                     ->withContent(LargeFileContent::withGigabytes(100))
37                                     ->at($root);
38     }
39
40     /**
41      * @test
42      */
43     public function hasLargeFileSize()
44     {
45         if (PHP_INT_MAX == 2147483647) {
46             $this->markTestSkipped('Requires 64-bit version of PHP');
47         }
48
49         $this->assertEquals(
50                 100 * 1024 * 1024 * 1024,
51                 filesize($this->largeFile->url())
52         );
53     }
54
55     /**
56      * @test
57      */
58     public function canReadFromLargeFile()
59     {
60         $fp = fopen($this->largeFile->url(), 'rb');
61         $data = fread($fp, 15);
62         fclose($fp);
63         $this->assertEquals(str_repeat(' ', 15), $data);
64     }
65
66     /**
67      * @test
68      */
69     public function canWriteIntoLargeFile()
70     {
71         $fp = fopen($this->largeFile->url(), 'rb+');
72         fseek($fp, 100 * 1024 * 1024, SEEK_SET);
73         fwrite($fp, 'foobarbaz');
74         fclose($fp);
75         $this->largeFile->seek((100 * 1024 * 1024) - 3, SEEK_SET);
76         $this->assertEquals(
77                 '   foobarbaz   ',
78                 $this->largeFile->read(15)
79         );
80     }
81 }