Debian Codegraph @

tests/phpunit/unit/includes/libs/filebackend/fsfile/TempFSFileTestTrait.php

raw symbols SCIP
1 <?php
2
3 namespace Wikimedia\Tests\FileBackend\FSFile;
4
5 /**
6 * Code shared between the unit and integration tests
7 */
8 trait TempFSFileTestTrait {
9 abstract protected function newFile();
10
11 /**
12 * @covers \Wikimedia\FileBackend\FSFile\TempFSFile
13 */
14 public function testPurge() {
15 $file = $this->newFile();
16 $this->assertTrue( is_file( $file->getPath() ) );
17 $file->purge();
18 $this->assertFalse( is_file( $file->getPath() ) );
19 }
20
21 /**
22 * @covers \Wikimedia\FileBackend\FSFile\TempFSFile
23 */
24 public function testBind() {
25 $file = $this->newFile();
26 $path = $file->getPath();
27 $this->assertTrue( is_file( $path ) );
28 $obj = new class {
29 };
30 $file->bind( $obj );
31 unset( $file );
32 $this->assertTrue( is_file( $path ) );
33
34 // Make sure the file still exists after garbage collection
35 gc_collect_cycles();
36 $this->assertTrue( is_file( $path ) );
37
38 unset( $obj );
39 $this->assertFalse( is_file( $path ) );
40 }
41
42 /**
43 * @covers \Wikimedia\FileBackend\FSFile\TempFSFile
44 */
45 public function testPreserve() {
46 $file = $this->newFile();
47 $path = $file->getPath();
48 $this->assertTrue( is_file( $path ) );
49 $file->preserve();
50 unset( $file );
51 $this->assertTrue( is_file( $path ) );
52 @unlink( $path );
53 }
54 }