Bladeren bron

Added full unit test suite for URL plugin.

Taddeus Kroes 14 jaren geleden
bovenliggende
commit
7f57b35450
1 gewijzigde bestanden met toevoegingen van 16 en 14 verwijderingen
  1. 16 14
      pquery.url.php

+ 16 - 14
pquery.url.php

@@ -34,20 +34,6 @@ class pQueryUrl extends pQuery {
 		return preg_replace('%(^/|/$)%', '', $url);
 	}
 	
-	/**
-	 * Execute the handler of the first matching URL regex.
-	 * 
-	 * @param string $path The path to add.
-	 * @param bool $relative Indicates whether the path is relative to the document root.
-	 */
-	function handler() {
-		foreach( self::$handlers as $pattern => $handler )
-			if( preg_match($pattern, $this->url, $matches) )
-				return call_user_func_array($handler, array_slice($matches, 1));
-		
-		//self::error('URL has no handler.', $this->url);
-	}
-	
 	/**
 	 * Add a handler function to a URL match.
 	 * 
@@ -68,6 +54,22 @@ class pQueryUrl extends pQuery {
 		foreach( $handlers as $pattern => $handler )
 			self::add_handler($pattern, $handler);
 	}
+	
+	/**
+	 * Execute the handler of the first matching URL regex.
+	 * 
+	 * @param string $path The path to add.
+	 * @param bool $relative Indicates whether the path is relative to the document root.
+	 */
+	function handler() {
+		foreach( self::$handlers as $pattern => $handler )
+			if( preg_match($pattern, $this->url, $matches) )
+				return call_user_func_array($handler, array_slice($matches, 1));
+		
+		self::error('URL "%s" has no handler.', $this->url);
+		// @codeCoverageIgnoreStart
+	}
+	// @codeCoverageIgnoreEnd
 }
 
 /**