xref: /dokuwiki/_test/tests/inc/io_savefile.test.php (revision 7e9637146fa03b75eb1e5fc1e7d34d9c3d10ba4e)
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 (!extension_loaded('zlib')) {
10            $this->markTestSkipped('skipping all zlib tests.  Need zlib extension');
11        }
12    }
13
14    /*
15     * dependency for tests needing zlib extension to pass
16     */
17    public function test_ext_bz2() {
18        if (!extension_loaded('bz2')) {
19            $this->markTestSkipped('skipping all bzip2 tests.  Need bz2 extension');
20        }
21    }
22
23    function _write($file){
24        $contents = "The\012Write\012Test\012";
25        $this->assertTrue(io_saveFile($file, $contents));
26        $this->assertEquals($contents, io_readFile($file));
27        $this->assertTrue(io_saveFile($file, $contents, true));
28        $this->assertEquals($contents.$contents, io_readFile($file));
29    }
30
31    function test_write(){
32        $this->_write(TMP_DIR.'/test.txt');
33    }
34
35    /**
36     * @depends test_ext_zlib
37     */
38    function test_gzwrite(){
39        $this->_write(TMP_DIR.'/test.txt.gz');
40    }
41
42    /**
43     * @depends test_ext_bz2
44     */
45    function test_bzwrite(){
46        $this->_write(TMP_DIR.'/test.txt.bz2');
47    }
48
49}
50