public
Description: My mirror of phpspec
Homepage: http://www.phpspec.org/
Clone URL: git://github.com/tedkulp/phpspec.git
* Refactoring for HTML output

git-svn-id: http://phpspec.googlecode.com/svn/trunk@172 
d6e91ea2-e33a-0410-98df-1d493bd67c58
padraic.brady (author)
Tue Jan 08 09:51:20 -0800 2008
commit  fc90d707a2b17c0956beed6d48e8cfe92e9a4e0c
tree    40324cba8ff4212585b26b178c4ffd75a6a717c2
parent  b41a2c603901f8a3f77c93124c76f9124416f71b
...
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
 
 
 
 
97
98
99
...
126
127
128
129
130
131
132
133
134
 
135
...
37
38
39
 
 
40
41
42
 
43
44
45
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
48
49
50
51
52
53
...
80
81
82
 
 
 
 
 
83
84
85
0
@@ -37,63 +37,17 @@ class PHPSpec_Console_Command
0
      */
0
     public static function main(PHPSpec_Console_Getopt $options = null)
0
     {
0
- $runnable = array();
0
- $generateSpecdox = false;
0
         if (is_null($options)) {
0
           $options = new PHPSpec_Console_Getopt;
0
         }
0
-
0
         if (isset($options->a) || isset($options->autotest)) {
0
           self::autotest($options);
0
           return;
0
         }
0
-
0
- // check for straight class to execute
0
- if (isset($options->specFile)) {
0
- $loader = new PHPSpec_Runner_Loader_Classname;
0
- $runnable += $loader->load($options->specFile);
0
- }
0
-
0
- // should only recurse if not running a single spec
0
- if (isset($options->r) && !isset($options->specFile)) {
0
- $loader = new PHPSpec_Runner_Loader_DirectoryRecursive;
0
- $runnable += $loader->load( getcwd() );
0
- }
0
-
0
- if (isset($options->s) || (isset($options->format) && $options->format == 'specdoc')) {
0
- $generateSpecdox = true;
0
- }
0
-
0
- if (empty($runnable)) {
0
- echo 'No specs to execute!';
0
- return;
0
- }
0
-
0
- $result = new PHPSpec_Runner_Result;
0
- $result->setRuntimeStart(microtime(true));
0
-
0
- if (isset($options->reporter)) {
0
- $reporterClass = 'PHPSpec_Runner_Reporter_' . ucwords($options->reporter);
0
- } else {
0
- $reporterClass = 'PHPSpec_Runner_Reporter_Console';
0
- }
0
- $reporter = new $reporterClass($result);
0
-
0
- $result->setReporter($reporter);
0
-
0
- foreach ($runnable as $behaviourContextReflection) {
0
- $contextObject = $behaviourContextReflection->newInstance();
0
- $collection = new PHPSpec_Runner_Collection($contextObject);
0
- $runner = PHPSpec_Runner_Base::execute($collection, $result);
0
- }
0
-
0
- $result->setRuntimeEnd(microtime(true));
0
-
0
- $textReporter->output($generateSpecdox);
0
-
0
- unset($textReporter, $result, $runner, $runnable, $collection,
0
- $contextObject, $behaviourContextReflection);
0
-
0
+ if (!isset($options->reporter)) {
0
+ $options->reporter = 'Console';
0
+ }
0
+ PHPSpec_Runner::run($options);
0
     }
0
 
0
     /**
0
@@ -126,8 +80,4 @@ class PHPSpec_Console_Command
0
     
0
 }
0
 
0
-if (isset($options) && $options instanceof PHPSpec_Console_Getopt) {
0
- PHPSpec_Console_Command::main($options);
0
-} else {
0
- PHPSpec_Console_Command::main();
0
-}
0
\ No newline at end of file
0
+PHPSpec_Console_Command::main();
0
\ No newline at end of file
...
72
73
74
 
 
 
 
 
 
 
 
 
75
76
77
...
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
0
@@ -72,6 +72,15 @@ class PHPSpec_Console_Getopt
0
         return $this->_options;
0
     }
0
 
0
+ public function getAllOptionsAsObject()
0
+ {
0
+ $options = new stdClass;
0
+ foreach ($this->_options as $key=>$value) {
0
+ $options->$key = $value;
0
+ }
0
+ return $options;
0
+ }
0
+
0
     public static function parseOptionString($str)
0
     {
0
         $argv = explode(' ', $str);
...
1
2
3
 
 
 
4
5
6
...
12
13
14
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
17
18
19
20
21
 
 
 
 
22
23
24
...
43
44
45
46
47
 
48
49
50
...
112
113
114
115
 
 
 
 
 
 
 
 
 
 
116
117
118
...
1
2
 
3
4
5
6
7
8
...
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
...
71
72
73
 
 
74
75
76
77
...
139
140
141
 
142
143
144
145
146
147
148
149
150
151
152
153
154
0
@@ -1,6 +1,8 @@
0
 <?php
0
 
0
-class PHPSpec_Runner_Reporter_Html extends PHPSpec_Runner_Reporter{
0
+class PHPSpec_Runner_Reporter_Html extends PHPSpec_Runner_Reporter {
0
+
0
+ protected $_headerSent = false;
0
 
0
   public function output($specs = false)
0
   {
0
@@ -12,13 +14,39 @@ class PHPSpec_Runner_Reporter_Html extends PHPSpec_Runner_Reporter{
0
      * @param string $symbol
0
      */
0
   public function outputStatus($symbol)
0
- {
0
+ {
0
+ if (!$this->_headerSent) {
0
+ ob_start();
0
+ $this->renderHeader();
0
+ }
0
+ switch ($symbol) {
0
+ case '.':
0
+ $symbol = Console_Color::convert("%g$symbol%n");
0
+ break;
0
+ case 'F':
0
+ $symbol = Console_Color::convert("%r$symbol%n");
0
+ break;
0
+ case 'E':
0
+ $symbol = Console_Color::convert("%r$symbol%n");
0
+ break;
0
+ case 'P':
0
+ $symbol = Console_Color::convert("%y$symbol%n");
0
+ break;
0
+ default:
0
+ }
0
+ if (!$this->_headerSent) {
0
+ echo ob_get_clean();
0
+ } else {
0
+ echo $symbol;
0
+ }
0
   }
0
 
0
   public function toString($specs = false)
0
   {
0
- ob_start();
0
- $this->renderHeader();
0
+ if (!$this->_headerSent) {
0
+ ob_start();
0
+ $this->renderHeader();
0
+ }
0
     $this->renderSummary();
0
     if($specs){
0
       $this->renderSpecDocs();
0
@@ -43,8 +71,7 @@ class PHPSpec_Runner_Reporter_Html extends PHPSpec_Runner_Reporter{
0
     return $description . ' ';
0
   }
0
 
0
- public function getSpecdox(){
0
-
0
+ public function getSpecdox(){
0
   }
0
   
0
   private function renderHeader(){
0
@@ -112,7 +139,16 @@ class PHPSpec_Runner_Reporter_Html extends PHPSpec_Runner_Reporter{
0
           margin-top:4px;
0
           font-size:0.8em;
0
          white-space: pre ;
0
- }
0
+ }
0
+ span .pass {
0
+ color: green;
0
+ }
0
+ spec .fail {
0
+ color: red;
0
+ }
0
+ spec .pending {
0
+ color: yellow;
0
+ }
0
       </style>      
0
     </head>
0
     <body>

Comments

    No one has commented yet.