summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Integration/TempFileRoundTripTest.php
blob: 02b62475086fa28e255d2df8eb75f8a9430f420f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php

namespace SMW\Tests\Integration;

use SMW\Utils\TempFile;

/**
 * @group semantic-mediawiki
 *
 * @license GNU GPL v2+
 * @since 3.0
 *
 * @author mwjames
 */
class TempFileRoundTripTest extends \PHPUnit_Framework_TestCase {

	public function testRoundTrip() {

		$expected = 'Test write file';
		$tempFile = new TempFile();

		$file = $tempFile->generate( 'Test' );

		$tempFile->write( $file, $expected );

		$this->assertTrue(
			$tempFile->exists( $file )
		);

		$this->assertEquals(
			$expected,
			$tempFile->read( $file, $tempFile->getCheckSum( $file ) )
		);

		$tempFile->write( $file, '++plus++', FILE_APPEND );

		$this->assertEquals(
			$expected . '++plus++',
			$tempFile->read( $file )
		);

		$tempFile->delete( $file );

		$this->assertFalse(
			$tempFile->exists( $file )
		);
	}

}