/
test-get-executable-path.php
53 lines (34 loc) · 1.16 KB
/
test-get-executable-path.php
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
50
51
52
53
<?php
namespace HM\BackUpWordPress;
class Backup_Engine_Get_Executable_Path_Tests extends \HM_Backup_UnitTestCase {
public function setUp() {
$paths = array(
'mysql',
'/usr/bin/mysqlnope',
'/usr/bin/mysqlwrong',
'/usr/bin/mysqltryagain',
);
$this->paths = array_combine( $paths, $paths );
if ( ! function_exists( 'proc_open' ) || ! function_exists( 'proc_close' ) ) {
$this->markTestSkipped( 'proc_open is disabled' );
}
}
public function test_can_pick_first_path() {
$this->assertEquals( 'mysql', Backup_Utilities::get_executable_path( $this->paths ) );
}
public function test_can_pick_shuffled_command_path() {
$paths = $this->paths;
shuffle( $paths );
$this->assertEquals( 'mysql', Backup_Utilities::get_executable_path( $paths ) );
}
public function test_remove_default_command_path() {
$paths = $this->paths;
$paths[] = $path = trim( shell_exec( 'which mysql ' . ignore_stderr() ) );
if ( ! $path ) {
$this->markTestSkipped( 'Couldn\'t find mysql' );
}
unset( $paths['mysql'] );
shuffle( $paths );
$this->assertEquals( $path, Backup_Utilities::get_executable_path( $paths ) );
}
}