1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class CodeFixerTest extends PHPUnit_Framework_TestCase { |
|
|
|
|
4
|
|
|
|
5
|
|
|
public function testGetBasicFunctionRenames() { |
6
|
|
|
$fixes = new CodeFixer(); |
7
|
|
|
|
8
|
|
|
$renames = $fixes->getBasicFunctionRenames(); |
9
|
|
|
|
10
|
|
|
$pattern = '/^[a-zA-Z_][\sa-zA-Z_0-9\(\)\->]*$/'; |
11
|
|
|
|
12
|
|
|
foreach ($renames as $from => $to) { |
13
|
|
|
$this->assertNotEmpty($from); |
14
|
|
|
$this->assertNotEmpty($to); |
15
|
|
|
|
16
|
|
|
$this->assertRegExp($pattern, $from); |
17
|
|
|
$this->assertRegExp($pattern, $to); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
/* |
21
|
|
|
* Check version filtering |
22
|
|
|
*/ |
23
|
|
|
// no results below 1.7 |
24
|
|
|
$this->assertEmpty($fixes->getBasicFunctionRenames('1.6')); |
25
|
|
|
|
26
|
|
|
// version 1.7 |
27
|
|
|
$renames = $fixes->getBasicFunctionRenames('1.7'); |
28
|
|
|
$this->assertArrayHasKey('elgg_validate_action_url', $renames); |
29
|
|
|
$this->assertArrayNotHasKey('register_elgg_event_handler', $renames); |
30
|
|
|
$this->assertArrayNotHasKey('setup_db_connections', $renames); |
31
|
|
|
|
32
|
|
|
// version 1.8 |
33
|
|
|
$renames = $fixes->getBasicFunctionRenames('1.8'); |
34
|
|
|
$this->assertArrayHasKey('elgg_validate_action_url', $renames); |
35
|
|
|
$this->assertArrayHasKey('register_elgg_event_handler', $renames); |
36
|
|
|
$this->assertArrayNotHasKey('setup_db_connections', $renames); |
37
|
|
|
|
38
|
|
|
// version 1.9 |
39
|
|
|
$renames = $fixes->getBasicFunctionRenames('1.9'); |
40
|
|
|
$this->assertArrayHasKey('elgg_validate_action_url', $renames); |
41
|
|
|
$this->assertArrayHasKey('register_elgg_event_handler', $renames); |
42
|
|
|
$this->assertArrayHasKey('setup_db_connections', $renames); |
43
|
|
|
|
44
|
|
|
// all versions |
45
|
|
|
$renames = $fixes->getBasicFunctionRenames(''); |
46
|
|
|
$this->assertArrayHasKey('elgg_validate_action_url', $renames); |
47
|
|
|
$this->assertArrayHasKey('register_elgg_event_handler', $renames); |
48
|
|
|
$this->assertArrayHasKey('setup_db_connections', $renames); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.