Merge "objectcache: Remove lock()/unlock() stubs from MemcachedClient"
[lhc/web/wiklou.git] / tests / phpunit / unit / includes / libs / filebackend / fsfile / TempFSFileTestTrait.php
1 <?php
2
3 /**
4 * Code shared between the unit and integration tests
5 */
6 trait TempFSFileTestTrait {
7 abstract protected function newFile();
8
9 /**
10 * @covers TempFSFile::__construct
11 * @covers TempFSFile::purge
12 */
13 public function testPurge() {
14 $file = $this->newFile();
15 $this->assertTrue( file_exists( $file->getPath() ) );
16 $file->purge();
17 $this->assertFalse( file_exists( $file->getPath() ) );
18 }
19
20 /**
21 * @covers TempFSFile::__construct
22 * @covers TempFSFile::bind
23 * @covers TempFSFile::autocollect
24 * @covers TempFSFile::__destruct
25 */
26 public function testBind() {
27 $file = $this->newFile();
28 $path = $file->getPath();
29 $this->assertTrue( file_exists( $path ) );
30 $obj = new stdclass;
31 $file->bind( $obj );
32 unset( $file );
33 $this->assertTrue( file_exists( $path ) );
34 unset( $obj );
35 $this->assertFalse( file_exists( $path ) );
36 }
37
38 /**
39 * @covers TempFSFile::__construct
40 * @covers TempFSFile::preserve
41 * @covers TempFSFile::__destruct
42 */
43 public function testPreserve() {
44 $file = $this->newFile();
45 $path = $file->getPath();
46 $this->assertTrue( file_exists( $path ) );
47 $file->preserve();
48 unset( $file );
49 $this->assertTrue( file_exists( $path ) );
50 Wikimedia\suppressWarnings();
51 unlink( $path );
52 Wikimedia\restoreWarnings();
53 }
54 }