xref: /dokuwiki/_test/tests/inc/common_php_to_byte.test.php (revision a81f3d99fc1bb57989fc0acb0ed72fc168bb74ad)
1*a81f3d99SAndreas Gohr<?php
2*a81f3d99SAndreas Gohr
3*a81f3d99SAndreas Gohrclass common_php_to_byte_test extends DokuWikiTest {
4*a81f3d99SAndreas Gohr
5*a81f3d99SAndreas Gohr
6*a81f3d99SAndreas Gohr    public function data() {
7*a81f3d99SAndreas Gohr        $data = [
8*a81f3d99SAndreas Gohr            ['1G', 1073741824],
9*a81f3d99SAndreas Gohr            ['8M', 8388608],
10*a81f3d99SAndreas Gohr            ['8K', 8192],
11*a81f3d99SAndreas Gohr            ['800', 800],
12*a81f3d99SAndreas Gohr            ['8', 8],
13*a81f3d99SAndreas Gohr            ['0', 0],
14*a81f3d99SAndreas Gohr            ['-1', -1]
15*a81f3d99SAndreas Gohr        ];
16*a81f3d99SAndreas Gohr
17*a81f3d99SAndreas Gohr        // larger sizes only work on 64bit platforms
18*a81f3d99SAndreas Gohr        if(PHP_INT_SIZE == 8) {
19*a81f3d99SAndreas Gohr            $data[] = ['8G', 8589934592];
20*a81f3d99SAndreas Gohr        }
21*a81f3d99SAndreas Gohr
22*a81f3d99SAndreas Gohr        return $data;
23*a81f3d99SAndreas Gohr    }
24*a81f3d99SAndreas Gohr
25*a81f3d99SAndreas Gohr    /**
26*a81f3d99SAndreas Gohr     * @dataProvider data
27*a81f3d99SAndreas Gohr     * @param string $value
28*a81f3d99SAndreas Gohr     * @param int $bytes
29*a81f3d99SAndreas Gohr     */
30*a81f3d99SAndreas Gohr    public function test_undefined($value, $bytes) {
31*a81f3d99SAndreas Gohr        $this->assertSame($bytes, php_to_byte($value));
32*a81f3d99SAndreas Gohr    }
33*a81f3d99SAndreas Gohr
34*a81f3d99SAndreas Gohr}
35