summaryrefslogtreecommitdiff
path: root/_test/tests/inc/io_savefile.test.php
blob: 4a4d4671d2d750b8197ba83a30e5164db1bf2c51 (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

class io_savefile_test extends DokuWikiTest {

    /*
     * dependency for tests needing zlib extension to pass
     */
    public function test_ext_zlib() {
        if (!extension_loaded('zlib')) {
            $this->markTestSkipped('skipping all zlib tests.  Need zlib extension');
        }
    }

    /*
     * dependency for tests needing zlib extension to pass
     */
    public function test_ext_bz2() {
        if (!extension_loaded('bz2')) {
            $this->markTestSkipped('skipping all bzip2 tests.  Need bz2 extension');
        }
    }

    function _write($file){
        $contents = "The\012Write\012Test\012";
        $this->assertTrue(io_saveFile($file, $contents));
        $this->assertEquals($contents, io_readFile($file));
        $this->assertTrue(io_saveFile($file, $contents, true));
        $this->assertEquals($contents.$contents, io_readFile($file));
    }

    function test_write(){
        $this->_write(TMP_DIR.'/test.txt');
    }

    /**
     * @depends test_ext_zlib
     */
    function test_gzwrite(){
        $this->_write(TMP_DIR.'/test.txt.gz');
    }

    /**
     * @depends test_ext_bz2
     */
    function test_bzwrite(){
        $this->_write(TMP_DIR.'/test.txt.bz2');
    }

}