-
Notifications
You must be signed in to change notification settings - Fork 370
Expand file tree
/
Copy pathUtilsTest.php
More file actions
46 lines (39 loc) · 1.24 KB
/
UtilsTest.php
File metadata and controls
46 lines (39 loc) · 1.24 KB
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
<?php
namespace PHPPM\Tests;
use PHPPM\Utils;
class UtilsTest extends PhpPmTestCase
{
public function providePaths()
{
return [
['/images/foo.png', '/images/foo.png'],
['/images/../foo.png', '/foo.png'],
['/images/sub/../../foo.png', '/foo.png'],
['/images/sub/../foo.png', '/images/foo.png'],
['/../foo.png', false],
['../foo.png', false],
['//images/d/../../foo.png', '/foo.png'],
['/images//../foo.png', '/images/foo.png'],
["/images/\0/../foo.png", '/images/foo.png'],
["/images/\0../foo.png", '/foo.png'],
];
}
/**
* @dataProvider providePaths
* @param string $path
* @param string $expected
*/
public function testParseQueryPath($path, $expected)
{
$this->assertEquals($expected, Utils::parseQueryPath($path));
}
public function testHijackProperty()
{
$object = new \PHPPM\SlavePool();
Utils::hijackProperty($object, 'slaves', ['SOME VALUE']);
$r = new \ReflectionObject($object);
$p = $r->getProperty('slaves');
$p->setAccessible(true);
$this->assertEquals(['SOME VALUE'], $p->getValue($object));
}
}