Permalink
Browse files

Adding a phpunit config file. Must have test in the name for the tests

to be found.
  • Loading branch information...
1 parent 443c7f6 commit e227925e6076531fb9f5ff0adef7cd3056c80cf9 @isleshocky77 isleshocky77 committed Nov 6, 2012
View
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
+<phpunit
+ backupGlobals = "false"
+ backupStaticAttributes = "false"
+ colors = "true"
+ convertErrorsToExceptions = "true"
+ convertNoticesToExceptions = "true"
+ convertWarningsToExceptions = "true"
+ processIsolation = "false"
+ stopOnFailure = "false"
+ syntaxCheck = "false"
+ >
+
+ <testsuites>
+ <testsuite name="Project Test Suite">
+ <directory>tests</directory>
+ </testsuite>
+ </testsuites>
+
+ <!--
+ <php>
+ <server name="KERNEL_DIR" value="/path/to/your/app/" />
+ </php>
+ -->
+
+</phpunit>
View
@@ -25,7 +25,7 @@ public static function reset_config() {
"private_cdn" => isset($uri["path"]));
if (isset($uri["path"])) {
$config["secure_distribution"] = substr($uri["path"], 1);
- }
+ }
self::$config = array_merge(self::$config, $config);
}
}
@@ -34,16 +34,16 @@ public static function config_get($option, $default=NULL) {
return Cloudinary::option_get(self::config(), $option, $default);
}
- public static function option_get(&$options, $option, $default=NULL) {
- if (isset($options[$option])) {
+ public static function option_get($options, $option, $default=NULL) {
+ if (isset($options[$option])) {
return $options[$option];
} else {
return $default;
}
}
-
+
public static function option_consume(&$options, $option, $default=NULL) {
- if (isset($options[$option])) {
+ if (isset($options[$option])) {
$value = $options[$option];
unset($options[$option]);
return $value;
@@ -52,7 +52,7 @@ public static function option_consume(&$options, $option, $default=NULL) {
return $default;
}
}
-
+
public static function build_array($value) {
if (is_array($value) && $value == array_values($value)) {
return $value;
@@ -64,11 +64,11 @@ public static function build_array($value) {
}
private static function generate_base_transformation($base_transformation) {
- return is_array($base_transformation) ?
- Cloudinary::generate_transformation_string($base_transformation) :
+ return is_array($base_transformation) ?
+ Cloudinary::generate_transformation_string($base_transformation) :
Cloudinary::generate_transformation_string(array("transformation"=>$base_transformation));
- }
-
+ }
+
// Warning: $options are being destructively updated!
public static function generate_transformation_string(&$options=array()) {
$generate_base_transformation = "Cloudinary::generate_base_transformation";
@@ -83,17 +83,17 @@ public static function generate_transformation_string(&$options=array()) {
$height = Cloudinary::option_get($options, "height");
$has_layer = Cloudinary::option_get($options, "underlay") || Cloudinary::option_get($options, "overlay");
- if ($width && (floatval($width) < 1 || $has_layer)) unset($options["width"]);
- if ($height && (floatval($height) < 1 || $has_layer)) unset($options["height"]);
-
+ if ($width && (floatval($width) < 1 || $has_layer)) unset($options["width"]);
+ if ($height && (floatval($height) < 1 || $has_layer)) unset($options["height"]);
+
$angle = implode(Cloudinary::build_array(Cloudinary::option_consume($options, "angle")), ".");
-
+
$crop = Cloudinary::option_consume($options, "crop");
if (!$crop && !$has_layer) $width = $height = NULL;
$background = Cloudinary::option_consume($options, "background");
if ($background) $background = preg_replace("/^#/", 'rgb:', $background);
-
+
$base_transformations = Cloudinary::build_array(Cloudinary::option_consume($options, "transformation"));
if (count(array_filter($base_transformations, "is_array")) > 0) {
$base_transformations = array_map($generate_base_transformation, $base_transformations);
@@ -102,7 +102,7 @@ public static function generate_transformation_string(&$options=array()) {
$named_transformation = implode(".", $base_transformations);
$base_transformations = array();
}
-
+
$effect = Cloudinary::option_consume($options, "effect");
if (is_array($effect)) $effect = implode(":", $effect);
@@ -116,12 +116,12 @@ public static function generate_transformation_string(&$options=array()) {
$flags = implode(Cloudinary::build_array(Cloudinary::option_consume($options, "flags")), ".");
$params = array("w"=>$width, "h"=>$height, "t"=>$named_transformation, "c"=>$crop, "b"=>$background, "e"=>$effect, "bo"=>$border, "a"=>$angle, "fl"=>$flags);
- $simple_params = array("x"=>"x", "y"=>"y", "r"=>"radius", "d"=>"default_image", "g"=>"gravity",
+ $simple_params = array("x"=>"x", "y"=>"y", "r"=>"radius", "d"=>"default_image", "g"=>"gravity",
"q"=>"quality", "p"=>"prefix", "l"=>"overlay", "u"=>"underlay", "f"=>"fetch_format",
"dn"=>"density", "pg"=>"page", "dl"=>"delay", "cs"=>"color_space");
- foreach ($simple_params as $param=>$option) {
+ foreach ($simple_params as $param=>$option) {
$params[$param] = Cloudinary::option_consume($options, $option);
- }
+ }
$params = array_filter($params);
ksort($params);
@@ -145,40 +145,40 @@ public static function cloudinary_url($source, &$options=array()) {
$resource_type = Cloudinary::option_consume($options, "resource_type", "image");
$version = Cloudinary::option_consume($options, "version");
$format = Cloudinary::option_consume($options, "format");
-
+
$cloud_name = Cloudinary::option_consume($options, "cloud_name", Cloudinary::config_get("cloud_name"));
if (!$cloud_name) throw new InvalidArgumentException("Must supply cloud_name in tag or in configuration");
$secure = Cloudinary::option_consume($options, "secure", Cloudinary::config_get("secure"));
$private_cdn = Cloudinary::option_consume($options, "private_cdn", Cloudinary::config_get("private_cdn"));
$secure_distribution = Cloudinary::option_consume($options, "secure_distribution", Cloudinary::config_get("secure_distribution"));
$cdn_subdomain = Cloudinary::option_consume($options, "cdn_subdomain", Cloudinary::config_get("cdn_subdomain"));
$cname = Cloudinary::option_consume($options, "cname", Cloudinary::config_get("cname"));
-
+
$original_source = $source;
if (!$source) return $original_source;
if (preg_match("/^https?:\//i", $source)) {
- if ($type == "upload" || $type == "asset") return $original_source;
+ if ($type == "upload" || $type == "asset") return $original_source;
$source = Cloudinary::smart_escape($source);
} else if ($format) {
$source = $source . "." . $format;
- }
+ }
if ($secure && !$secure_distribution) {
if ($private_cdn) {
throw new InvalidArgumentException("secure_distribution not defined");
} else {
$secure_distribution = Cloudinary::SHARED_CDN;
}
- }
+ }
if ($secure) {
$prefix = "https://" . $secure_distribution;
} else {
$subdomain = $cdn_subdomain ? "a" . ((crc32($source) % 5 + 5) % 5 + 1) . "." : "";
$host = $cname ? $cname : ($private_cdn ? $cloud_name . "-" : "") . "res.cloudinary.com";
$prefix = "http://" . $subdomain . $host;
}
- if (!$private_cdn) $prefix .= "/" . $cloud_name;
-
+ if (!$private_cdn) $prefix .= "/" . $cloud_name;
+
return preg_replace("/([^:])\/+/", "$1/", implode("/", array($prefix, $resource_type,
$type, $transformation, $version ? "v" . $version : "", $source)));
}
@@ -241,7 +241,7 @@ function fetch_image_tag($url, $options = array()) {
$options["type"] = "fetch";
return cl_image_tag($url, $options);
}
-
+
function facebook_profile_image_tag($profile, $options = array()) {
$options["type"] = "facebook";
return cl_image_tag($profile, $options);
@@ -282,5 +282,5 @@ function cloudinary_url_internal($source, &$options = array()) {
return Cloudinary::cloudinary_url($source, $options);
}
-
+
?>
View
@@ -148,18 +148,18 @@ public static function call_api($action, $params, $options = array(), $file = NU
}
return $result;
}
- protected static function build_eager(&$transformations) {
+ protected static function build_eager($transformations) {
$eager = array();
foreach (\Cloudinary::build_array($transformations) as $trans) {
$transformation = $trans;
$format = \Cloudinary::option_consume($tranformation, "format");
- $single_eager = implode("/", array_filter(array(\Cloudinary::generate_transformation_string($transformation), $format)));
+ $single_eager = implode("/", array_filter(array(\Cloudinary::generate_transformation_string($transformation), $format)));
array_push($eager, $single_eager);
}
- return implode("|", $eager);
+ return implode("|", $eager);
}
- protected static function build_custom_headers(&$headers) {
+ protected static function build_custom_headers($headers) {
if ($headers == NULL) {
return NULL;
} elseif (is_string($headers)) {
@@ -168,7 +168,7 @@ protected static function build_custom_headers(&$headers) {
return implode("\n", $headers);
} else {
$join_pair = function($key, $value) { return $key . ": " . $value; };
- return implode("\n", array_map($join_pair, array_keys($headers), array_values($headers)));
+ return implode("\n", array_map($join_pair, array_keys($headers), array_values($headers)));
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit e227925

Please sign in to comment.