Skip to content
This repository
Browse code

- Readded check for _config.php in ClassManifest.

- Added UnitTest for files with underscore prefix.
  • Loading branch information...
commit 42f8d9f77a6e13c2b0513d837e1e9a92261bf642 1 parent 7927fff
Dominik Beerbohm authored March 13, 2012
28  core/manifest/ClassManifest.php
@@ -52,7 +52,7 @@ public static function get_class_parser() {
52 52
 			15 => '{',
53 53
 		));
54 54
 	}
55  
-	
  55
+
56 56
 	/**
57 57
 	 * @return TokenisedRegularExpression
58 58
 	 */
@@ -78,7 +78,7 @@ public static function get_namespaced_class_parser() {
78 78
 			17 => '{',
79 79
 		));
80 80
 	}
81  
-	
  81
+
82 82
 	/**
83 83
 	 * @return TokenisedRegularExpression
84 84
 	 */
@@ -92,7 +92,7 @@ public static function get_namespace_parser() {
92 92
 			5 => ';',
93 93
 		));
94 94
 	}
95  
-	
  95
+
96 96
 	/**
97 97
 	 * @return TokenisedRegularExpression
98 98
 	 */
@@ -103,7 +103,7 @@ public static function get_interface_parser() {
103 103
 			2 => array(T_STRING, 'save_to' => 'interfaceName')
104 104
 		));
105 105
 	}
106  
-	
  106
+
107 107
 	/**
108 108
 	 * Constructs and initialises a new class manifest, either loading the data
109 109
 	 * from the cache or re-scanning for classes.
@@ -243,11 +243,11 @@ public function getImplementorsOf($interface) {
243 243
 	public function getConfigs() {
244 244
 		return $this->configs;
245 245
 	}
246  
-	
  246
+
247 247
 	/**
248 248
 	 * Returns an array of module names mapped to their paths.
249 249
 	 * "Modules" in sapphire are simply directories with a _config.php file.
250  
-	 * 
  250
+	 *
251 251
 	 * @return array
252 252
 	 */
253 253
 	public function getModules() {
@@ -268,7 +268,7 @@ public function regenerate($cache = true) {
268 268
 			'classes', 'roots', 'children', 'descendants', 'interfaces',
269 269
 			'implementors', 'configs'
270 270
 		);
271  
-		
  271
+
272 272
 		// Reset the manifest so stale info doesn't cause errors.
273 273
 		foreach ($reset as $reset) {
274 274
 			$this->$reset = array();
@@ -276,7 +276,7 @@ public function regenerate($cache = true) {
276 276
 
277 277
 		$finder = new ManifestFileFinder();
278 278
 		$finder->setOptions(array(
279  
-			'name_regex'    => '/^[^_].*\.php$/',
  279
+			'name_regex'    => '/^(_config.php|[^_].*\.php)$/',
280 280
 			'ignore_files'  => array('index.php', 'main.php', 'cli-script.php'),
281 281
 			'ignore_tests'  => !$this->tests,
282 282
 			'file_callback' => array($this, 'handleFile')
@@ -328,7 +328,7 @@ public function handleFile($basename, $pathname, $depth) {
328 328
 				$namespace = $data['namespace'];
329 329
 			}
330 330
 		}
331  
-		
  331
+
332 332
 		if (!$classes) {
333 333
 			$tokens     = token_get_all($file);
334 334
 			if(version_compare(PHP_VERSION, '5.3', '>=')) {
@@ -353,7 +353,7 @@ public function handleFile($basename, $pathname, $depth) {
353 353
 			$name       = $namespace . $class['className'];
354 354
 			$extends    = isset($class['extends']) ? implode('', $class['extends']) : null;
355 355
 			$implements = isset($class['interfaces']) ? $class['interfaces'] : null;
356  
-			
  356
+
357 357
 			if($extends && $extends[0] != '\\') {
358 358
 				$extends = $namespace . $extends;
359 359
 			} elseif($extends) {
@@ -380,7 +380,7 @@ public function handleFile($basename, $pathname, $depth) {
380 380
 			} else {
381 381
 				$this->roots[] = $name;
382 382
 			}
383  
-			
  383
+
384 384
 			if ($implements) {
385 385
 				$interface = $namespace;
386 386
 				for($i = 0; $i < count($implements); ++$i) {
@@ -395,7 +395,7 @@ public function handleFile($basename, $pathname, $depth) {
395 395
 					}
396 396
 					if($i == count($implements)-1 || $implements[$i+1] == ',') {
397 397
 						$interface = strtolower($interface);
398  
-		
  398
+
399 399
 						if (!isset($this->implementors[$interface])) {
400 400
 							$this->implementors[$interface] = array($name);
401 401
 						} else {
@@ -405,7 +405,7 @@ public function handleFile($basename, $pathname, $depth) {
405 405
 				}
406 406
 			}
407 407
 		}
408  
-		
  408
+
409 409
 		foreach ($interfaces as $interface) {
410 410
 			$this->interfaces[strtolower($namespace . $interface['interfaceName'])] = $pathname;
411 411
 		}
@@ -421,7 +421,7 @@ public function handleFile($basename, $pathname, $depth) {
421 421
 	protected function coalesceDescendants($class) {
422 422
 		$result = array();
423 423
 		$lClass = strtolower($class);
424  
-		
  424
+
425 425
 		if (array_key_exists($lClass, $this->children)) {
426 426
 			$this->descendants[$lClass] = array();
427 427
 
5  tests/core/manifest/ClassManifestTest.php
@@ -105,7 +105,7 @@ public function testGetConfigs() {
105 105
 		$this->assertEquals($expect, $this->manifest->getConfigs());
106 106
 		$this->assertEquals($expect, $this->manifestTests->getConfigs());
107 107
 	}
108  
-	
  108
+
109 109
 	public function testGetModules() {
110 110
 		$expect = array("module" => "{$this->base}/module");
111 111
 		$this->assertEquals($expect, $this->manifest->getModules());
@@ -117,4 +117,7 @@ public function testTestManifestIncludesTestClasses() {
117 117
 		$this->assertContains('testclassa', array_keys($this->manifestTests->getClasses()));
118 118
 	}
119 119
 
  120
+	public function testManifestExcludeFilesPrefixedWithUnderscore() {
  121
+		$this->assertNotContains('ignore', array_keys($this->manifest->getClasses()));
  122
+	}
120 123
 }
5  tests/core/manifest/fixtures/classmanifest/module/classes/_Ignore.php
... ...
@@ -0,0 +1,5 @@
  1
+<?php
  2
+/**
  3
+ * @ignore
  4
+ */
  5
+class Ignore extends ClassC {  }

0 notes on commit 42f8d9f

Please sign in to comment.
Something went wrong with that request. Please try again.