1<?php
2require_once 'PHPUnit/Framework.php';
3  require_once dirname(__FILE__) . '/../src/gtAutoload.php';
4
5
6  class gtCommandLineOptionsTest extends PHPUnit_Framework_TestCase
7  {
8
9    /**
10    * @expectedException RuntimeException
11    */
12    public function testNoOption() {
13      $clo = new gtCommandLineOptions();
14      $clo->parse(array('generate-phpt.php'));
15    }
16
17    public function testShortOption() {
18      $clo = new gtCommandLineOptions();
19      $clo->parse(array('generate-phpt.php', '-h'));
20      $this->assertTrue($clo->hasOption('h'));
21    }
22
23    public function testShortOptionArgument() {
24      $clo = new gtCommandLineOptions();
25      $clo->parse(array('generate-phpt.php', '-f', 'some-function'));
26      $this->assertTrue($clo->hasOption('f'));
27      $this->assertEquals('some-function', $clo->getOption('f'));
28    }
29
30    /**
31    * @expectedException RuntimeException
32    */
33      public function testInvalidOption() {
34      $clo = new gtCommandLineOptions();
35      $clo->parse(array('generate-phpt.php', '-z'));
36    }
37
38    /**
39    * @expectedException RuntimeException
40    */
41   public function testMissingArgument() {
42      $clo = new gtCommandLineOptions();
43      $clo->parse(array('generate-phpt.php', '-f'));
44    }
45  }
46?>