Ejemplo n.º 1
0
 protected function validateOptsValidationSucceeds($text_spec, $fake_argv)
 {
     $values = CLIOpts::getOpts($text_spec, $fake_argv);
     $validator = $values->getValidator();
     $this->assertTrue($validator->isValid(), 'Validation was false');
     return $values;
 }
Ejemplo n.º 2
0
 protected function validateHelpString($text_spec, $expected_help_text = null, $literal_text_spec = false)
 {
     $text_spec_for_create = $text_spec;
     if (!$literal_text_spec and substr($expected_help_text, 0, 6) != 'Usage:') {
         $text_spec_for_create = "Usage: ./script.php\n" . $text_spec;
     }
     $cli_opts = CLIOpts::createFromTextSpec($text_spec_for_create);
     if ($expected_help_text === null) {
         $expected_help_text = "Usage:\n./script.php [options]\n\nOptions:\n" . trim($text_spec);
     } else {
         $expected_help_text = trim($expected_help_text);
         if (substr($expected_help_text, 0, 6) != 'Usage:') {
             $expected_help_text = "Usage:\n./script.php [options]\n\nOptions:\n" . $expected_help_text;
         }
     }
     $actual_help_text = $cli_opts->buildHelpText();
     $actual_help_text = preg_replace('!\\x1b\\[0;.*?m!', '', $actual_help_text);
     $actual_help_text = str_replace("\n  ", "\n", $actual_help_text);
     $this->assertEquals(trim($expected_help_text), trim($actual_help_text));
 }
Ejemplo n.º 3
0
 protected function verifyOpts($text_spec, $fake_argv, $expected_values, $expected_data_by_offset = null)
 {
     $values = CLIOpts::getOpts($text_spec, $fake_argv);
     $this->assertEquals($expected_values, iterator_to_array($values));
     if ($expected_data_by_offset !== null) {
         $this->assertEquals($expected_data_by_offset, $values->getAllArgumentValuesByOffset());
     }
     return $values;
 }