1<?php
2
3class io_savefile_test extends DokuWikiTest {
4
5    /*
6     * dependency for tests needing zlib extension to pass
7     */
8    public function test_ext_zlib() {
9        if (!DOKU_HAS_GZIP) {
10            $this->markTestSkipped('skipping all zlib tests.  Need zlib extension');
11            return;
12        }
13        $this->assertTrue(true);
14    }
15
16    /*
17     * dependency for tests needing zlib extension to pass
18     */
19    public function test_ext_bz2() {
20        if (!DOKU_HAS_BZIP) {
21            $this->markTestSkipped('skipping all bzip2 tests.  Need bz2 extension');
22            return;
23        }
24        $this->assertTrue(true);
25    }
26
27    function _write($file){
28        $contents = "The\012Write\012Test\012";
29        $this->assertTrue(io_saveFile($file, $contents));
30        $this->assertEquals($contents, io_readFile($file));
31        $this->assertTrue(io_saveFile($file, $contents, true));
32        $this->assertEquals($contents.$contents, io_readFile($file));
33    }
34
35    function test_write(){
36        $this->_write(TMP_DIR.'/test.txt');
37    }
38
39    /**
40     * @depends test_ext_zlib
41     */
42    function test_gzwrite(){
43        $this->_write(TMP_DIR.'/test.txt.gz');
44    }
45
46    /**
47     * @depends test_ext_bz2
48     */
49    function test_bzwrite(){
50        $this->_write(TMP_DIR.'/test.txt.bz2');
51    }
52
53}
54