6 * Unit tests for xh.drush.inc.
10 class xhUnitCase extends UnitUnishTestCase {
13 * Test various combinations of XHProf flag options.
15 * @dataProvider xhOptionProvider
17 public function testFlags($name, $options, $expected) {
19 foreach ($options as $option_name => $option_value) {
20 drush_set_option($option_name, $option_value);
22 $this->assertEquals($expected, xh_flags(), $name);
26 * Provides drush XHProf options and the results we expect from xh_flags().
28 public function xhOptionProvider() {
30 if (!defined('XHPROF_FLAGS_NO_BUILTINS')) {
31 define('XHPROF_FLAGS_NO_BUILTINS', 1);
32 define('XHPROF_FLAGS_CPU', 2);
33 define('XHPROF_FLAGS_MEMORY', 3);
38 'name' => 'No flag options provided (default)',
43 'name' => 'Default flag options explicitly provided',
45 'xh-profile-builtins' => TRUE,
46 'xh-profile-cpu' => FALSE,
47 'xh-profile-memory' => FALSE,
52 'name' => 'Disable profiling of built-ins',
54 'xh-profile-builtins' => FALSE,
55 'xh-profile-cpu' => FALSE,
56 'xh-profile-memory' => FALSE,
58 'expected' => XHPROF_FLAGS_NO_BUILTINS,
61 'name' => 'Enable profiling of CPU',
63 'xh-profile-builtins' => TRUE,
64 'xh-profile-cpu' => TRUE,
65 'xh-profile-memory' => FALSE,
67 'expected' => XHPROF_FLAGS_CPU,
70 'name' => 'Enable profiling of CPU, without builtins',
72 'xh-profile-builtins' => FALSE,
73 'xh-profile-cpu' => TRUE,
74 'xh-profile-memory' => FALSE,
76 'expected' => XHPROF_FLAGS_NO_BUILTINS | XHPROF_FLAGS_CPU,
79 'name' => 'Enable profiling of Memory',
81 'xh-profile-builtins' => TRUE,
82 'xh-profile-cpu' => FALSE,
83 'xh-profile-memory' => TRUE,
85 'expected' => XHPROF_FLAGS_MEMORY,
88 'name' => 'Enable profiling of Memory, without builtins',
90 'xh-profile-builtins' => FALSE,
91 'xh-profile-cpu' => FALSE,
92 'xh-profile-memory' => TRUE,
94 'expected' => XHPROF_FLAGS_NO_BUILTINS | XHPROF_FLAGS_MEMORY,
97 'name' => 'Enable profiling of CPU & Memory',
99 'xh-profile-builtins' => TRUE,
100 'xh-profile-cpu' => TRUE,
101 'xh-profile-memory' => TRUE,
103 'expected' => XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY,