diff --git a/config/deprecatedFiles.lst b/config/deprecatedFiles.lst
index fcefceef2..62870a17c 100644
--- a/config/deprecatedFiles.lst
+++ b/config/deprecatedFiles.lst
@@ -1,6 +1,7 @@
checksum.txt
features/backend/projects/database_connections/main_tests_database_connections_sqlserver.feature
features/backend/projects/project_export_import/main_tests_project_export_import.feature
+gulliver/bin/tasks/pakeTest.php
gulliver/core/Session/PmSessionHandler.php
gulliver/js/codemirror/addon/hint/pig-hint.js
gulliver/js/codemirror/addon/hint/python-hint.js
@@ -130,4 +131,5 @@ workflow/engine/xmlform/users/users_List.xml
workflow/engine/xmlform/users/users_Options.xml
workflow/public_html/skins/JSForms.js
workflow/public_html/skins/ajax.js
-thirdparty/tcpdf
\ No newline at end of file
+thirdparty/tcpdf
+thirdparty/lime
\ No newline at end of file
diff --git a/gulliver/bin/tasks/pakeTest.php b/gulliver/bin/tasks/pakeTest.php
deleted file mode 100644
index d901ec833..000000000
--- a/gulliver/bin/tasks/pakeTest.php
+++ /dev/null
@@ -1,131 +0,0 @@
-.
- *
- * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
- * Coral Gables, FL, 33134, USA, or email info@colosa.com.
- *
- */
-
-
-
-pake_desc('launch unit tests');
-pake_task('test-unit', 'project_exists');
-
-pake_desc('launch functional tests for an application');
-pake_task('test-functional', 'project_exists');
-
-pake_desc('launch all tests');
-pake_task('test-all', 'project_exists');
-
- /**
- * Function run_test_all
- * access public
- */
-
-function run_test_all($task, $args)
-{
- require_once(sfConfig::get('sf_symfony_lib_dir').'/lime/lime.php');
-
- $h = new lime_harness(new lime_output_color());
- $h->base_dir = sfConfig::get('sf_test_dir');
-
- // register all tests
- $finder = pakeFinder::type('file')->ignore_version_control()->follow_link()->name('*Test.php');
- $h->register($finder->in($h->base_dir));
-
- $h->run();
-}
-
-function run_test_functional($task, $args)
-{
- if (!count($args))
- {
- throw new Exception('You must provide the app to test.');
- }
-
- $app = $args[0];
-
- if (!is_dir(sfConfig::get('sf_app_dir').DIRECTORY_SEPARATOR.$app))
- {
- throw new Exception(sprintf('The app "%s" does not exist.', $app));
- }
-
- if (isset($args[1]))
- {
- foreach (array_splice($args, 1) as $path)
- {
- $files = pakeFinder::type('file')->ignore_version_control()->follow_link()->name(basename($path).'Test.php')->in(sfConfig::get('sf_test_dir').DIRECTORY_SEPARATOR.'functional'.DIRECTORY_SEPARATOR.$app.DIRECTORY_SEPARATOR.dirname($path));
- foreach ($files as $file)
- {
- include($file);
- }
- }
- }
- else
- {
- require_once(sfConfig::get('sf_symfony_lib_dir').'/lime/lime.php');
-
- $h = new lime_harness(new lime_output_color());
- $h->base_dir = sfConfig::get('sf_test_dir').'/functional/'.$app;
-
- // register functional tests
- $finder = pakeFinder::type('file')->ignore_version_control()->follow_link()->name('*Test.php');
- $h->register($finder->in($h->base_dir));
-
- $h->run();
- }
-}
-
-function run_test_unit($task, $args)
-{
- $environment = isset ( $arg[1] ) ? $arg[1] : G_TEST_ENV;
- printf("start test in %s environment\n", pakeColor::colorize( $environment, 'INFO'));
- define ( 'G_ENVIRONMENT', $environment );
-
- if (isset($args[0]))
- {
- foreach ($args as $path)
- {
- $pathUnit = PATH_CORE . 'test' . PATH_SEP . 'unit' . PATH_SEP . dirname($path);
- $files = pakeFinder::type('file')->ignore_version_control()->follow_link()->name(basename($path).'Test.php')->in( $pathUnit );
- foreach ($files as $file)
- {
- $fName = str_replace ( PATH_CORE . 'test' . PATH_SEP . 'unit' . PATH_SEP , '', $file );
- printf("\ntesting %s \n", pakeColor::colorize( $fName, 'INFO'));
- include($file);
- }
- }
- }
- else
- {
-
- require_once( PATH_THIRDPARTY . '/lime/lime.php');
- $h = new lime_harness(new lime_output_color());
- $h->base_dir = $pathUnit = PATH_CORE . 'test' . PATH_SEP . 'unit';
-// $h->base_dir = $pathUnit = PATH_CORE . 'test' . PATH_SEP . 'unit' . PATH_SEP . "processmaker";
-
- // register unit tests
- $finder = pakeFinder::type('file')->ignore_version_control()->follow_link()->name('*Test.php');
- $h->register($finder->in($h->base_dir));
-
- $h->run();
- }
-}
diff --git a/thirdparty/lime/Spyc.class.php b/thirdparty/lime/Spyc.class.php
deleted file mode 100644
index 4a1977504..000000000
--- a/thirdparty/lime/Spyc.class.php
+++ /dev/null
@@ -1,1014 +0,0 @@
-
- * @link http://spyc.sourceforge.net/
- * @copyright Copyright 2005-2006 Chris Wanstrath
- * @license http://www.opensource.org/licenses/mit-license.php MIT License
- * @package Spyc
- */
-
-/**
- * A node, used by Spyc for parsing YAML.
- * @package Spyc
- */
-class YAMLNode
-{
- public $parent;
- public $id;
- public $data;
- public $indent;
- public $children = false;
-
- static protected $lastNodeId = 0;
-
- /**
- * The constructor assigns the node a unique ID.
- *
- * @return void
- */
- public function __construct()
- {
- $this->id = ++self::$lastNodeId;
- }
-}
-
-/**
- * The Simple PHP YAML Class.
- *
- * This class can be used to read a YAML file and convert its contents
- * into a PHP array. It currently supports a very limited subsection of
- * the YAML spec.
- *
- * Usage:
- *
- * $parser = new Spyc;
- * $array = $parser->load($file);
- *
- * @package Spyc
- */
-class Spyc
-{
- /**
- * Load YAML into a PHP array statically
- *
- * The load method, when supplied with a YAML stream (string or file),
- * will do its best to convert YAML in a file into a PHP array. Pretty
- * simple.
- * Usage:
- *
- * $array = Spyc::YAMLLoad('lucky.yml');
- * print_r($array);
- *
- *
- * @return array
- * @param string $input Path of YAML file or string containing YAML
- */
- public static function YAMLLoad($input)
- {
- $spyc = new Spyc();
-
- return $spyc->load($input);
- }
-
- /**
- * Dump YAML from PHP array statically
- *
- * The dump method, when supplied with an array, will do its best
- * to convert the array into friendly YAML. Pretty simple. Feel free to
- * save the returned string as nothing.yml and pass it around.
- *
- * Oh, and you can decide how big the indent is and what the wordwrap
- * for folding is. Pretty cool -- just pass in 'false' for either if
- * you want to use the default.
- *
- * Indent's default is 2 spaces, wordwrap's default is 40 characters. And
- * you can turn off wordwrap by passing in 0.
- *
- * @return string
- * @param array $array PHP array
- * @param int $indent Pass in false to use the default, which is 2
- * @param int $wordwrap Pass in 0 for no wordwrap, false for default (40)
- */
- public static function YAMLDump($array, $indent = false, $wordwrap = false)
- {
- $spyc = new Spyc();
-
- return $spyc->dump($array, $indent, $wordwrap);
- }
-
- /**
- * Load YAML into a PHP array from an instantiated object
- *
- * The load method, when supplied with a YAML stream (string or file path),
- * will do its best to convert the YAML into a PHP array. Pretty simple.
- * Usage:
- *
- * $parser = new Spyc;
- * $array = $parser->load('lucky.yml');
- * print_r($array);
- *
- *
- * @return array
- * @param string $input Path of YAML file or string containing YAML
- */
- public function load($input)
- {
- // See what type of input we're talking about
- // If it's not a file, assume it's a string
- if (!empty($input) && (strpos($input, "\n") === false) && file_exists($input))
- {
- $file = $input;
- $yaml = file($input);
- }
- else
- {
- $file = null;
- $yaml = explode("\n", $input);
- }
-
- // Initiate some objects and values
- $base = new YAMLNode();
- $base->indent = 0;
- $this->_lastIndent = 0;
- $this->_lastNode = $base->id;
- $this->_inBlock = false;
- $this->_isInline = false;
-
- foreach ($yaml as $linenum => $line)
- {
- $ifchk = trim($line);
-
- // If the line starts with a tab (instead of a space), throw a fit.
- if (preg_match('/^ *(\t) *+(\w+)/', $line))
- {
- $error = sprintf('ERROR: %sLine %d in your input YAML begins with a tab. YAML only recognizes spaces. Please reformat.', ($file ? "File $file " : ''), $linenum + 1);
-
- throw new Exception($error);
- }
-
- if ($this->_inBlock === false && empty($ifchk))
- {
- continue;
- }
- else if ($this->_inBlock == true && empty($ifchk))
- {
- $last =& $this->_allNodes[$this->_lastNode];
- $last->data[key($last->data)] .= "\n";
- }
- else if ($ifchk{0} != '#' && substr($ifchk, 0, 3) != '---')
- {
- // Create a new node and get its indent
- $node = new YAMLNode();
- $node->indent = $this->_getIndent($line);
-
- // Check where the node lies in the hierarchy
- if ($this->_lastIndent == $node->indent)
- {
- // If we're in a block, add the text to the parent's data
- if ($this->_inBlock === true)
- {
- $parent =& $this->_allNodes[$this->_lastNode];
- $parent->data[key($parent->data)] .= trim($line).$this->_blockEnd;
- }
- else
- {
- // The current node's parent is the same as the previous node's
- if (isset($this->_allNodes[$this->_lastNode]))
- {
- $node->parent = $this->_allNodes[$this->_lastNode]->parent;
- }
- }
- }
- else if ($this->_lastIndent < $node->indent)
- {
- if ($this->_inBlock === true)
- {
- $parent =& $this->_allNodes[$this->_lastNode];
- $parent->data[key($parent->data)] .= substr($line, $this->_lastIndent).$this->_blockEnd;
- }
- else if ($this->_inBlock === false)
- {
- // The current node's parent is the previous node
- $node->parent = $this->_lastNode;
-
- // If the value of the last node's data was > or | we need to
- // start blocking i.e. taking in all lines as a text value until
- // we drop our indent.
- $parent =& $this->_allNodes[$node->parent];
- $this->_allNodes[$node->parent]->children = true;
- if (is_array($parent->data))
- {
- $chk = $parent->data[key($parent->data)];
- if ($chk === '>')
- {
- $this->_inBlock = true;
- $this->_blockEnd = ' ';
- $parent->data[key($parent->data)] = str_replace('>', '', $parent->data[key($parent->data)]);
- $parent->data[key($parent->data)] .= trim($line).' ';
- $this->_allNodes[$node->parent]->children = false;
- $this->_lastIndent = $node->indent;
- }
- else if ($chk === '|')
- {
- $this->_inBlock = true;
- $this->_blockEnd = "\n";
- $parent->data[key($parent->data)] = str_replace('|', '', $parent->data[key($parent->data)]);
- $parent->data[key($parent->data)] .= trim($line)."\n";
- $this->_allNodes[$node->parent]->children = false;
- $this->_lastIndent = $node->indent;
- }
- }
- }
- }
- else if ($this->_lastIndent > $node->indent)
- {
- // Any block we had going is dead now
- if ($this->_inBlock === true)
- {
- $this->_inBlock = false;
- if ($this->_blockEnd = "\n")
- {
- $last =& $this->_allNodes[$this->_lastNode];
- $last->data[key($last->data)] = trim($last->data[key($last->data)]);
- }
- }
-
- // We don't know the parent of the node so we have to find it
- // foreach ($this->_allNodes as $n) {
- foreach ($this->_indentSort[$node->indent] as $n)
- {
- if ($n->indent == $node->indent)
- {
- $node->parent = $n->parent;
- }
- }
- }
-
- if ($this->_inBlock === false)
- {
- // Set these properties with information from our current node
- $this->_lastIndent = $node->indent;
- // Set the last node
- $this->_lastNode = $node->id;
- // Parse the YAML line and return its data
- $node->data = $this->_parseLine($line);
- // Add the node to the master list
- $this->_allNodes[$node->id] = $node;
- // Add a reference to the node in an indent array
- $this->_indentSort[$node->indent][] =& $this->_allNodes[$node->id];
- // Add a reference to the node in a References array if this node
- // has a YAML reference in it.
- if (
- ((is_array($node->data)) &&
- isset($node->data[key($node->data)]) &&
- (!is_array($node->data[key($node->data)])))
- &&
- ((preg_match('/^&([^ ]+)/', $node->data[key($node->data)]))
- ||
- (preg_match('/^\*([^ ]+)/', $node->data[key($node->data)])))
- )
- {
- $this->_haveRefs[] =& $this->_allNodes[$node->id];
- }
- else if (
- ((is_array($node->data)) &&
- isset($node->data[key($node->data)]) &&
- (is_array($node->data[key($node->data)])))
- )
- {
- // Incomplete reference making code. Ugly, needs cleaned up.
- foreach ($node->data[key($node->data)] as $d)
- {
- if (!is_array($d) && ((preg_match('/^&([^ ]+)/', $d)) || (preg_match('/^\*([^ ]+)/', $d))))
- {
- $this->_haveRefs[] =& $this->_allNodes[$node->id];
- }
- }
- }
- }
- }
- }
- unset($node);
-
- // Here we travel through node-space and pick out references (& and *)
- $this->_linkReferences();
-
- // Build the PHP array out of node-space
- $trunk = $this->_buildArray();
-
- return $trunk;
- }
-
- /**
- * Dump PHP array to YAML
- *
- * The dump method, when supplied with an array, will do its best
- * to convert the array into friendly YAML. Pretty simple. Feel free to
- * save the returned string as tasteful.yml and pass it around.
- *
- * Oh, and you can decide how big the indent is and what the wordwrap
- * for folding is. Pretty cool -- just pass in 'false' for either if
- * you want to use the default.
- *
- * Indent's default is 2 spaces, wordwrap's default is 40 characters. And
- * you can turn off wordwrap by passing in 0.
- *
- * @return string
- * @param array $array PHP array
- * @param int $indent Pass in false to use the default, which is 2
- * @param int $wordwrap Pass in 0 for no wordwrap, false for default (40)
- */
- public function dump($array, $indent = false, $wordwrap = false)
- {
- // Dumps to some very clean YAML. We'll have to add some more features
- // and options soon. And better support for folding.
-
- // New features and options.
- if ($indent === false or !is_numeric($indent))
- {
- $this->_dumpIndent = 2;
- }
- else
- {
- $this->_dumpIndent = $indent;
- }
-
- if ($wordwrap === false or !is_numeric($wordwrap))
- {
- $this->_dumpWordWrap = 40;
- }
- else
- {
- $this->_dumpWordWrap = $wordwrap;
- }
-
- // New YAML document
- $string = "---\n";
-
- // Start at the base of the array and move through it.
- foreach ($array as $key => $value)
- {
- $string .= $this->_yamlize($key, $value, 0);
- }
-
- return $string;
- }
-
- protected $_haveRefs;
- protected $_allNodes;
- protected $_lastIndent;
- protected $_lastNode;
- protected $_inBlock;
- protected $_isInline;
- protected $_dumpIndent;
- protected $_dumpWordWrap;
-
- /**
- * Attempts to convert a key / value array item to YAML
- *
- * @return string
- * @param $key The name of the key
- * @param $value The value of the item
- * @param $indent The indent of the current node
- */
- protected function _yamlize($key, $value, $indent)
- {
- if (is_array($value))
- {
- // It has children. What to do?
- // Make it the right kind of item
- $string = $this->_dumpNode($key, null, $indent);
- // Add the indent
- $indent += $this->_dumpIndent;
- // Yamlize the array
- $string .= $this->_yamlizeArray($value, $indent);
- }
- else if (!is_array($value))
- {
- // It doesn't have children. Yip.
- $string = $this->_dumpNode($key, $value, $indent);
- }
-
- return $string;
- }
-
- /**
- * Attempts to convert an array to YAML
- *
- * @return string
- * @param $array The array you want to convert
- * @param $indent The indent of the current level
- */
- protected function _yamlizeArray($array, $indent)
- {
- if (is_array($array))
- {
- $string = '';
- foreach ($array as $key => $value)
- {
- $string .= $this->_yamlize($key, $value, $indent);
- }
-
- return $string;
- }
- else
- {
- return false;
- }
- }
-
- /**
- * Returns YAML from a key and a value
- *
- * @return string
- * @param $key The name of the key
- * @param $value The value of the item
- * @param $indent The indent of the current node
- */
- protected function _dumpNode($key, $value, $indent)
- {
- if (is_object($value))
- {
- if (method_exists($value, '__toString'))
- {
- $value = (string) $value;
- }
- else
- {
- $ref = new ReflectionObject($value);
- $value = $ref->getName();
- }
- }
-
- // do some folding here, for blocks
- if (strpos($value,"\n"))
- {
- $value = $this->_doLiteralBlock($value, $indent);
- }
- else
- {
- $value = $this->_doFolding($value, $indent);
- }
-
- $spaces = str_repeat(' ', $indent);
-
- if (is_int($key))
- {
- // It's a sequence
- $string = $spaces.'- '.$value."\n";
- }
- else
- {
- // It's mapped
- $string = $spaces.$key.': '.$value."\n";
- }
-
- return $string;
- }
-
- /**
- * Creates a literal block for dumping
- *
- * @return string
- * @param $value
- * @param $indent int The value of the indent
- */
- protected function _doLiteralBlock($value, $indent)
- {
- $exploded = explode("\n", $value);
- $newValue = '|';
- $indent += $this->_dumpIndent;
- $spaces = str_repeat(' ', $indent);
- foreach ($exploded as $line)
- {
- $newValue .= "\n".$spaces.trim($line);
- }
- return $newValue;
- }
-
- /**
- * Folds a string of text, if necessary
- *
- * @return string
- * @param $value The string you wish to fold
- */
- protected function _doFolding($value, $indent)
- {
- // Don't do anything if wordwrap is set to 0
- if ($this->_dumpWordWrap === 0)
- {
- return $value;
- }
-
- if (strlen($value) > $this->_dumpWordWrap)
- {
- $indent += $this->_dumpIndent;
- $indent = str_repeat(' ', $indent);
- $wrapped = wordwrap($value, $this->_dumpWordWrap, "\n$indent");
- $value = ">\n".$indent.$wrapped;
- }
-
- return $value;
- }
-
- /* Methods used in loading */
-
- /**
- * Finds and returns the indentation of a YAML line
- *
- * @return int
- * @param string $line A line from the YAML file
- */
- protected function _getIndent($line)
- {
- preg_match('/^\s{1,}/', $line, $match);
- if (!empty($match[0]))
- {
- $indent = substr_count($match[0], ' ');
- }
- else
- {
- $indent = 0;
- }
-
- return $indent;
- }
-
- /**
- * Parses YAML code and returns an array for a node
- *
- * @return array
- * @param string $line A line from the YAML file
- */
- protected function _parseLine($line)
- {
- $line = trim($line);
-
- $array = array();
-
- if (preg_match('/^-(.*):$/', $line))
- {
- // It's a mapped sequence
- $key = trim(substr(substr($line,1), 0, -1));
- $array[$key] = '';
- }
- else if ($line[0] == '-' && substr($line, 0, 3) != '---')
- {
- // It's a list item but not a new stream
- if (strlen($line) > 1)
- {
- $value = trim(substr($line, 1));
- // Set the type of the value. Int, string, etc
- $value = $this->_toType($value);
- $array[] = $value;
- }
- else
- {
- $array[] = array();
- }
- }
- else if (preg_match('/^(.+):/', $line, $key))
- {
- // It's a key/value pair most likely
- // If the key is in double quotes pull it out
- if (preg_match('/^(["\'](.*)["\'](\s)*:)/', $line, $matches))
- {
- $value = trim(str_replace($matches[1], '', $line));
- $key = $matches[2];
- }
- else
- {
- // Do some guesswork as to the key and the value
- $explode = explode(':', $line);
- $key = trim($explode[0]);
- array_shift($explode);
- $value = trim(implode(':', $explode));
- }
-
- // Set the type of the value. Int, string, etc
- $value = $this->_toType($value);
- if (empty($key))
- {
- $array[] = $value;
- }
- else
- {
- $array[$key] = $value;
- }
- }
-
- return $array;
- }
-
- /**
- * Finds the type of the passed value, returns the value as the new type.
- *
- * @param string $value
- * @return mixed
- */
- protected function _toType($value)
- {
- $value = trim($value);
- if ($value && !('"' == $value[0] || "'" == $value[0]))
- {
- $value = preg_replace('/\s*#(.+)$/', '', $value);
- }
-
- if (preg_match('/^("(.*)"|\'(.*)\')/', $value, $matches))
- {
- $value = (string) preg_replace('/(\'\'|\\\\\')/', "'", end($matches));
- $value = preg_replace('/\\\\"/', '"', $value);
- }
- else if (preg_match('/^\\[\s*\\]$/', $value, $matches))
- {
- $value = array();
- }
- else if (preg_match('/^{}$/', $value, $matches))
- {
- $value = array();
- }
- else if (preg_match('/^\\[(.+)\\]$/', $value, $matches))
- {
- // Inline Sequence
-
- // Take out strings sequences and mappings
- $explode = $this->_inlineEscape($matches[1]);
-
- // Propogate value array
- $value = array();
- foreach ($explode as $v)
- {
- $value[] = $this->_toType($v);
- }
- }
- else if (strpos($value,': ') !== false && !preg_match('/^{(.+)/', $value))
- {
- // It's a map
- $array = explode(': ', $value);
- $key = trim($array[0]);
- array_shift($array);
- $value = trim(implode(': ', $array));
- $value = $this->_toType($value);
- $value = array($key => $value);
- }
- else if (preg_match("/{(.+)}$/", $value, $matches))
- {
- // Inline Mapping
-
- // Take out strings sequences and mappings
- $explode = $this->_inlineEscape($matches[1]);
-
- // Propogate value array
- $array = array();
- foreach ($explode as $v)
- {
- $array = $array + $this->_toType($v);
- }
- $value = $array;
- }
- else if (strtolower($value) == 'null' or $value == '' or $value == '~')
- {
- $value = null;
- }
- else if (ctype_digit($value))
- {
- $value = (int) $value;
- }
- else if (in_array(strtolower($value), array('true', 'on', '+', 'yes', 'y')))
- {
- $value = true;
- }
- else if (in_array(strtolower($value), array('false', 'off', '-', 'no', 'n')))
- {
- $value = false;
- }
- else if (is_numeric($value))
- {
- $value = (float) $value;
- }
-
- return $value;
- }
-
- /**
- * Used in inlines to check for more inlines or quoted strings
- *
- * @return array
- */
- protected function _inlineEscape($inline)
- {
- // There's gotta be a cleaner way to do this...
- // While pure sequences seem to be nesting just fine,
- // pure mappings and mappings with sequences inside can't go very
- // deep. This needs to be fixed.
-
- // Check for strings
- $regex = '/(?:(")|(?:\'))((?(1)[^"]+|[^\']+))(?(1)"|\')/';
- if (preg_match_all($regex, $inline, $strings))
- {
- foreach ($strings[0] as $string)
- {
- $saved_strings[] = $string;
- }
- $inline = preg_replace($regex, 'YAMLString', $inline);
- }
- unset($regex);
-
- // Check for sequences
- if (preg_match_all('/\[(.+)\]/U', $inline, $seqs))
- {
- $inline = preg_replace('/\[(.+)\]/U', 'YAMLSeq', $inline);
- $seqs = $seqs[0];
- }
-
- // Check for mappings
- if (preg_match_all('/{(.+)}/U', $inline, $maps))
- {
- $inline = preg_replace('/{(.+)}/U', 'YAMLMap', $inline);
- $maps = $maps[0];
- }
-
- $explode = explode(', ', $inline);
-
- // Re-add the strings
- if (!empty($saved_strings))
- {
- $i = 0;
- foreach ($explode as $key => $value)
- {
- if (false !== strpos($value,'YAMLString'))
- {
- $explode[$key] = str_replace('YAMLString', $saved_strings[$i], $value);
- ++$i;
- }
- }
- }
-
- // Re-add the sequences
- if (!empty($seqs))
- {
- $i = 0;
- foreach ($explode as $key => $value)
- {
- if (strpos($value,'YAMLSeq') !== false)
- {
- $explode[$key] = str_replace('YAMLSeq', $seqs[$i], $value);
- ++$i;
- }
- }
- }
-
- // Re-add the mappings
- if (!empty($maps))
- {
- $i = 0;
- foreach ($explode as $key => $value)
- {
- if (strpos($value,'YAMLMap') !== false)
- {
- $explode[$key] = str_replace('YAMLMap', $maps[$i], $value);
- ++$i;
- }
- }
- }
-
- return $explode;
- }
-
- /**
- * Builds the PHP array from all the YAML nodes we've gathered
- *
- * @return array
- */
- protected function _buildArray()
- {
- $trunk = array();
-
- if (!isset($this->_indentSort[0]))
- {
- return $trunk;
- }
-
- foreach ($this->_indentSort[0] as $n)
- {
- if (empty($n->parent))
- {
- $this->_nodeArrayizeData($n);
- // Check for references and copy the needed data to complete them.
- $this->_makeReferences($n);
- // Merge our data with the big array we're building
- $trunk = $this->_array_kmerge($trunk, $n->data);
- }
- }
-
- return $trunk;
- }
-
- /**
- * Traverses node-space and sets references (& and *) accordingly
- *
- * @return bool
- */
- protected function _linkReferences()
- {
- if (is_array($this->_haveRefs))
- {
- foreach ($this->_haveRefs as $node)
- {
- if (!empty($node->data))
- {
- $key = key($node->data);
- // If it's an array, don't check.
- if (is_array($node->data[$key]))
- {
- foreach ($node->data[$key] as $k => $v)
- {
- $this->_linkRef($node, $key, $k, $v);
- }
- }
- else
- {
- $this->_linkRef($node, $key);
- }
- }
- }
- }
-
- return true;
- }
-
- function _linkRef(&$n, $key, $k = null, $v = null)
- {
- if (empty($k) && empty($v))
- {
- // Look for &refs
- if (preg_match('/^&([^ ]+)/', $n->data[$key], $matches))
- {
- // Flag the node so we know it's a reference
- $this->_allNodes[$n->id]->ref = substr($matches[0], 1);
- $this->_allNodes[$n->id]->data[$key] = substr($n->data[$key], strlen($matches[0]) + 1);
- // Look for *refs
- }
- else if (preg_match('/^\*([^ ]+)/', $n->data[$key], $matches))
- {
- $ref = substr($matches[0], 1);
- // Flag the node as having a reference
- $this->_allNodes[$n->id]->refKey = $ref;
- }
- }
- else if (!empty($k) && !empty($v))
- {
- if (preg_match('/^&([^ ]+)/', $v, $matches))
- {
- // Flag the node so we know it's a reference
- $this->_allNodes[$n->id]->ref = substr($matches[0], 1);
- $this->_allNodes[$n->id]->data[$key][$k] = substr($v, strlen($matches[0]) + 1);
- // Look for *refs
- }
- else if (preg_match('/^\*([^ ]+)/', $v, $matches))
- {
- $ref = substr($matches[0], 1);
- // Flag the node as having a reference
- $this->_allNodes[$n->id]->refKey = $ref;
- }
- }
- }
-
- /**
- * Finds the children of a node and aids in the building of the PHP array
- *
- * @param int $nid The id of the node whose children we're gathering
- * @return array
- */
- protected function _gatherChildren($nid)
- {
- $return = array();
- $node =& $this->_allNodes[$nid];
- foreach ($this->_allNodes as $z)
- {
- if ($z->parent == $node->id)
- {
- // We found a child
- $this->_nodeArrayizeData($z);
- // Check for references
- $this->_makeReferences($z);
- // Merge with the big array we're returning
- // The big array being all the data of the children of our parent node
- $return = $this->_array_kmerge($return, $z->data);
- }
- }
-
- return $return;
- }
-
- /**
- * Turns a node's data and its children's data into a PHP array
- *
- *
- * @param array $node The node which you want to arrayize
- * @return boolean
- */
- protected function _nodeArrayizeData(&$node)
- {
- if (is_array($node->data) && $node->children == true)
- {
- // This node has children, so we need to find them
- $childs = $this->_gatherChildren($node->id);
- // We've gathered all our children's data and are ready to use it
- $key = key($node->data);
- $key = empty($key) ? 0 : $key;
- // If it's an array, add to it of course
- if (is_array($node->data[$key]))
- {
- $node->data[$key] = $this->_array_kmerge($node->data[$key], $childs);
- }
- else
- {
- $node->data[$key] = $childs;
- }
- }
- else if (!is_array($node->data) && $node->children == true)
- {
- // Same as above, find the children of this node
- $childs = $this->_gatherChildren($node->id);
- $node->data = array();
- $node->data[] = $childs;
- }
-
- // We edited $node by reference, so just return true
- return true;
- }
-
- /**
- * Traverses node-space and copies references to / from this object.
- *
- * @param object $z A node whose references we wish to make real
- * @return bool
- */
- protected function _makeReferences(&$z)
- {
- // It is a reference
- if (isset($z->ref))
- {
- $key = key($z->data);
- // Copy the data to this object for easy retrieval later
- $this->ref[$z->ref] =& $z->data[$key];
- // It has a reference
- }
- else if (isset($z->refKey))
- {
- if (isset($this->ref[$z->refKey]))
- {
- $key = key($z->data);
- // Copy the data from this object to make the node a real reference
- $z->data[$key] =& $this->ref[$z->refKey];
- }
- }
-
- return true;
- }
-
- /**
- * Merges arrays and maintains numeric keys.
- *
- * An ever-so-slightly modified version of the array_kmerge() function posted
- * to php.net by mail at nospam dot iaindooley dot com on 2004-04-08.
- *
- * http://us3.php.net/manual/en/function.array-merge.php#41394
- *
- * @param array $arr1
- * @param array $arr2
- * @return array
- */
- protected function _array_kmerge($arr1, $arr2)
- {
- if (!is_array($arr1))
- {
- $arr1 = array();
- }
- if (!is_array($arr2))
- {
- $arr2 = array();
- }
-
- $keys = array_merge(array_keys($arr1), array_keys($arr2));
- $vals = array_merge(array_values($arr1), array_values($arr2));
- $ret = array();
- foreach ($keys as $key)
- {
- list($unused, $val) = each($vals);
- if (isset($ret[$key]) && is_int($key))
- {
- $ret[] = $val;
- }
- else
- {
- $ret[$key] = $val;
- }
- }
-
- return $ret;
- }
-}
diff --git a/thirdparty/lime/lime.php b/thirdparty/lime/lime.php
deleted file mode 100644
index 456dd2564..000000000
--- a/thirdparty/lime/lime.php
+++ /dev/null
@@ -1,980 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Unit test library.
- *
- * @package lime
- * @author Fabien Potencier
- * @version SVN: $Id: lime.php 4259 2007-06-19 07:24:40Z fabien $
- */
-
-class lime_test
-{
- public $plan = null;
- public $test_nb = 0;
- public $failed = 0;
- public $passed = 0;
- public $skipped = 0;
- public $output = null;
-
- function __construct($plan = null, $output_instance = null)
- {
- $this->plan = $plan;
- $this->output = $output_instance ? $output_instance : new lime_output();
-
- null !== $this->plan and $this->output->echoln(sprintf("1..%d", $this->plan));
- }
-
- function __destruct()
- {
- $total = $this->passed + $this->failed + $this->skipped;
-
- null === $this->plan and $this->plan = $total and $this->output->echoln(sprintf("1..%d", $this->plan));
-
- if ($total > $this->plan)
- {
- $this->output->red_bar(sprintf(" Looks like you planned %d tests but ran %d extra.", $this->plan, $total - $this->plan));
- }
- elseif ($total < $this->plan)
- {
- $this->output->red_bar(sprintf(" Looks like you planned %d tests but only ran %d.", $this->plan, $total));
- }
-
- if ($this->failed)
- {
- $this->output->red_bar(sprintf(" Looks like you failed %d tests of %d.", $this->failed, $this->plan));
- }
- else if ($total == $this->plan)
- {
- $this->output->green_bar(" Looks like everything went fine.");
- }
-
- flush();
- }
-
- function ok($exp, $message = '')
- {
- if ($result = (boolean) $exp)
- {
- ++$this->passed;
- }
- else
- {
- ++$this->failed;
- }
- $this->output->echoln(sprintf("%s %d%s", $result ? 'ok' : 'not ok', ++$this->test_nb, $message = $message ? sprintf('%s %s', 0 === strpos($message, '#') ? '' : ' -', $message) : ''));
-
- if (!$result)
- {
- $traces = debug_backtrace();
- if ($_SERVER['PHP_SELF'])
- {
- $i = strstr($traces[0]['file'], $_SERVER['PHP_SELF']) ? 0 : (isset($traces[1]['file']) ? 1 : 0);
- }
- else
- {
- $i = 0;
- }
- $this->output->diag(sprintf(' Failed test (%s at line %d)', str_replace(getcwd(), '.', $traces[$i]['file']), $traces[$i]['line']));
- }
-
- return $result;
- }
-
- function is($exp1, $exp2, $message = '')
- {
- if (is_object($exp1) || is_object($exp2))
- {
- $value = $exp1 === $exp2;
- }
- else
- {
- $value = $exp1 == $exp2;
- }
-
- if (!$result = $this->ok($value, $message))
- {
- $this->output->diag(sprintf(" got: %s", str_replace("\n", '', var_export($exp1, true))), sprintf(" expected: %s", str_replace("\n", '', var_export($exp2, true))));
- }
-
- return $result;
- }
-
- function isnt($exp1, $exp2, $message = '')
- {
- if (!$result = $this->ok($exp1 != $exp2, $message))
- {
- $this->output->diag(sprintf(" %s", str_replace("\n", '', var_export($exp1, true))), ' ne', sprintf(" %s", str_replace("\n", '', var_export($exp2, true))));
- }
-
- return $result;
- }
-
- function like($exp, $regex, $message = '')
- {
- if (!$result = $this->ok(preg_match($regex, $exp), $message))
- {
- $this->output->diag(sprintf(" '%s'", $exp), sprintf(" doesn't match '%s'", $regex));
- }
-
- return $result;
- }
-
- function unlike($exp, $regex, $message = '')
- {
- if (!$result = $this->ok(!preg_match($regex, $exp), $message))
- {
- $this->output->diag(sprintf(" '%s'", $exp), sprintf(" matches '%s'", $regex));
- }
-
- return $result;
- }
-
- function cmp_ok($exp1, $op, $exp2, $message = '')
- {
- eval(sprintf("\$result = \$exp1 $op \$exp2;"));
- if (!$this->ok($result, $message))
- {
- $this->output->diag(sprintf(" %s", str_replace("\n", '', var_export($exp1, true))), sprintf(" %s", $op), sprintf(" %s", str_replace("\n", '', var_export($exp2, true))));
- }
-
- return $result;
- }
-
- function can_ok($object, $methods, $message = '')
- {
- $result = true;
- $failed_messages = array();
- foreach ((array) $methods as $method)
- {
- if (!method_exists($object, $method))
- {
- $failed_messages[] = sprintf(" method '%s' does not exist", $method);
- $result = false;
- }
- }
-
- !$this->ok($result, $message);
-
- !$result and $this->output->diag($failed_messages);
-
- return $result;
- }
-
- function isa_ok($var, $class, $message = '')
- {
- $type = is_object($var) ? get_class($var) : gettype($var);
- if (!$result = $this->ok($type == $class, $message))
- {
- $this->output->diag(sprintf(" isa_ok isn't a '%s' it's a '%s'", $class, $type));
- }
-
- return $result;
- }
-
- function is_deeply($exp1, $exp2, $message = '')
- {
- if (!$result = $this->ok($this->test_is_deeply($exp1, $exp2), $message))
- {
- $this->output->diag(sprintf(" got: %s", str_replace("\n", '', var_export($exp1, true))), sprintf(" expected: %s", str_replace("\n", '', var_export($exp2, true))));
- }
-
- return $result;
- }
-
- function pass($message = '')
- {
- return $this->ok(true, $message);
- }
-
- function fail($message = '')
- {
- return $this->ok(false, $message);
- }
-
- function diag($message)
- {
- $this->output->diag($message);
- }
-
- function skip($message = '', $nb_tests = 1)
- {
- for ($i = 0; $i < $nb_tests; $i++)
- {
- ++$this->skipped and --$this->passed;
- $this->pass(sprintf("# SKIP%s", $message ? ' '.$message : ''));
- }
- }
-
- function todo($message = '')
- {
- ++$this->skipped and --$this->passed;
- $this->pass(sprintf("# TODO%s", $message ? ' '.$message : ''));
- }
-
- function include_ok($file, $message = '')
- {
- if (!$result = $this->ok((@include($file)) == 1, $message))
- {
- $this->output->diag(sprintf(" Tried to include '%s'", $file));
- }
-
- return $result;
- }
-
- private function test_is_deeply($var1, $var2)
- {
- if (gettype($var1) != gettype($var2))
- {
- return false;
- }
-
- if (is_array($var1))
- {
- ksort($var1);
- ksort($var2);
- if (array_diff(array_keys($var1), array_keys($var2)))
- {
- return false;
- }
- $is_equal = true;
- foreach ($var1 as $key => $value)
- {
- $is_equal = $this->test_is_deeply($var1[$key], $var2[$key]);
- if ($is_equal === false)
- {
- break;
- }
- }
-
- return $is_equal;
- }
- else
- {
- return $var1 === $var2;
- }
- }
-
- function comment($message)
- {
- $this->output->comment($message);
- }
-
- static function get_temp_directory()
- {
- if ('\\' == DIRECTORY_SEPARATOR)
- {
- foreach (array('TEMP', 'TMP', 'windir') as $dir)
- {
- if ($var = isset($_ENV[$dir]) ? $_ENV[$dir] : getenv($dir))
- {
- return $var;
- }
- }
-
- return getenv('SystemRoot').'\temp';
- }
-
- if ($var = isset($_ENV['TMPDIR']) ? $_ENV['TMPDIR'] : getenv('TMPDIR'))
- {
- return $var;
- }
-
- return '/tmp';
- }
-}
-
-class lime_output
-{
- function diag()
- {
- $messages = func_get_args();
- foreach ($messages as $message)
- {
- array_map(array($this, 'comment'), (array) $message);
- }
- }
-
- function comment($message)
- {
- echo "# $message\n";
- }
-
- function echoln($message)
- {
- echo "$message\n";
- }
-
- function green_bar($message)
- {
- echo "$message\n";
- }
-
- function red_bar($message)
- {
- echo "$message\n";
- }
-}
-
-class lime_output_color extends lime_output
-{
- public $colorizer = null;
-
- function __construct()
- {
- $this->colorizer = new lime_colorizer();
- }
-
- function diag()
- {
- $messages = func_get_args();
- foreach ($messages as $message)
- {
- echo $this->colorizer->colorize('# '.join("\n# ", (array) $message), 'COMMENT')."\n";
- }
- }
-
- function comment($message)
- {
- echo $this->colorizer->colorize(sprintf('# %s', $message), 'COMMENT')."\n";
- }
-
- function echoln($message, $colorizer_parameter = null)
- {
- $message = preg_replace('/(?:^|\.)((?:not ok|dubious) *\d*)\b/e', '$this->colorizer->colorize(\'$1\', \'ERROR\')', $message);
- $message = preg_replace('/(?:^|\.)(ok *\d*)\b/e', '$this->colorizer->colorize(\'$1\', \'INFO\')', $message);
- $message = preg_replace('/"(.+?)"/e', '$this->colorizer->colorize(\'$1\', \'PARAMETER\')', $message);
- $message = preg_replace('/(\->|\:\:)?([a-zA-Z0-9_]+?)\(\)/e', '$this->colorizer->colorize(\'$1$2()\', \'PARAMETER\')', $message);
-
- echo ($colorizer_parameter ? $this->colorizer->colorize($message, $colorizer_parameter) : $message)."\n";
- }
-
- function green_bar($message)
- {
- echo $this->colorizer->colorize($message.str_repeat(' ', 71 - min(71, strlen($message))), 'GREEN_BAR')."\n";
- }
-
- function red_bar($message)
- {
- echo $this->colorizer->colorize($message.str_repeat(' ', 71 - min(71, strlen($message))), 'RED_BAR')."\n";
- }
-}
-
-class lime_colorizer
-{
- static public $styles = array();
-
- static function style($name, $options = array())
- {
- self::$styles[$name] = $options;
- }
-
- static function colorize($text = '', $parameters = array())
- {
- // disable colors if not supported (windows or non tty console)
- if (DIRECTORY_SEPARATOR == '\\' || !function_exists('posix_isatty') || !@posix_isatty(STDOUT))
- {
- return $text;
- }
-
- static $options = array('bold' => 1, 'underscore' => 4, 'blink' => 5, 'reverse' => 7, 'conceal' => 8);
- static $foreground = array('black' => 30, 'red' => 31, 'green' => 32, 'yellow' => 33, 'blue' => 34, 'magenta' => 35, 'cyan' => 36, 'white' => 37);
- static $background = array('black' => 40, 'red' => 41, 'green' => 42, 'yellow' => 43, 'blue' => 44, 'magenta' => 45, 'cyan' => 46, 'white' => 47);
-
- !is_array($parameters) && isset(self::$styles[$parameters]) and $parameters = self::$styles[$parameters];
-
- $codes = array();
- isset($parameters['fg']) and $codes[] = $foreground[$parameters['fg']];
- isset($parameters['bg']) and $codes[] = $background[$parameters['bg']];
- foreach ($options as $option => $value)
- {
- isset($parameters[$option]) && $parameters[$option] and $codes[] = $value;
- }
-
- return "\033[".implode(';', $codes).'m'.$text."\033[0m";
- }
-}
-
-lime_colorizer::style('ERROR', array('bg' => 'red', 'fg' => 'white', 'bold' => true));
-lime_colorizer::style('INFO', array('fg' => 'green', 'bold' => true));
-lime_colorizer::style('PARAMETER', array('fg' => 'cyan'));
-lime_colorizer::style('COMMENT', array('fg' => 'yellow'));
-
-lime_colorizer::style('GREEN_BAR', array('fg' => 'white', 'bg' => 'green', 'bold' => true));
-lime_colorizer::style('RED_BAR', array('fg' => 'white', 'bg' => 'red', 'bold' => true));
-
-class lime_harness extends lime_registration
-{
- public $php_cli = '';
- public $stats = array();
- public $output = null;
-
- function __construct($output_instance, $php_cli = null)
- {
- if (getenv('PHP_PATH'))
- {
- $this->php_cli = getenv('PHP_PATH');
-
- if (!is_executable($this->php_cli))
- {
- throw new Exception('The defined PHP_PATH environment variable is not a valid PHP executable.');
- }
- }
-
- $this->php_cli = null === $php_cli ? PHP_BINDIR.DIRECTORY_SEPARATOR.'php' : $php_cli;
-
- if (!is_executable($this->php_cli))
- {
- $this->php_cli = $this->find_php_cli();
- }
-
- $this->output = $output_instance ? $output_instance : new lime_output();
- }
-
- protected function find_php_cli()
- {
- $path = getenv('PATH') ? getenv('PATH') : getenv('Path');
- $exe_suffixes = DIRECTORY_SEPARATOR == '\\' ? (getenv('PATHEXT') ? explode(PATH_SEPARATOR, getenv('PATHEXT')) : array('.exe', '.bat', '.cmd', '.com')) : array('');
- foreach (array('php5', 'php') as $php_cli)
- {
- foreach ($exe_suffixes as $suffix)
- {
- foreach (explode(PATH_SEPARATOR, $path) as $dir)
- {
- $file = $dir.DIRECTORY_SEPARATOR.$php_cli.$suffix;
- if (is_executable($file))
- {
- return $file;
- }
- }
- }
- }
-
- throw new Exception("Unable to find PHP executable.");
- }
-
- function run()
- {
- if (!count($this->files))
- {
- throw new Exception('You must register some test files before running them!');
- }
-
- // sort the files to be able to predict the order
- sort($this->files);
-
- $this->stats =array(
- '_failed_files' => array(),
- '_failed_tests' => 0,
- '_nb_tests' => 0,
- );
-
- foreach ($this->files as $file)
- {
- $this->stats[$file] = array(
- 'plan' => null,
- 'nb_tests' => 0,
- 'failed' => array(),
- 'passed' => array(),
- );
- $this->current_file = $file;
- $this->current_test = 0;
- $relative_file = $this->get_relative_file($file);
-
- //$fName = str_replace ( PATH_CORE . 'test' . PATH_SEP . 'unit' . PATH_SEP , '', $file );
- //printf("\ntesting %s \n", pakeColor::colorize( $file, 'INFO'));
- ob_start(array($this, 'process_test_output'));
- passthru(sprintf('%s -d html_errors=off -d open_basedir= -q "%s" 2>&1', $this->php_cli, $file), $return);
- ob_end_clean();
-
- if ($return > 0)
- {
- $this->stats[$file]['status'] = 'dubious';
- $this->stats[$file]['status_code'] = $return;
- }
- else
- {
- $delta = $this->stats[$file]['plan'] - $this->stats[$file]['nb_tests'];
- if ($delta > 0)
- {
- $this->output->echoln(sprintf('%s%s%s', substr($relative_file, -min(67, strlen($relative_file))), str_repeat('.', 70 - min(67, strlen($relative_file))), $this->output->colorizer->colorize(sprintf('# Looks like you planned %d tests but only ran %d.', $this->stats[$file]['plan'], $this->stats[$file]['nb_tests']), 'COMMENT')));
- $this->stats[$file]['status'] = 'dubious';
- $this->stats[$file]['status_code'] = 255;
- $this->stats['_nb_tests'] += $delta;
- for ($i = 1; $i <= $delta; $i++)
- {
- $this->stats[$file]['failed'][] = $this->stats[$file]['nb_tests'] + $i;
- }
- }
- else if ($delta < 0)
- {
- $this->output->echoln(sprintf('%s%s%s', substr($relative_file, -min(67, strlen($relative_file))), str_repeat('.', 70 - min(67, strlen($relative_file))), $this->output->colorizer->colorize(sprintf('# Looks like you planned %s test but ran %s extra.', $this->stats[$file]['plan'], $this->stats[$file]['nb_tests'] - $this->stats[$file]['plan']), 'COMMENT')));
- $this->stats[$file]['status'] = 'dubious';
- $this->stats[$file]['status_code'] = 255;
- for ($i = 1; $i <= -$delta; $i++)
- {
- $this->stats[$file]['failed'][] = $this->stats[$file]['plan'] + $i;
- }
- }
- else
- {
- $this->stats[$file]['status_code'] = 0;
- $this->stats[$file]['status'] = $this->stats[$file]['failed'] ? 'not ok' : 'ok';
- }
- }
-
- $this->output->echoln(sprintf('%s%s%s', substr($relative_file, -min(67, strlen($relative_file))), str_repeat('.', 70 - min(67, strlen($relative_file))), $this->stats[$file]['status']));
- if (($nb = count($this->stats[$file]['failed'])) || $return > 0)
- {
- if ($nb)
- {
- $this->output->echoln(sprintf(" Failed tests: %s", implode(', ', $this->stats[$file]['failed'])));
- }
- $this->stats['_failed_files'][] = $file;
- $this->stats['_failed_tests'] += $nb;
- }
-
- if ('dubious' == $this->stats[$file]['status'])
- {
- $this->output->echoln(sprintf(' Test returned status %s', $this->stats[$file]['status_code']));
- }
- }
-
- if (count($this->stats['_failed_files']))
- {
- $format = "%-30s %4s %5s %5s %s";
- $this->output->echoln(sprintf($format, 'Failed Test', 'Stat', 'Total', 'Fail', 'List of Failed'));
- $this->output->echoln("------------------------------------------------------------------");
- foreach ($this->stats as $file => $file_stat)
- {
- if (!in_array($file, $this->stats['_failed_files'])) continue;
-
- $relative_file = $this->get_relative_file($file);
- $this->output->echoln(sprintf($format, substr($relative_file, -min(30, strlen($relative_file))), $file_stat['status_code'], count($file_stat['failed']) + count($file_stat['passed']), count($file_stat['failed']), implode(' ', $file_stat['failed'])));
- }
-
- $this->output->red_bar(sprintf('Failed %d/%d test scripts, %.2f%% okay. %d/%d subtests failed, %.2f%% okay.',
- $nb_failed_files = count($this->stats['_failed_files']),
- $nb_files = count($this->files),
- ($nb_files - $nb_failed_files) * 100 / $nb_files,
- $nb_failed_tests = $this->stats['_failed_tests'],
- $nb_tests = $this->stats['_nb_tests'],
- $nb_tests > 0 ? ($nb_tests - $nb_failed_tests) * 100 / $nb_tests : 0
- ));
- }
- else
- {
- $this->output->green_bar(' All tests successful.');
- $this->output->green_bar(sprintf(' Files=%d, Tests=%d', count($this->files), $this->stats['_nb_tests']));
- }
-
- return $this->stats['_failed_tests'] ? false : true;
- }
-
- private function process_test_output($lines)
- {
- foreach (explode("\n", $lines) as $text)
- {
- if (false !== strpos($text, 'not ok '))
- {
- ++$this->current_test;
- $test_number = (int) substr($text, 7);
- $this->stats[$this->current_file]['failed'][] = $test_number;
-
- ++$this->stats[$this->current_file]['nb_tests'];
- ++$this->stats['_nb_tests'];
- }
- else if (false !== strpos($text, 'ok '))
- {
- ++$this->stats[$this->current_file]['nb_tests'];
- ++$this->stats['_nb_tests'];
- }
- else if (preg_match('/^1\.\.(\d+)/', $text, $match))
- {
- $this->stats[$this->current_file]['plan'] = $match[1];
- }
- }
-
- return;
- }
-}
-
-class lime_coverage extends lime_registration
-{
- public $files = array();
- public $extension = '.php';
- public $base_dir = '';
- public $harness = null;
- public $verbose = false;
-
- function __construct($harness)
- {
- $this->harness = $harness;
- }
-
- function run()
- {
- if (!function_exists('xdebug_start_code_coverage'))
- {
- throw new Exception('You must install and enable xdebug before using lime coverage.');
- }
-
- if (!ini_get('xdebug.extended_info'))
- {
- throw new Exception('You must set xdebug.extended_info to 1 in your php.ini to use lime coverage.');
- }
-
- if (!count($this->harness->files))
- {
- throw new Exception('You must register some test files before running coverage!');
- }
-
- if (!count($this->files))
- {
- throw new Exception('You must register some files to cover!');
- }
-
- $coverage = array();
- $tmp_file = lime_test::get_temp_directory().DIRECTORY_SEPARATOR.'test.php';
- foreach ($this->harness->files as $file)
- {
- $tmp = <<'.serialize(xdebug_get_code_coverage()).'';
-EOF;
- file_put_contents($tmp_file, $tmp);
- ob_start();
- passthru(sprintf('%s -d html_errors=off -d open_basedir= -q "%s" 2>&1', $this->harness->php_cli, $tmp_file), $return);
- $retval = ob_get_clean();
- if (0 == $return)
- {
- if (false === $cov = unserialize(substr($retval, strpos($retval, '') + 9, strpos($retval, '') - 9)))
- {
- throw new Exception(sprintf('Unable to unserialize coverage for file "%s"', $file));
- }
-
- foreach ($cov as $file => $lines)
- {
- if (!isset($coverage[$file]))
- {
- $coverage[$file] = array();
- }
-
- foreach ($lines as $line => $count)
- {
- if (!isset($coverage[$file][$line]))
- {
- $coverage[$file][$line] = 0;
- }
- $coverage[$file][$line] = $coverage[$file][$line] + $count;
- }
- }
- }
- }
- unlink($tmp_file);
-
- ksort($coverage);
- $total_php_lines = 0;
- $total_covered_lines = 0;
- foreach ($this->files as $file)
- {
- $cov = isset($coverage[$file]) ? $coverage[$file] : array();
-
- list($cov, $php_lines) = $this->compute(file_get_contents($file), $cov);
-
- $output = $this->harness->output;
- $percent = count($php_lines) ? count($cov) * 100 / count($php_lines) : 100;
-
- $total_php_lines += count($php_lines);
- $total_covered_lines += count($cov);
-
- $relative_file = $this->get_relative_file($file);
- $output->echoln(sprintf("%-70s %3.0f%%", substr($relative_file, -min(70, strlen($relative_file))), $percent), $percent == 100 ? 'INFO' : ($percent > 90 ? 'PARAMETER' : ($percent < 20 ? 'ERROR' : '')));
- if ($this->verbose && $percent != 100)
- {
- $output->comment(sprintf("missing: %s", $this->format_range(array_keys(array_diff_key($php_lines, $cov)))));
- }
- }
-
- $output->echoln(sprintf("TOTAL COVERAGE: %3.0f%%", $total_covered_lines * 100 / $total_php_lines));
- }
-
- static function get_php_lines($content)
- {
- if (is_file($content))
- {
- $content = file_get_contents($content);
- }
-
- $tokens = token_get_all($content);
- $php_lines = array();
- $current_line = 1;
- $in_class = false;
- $in_function = false;
- $in_function_declaration = false;
- $end_of_current_expr = true;
- $open_braces = 0;
- foreach ($tokens as $token)
- {
- if (is_string($token))
- {
- switch ($token)
- {
- case '=':
- if (false === $in_class || (false !== $in_function && !$in_function_declaration))
- {
- $php_lines[$current_line] = true;
- }
- break;
- case '{':
- ++$open_braces;
- $in_function_declaration = false;
- break;
- case ';':
- $in_function_declaration = false;
- $end_of_current_expr = true;
- break;
- case '}':
- $end_of_current_expr = true;
- --$open_braces;
- if ($open_braces == $in_class)
- {
- $in_class = false;
- }
- if ($open_braces == $in_function)
- {
- $in_function = false;
- }
- break;
- }
-
- continue;
- }
-
- list($id, $text) = $token;
-
- switch ($id)
- {
- case T_CURLY_OPEN:
- case T_DOLLAR_OPEN_CURLY_BRACES:
- ++$open_braces;
- break;
- case T_WHITESPACE:
- case T_OPEN_TAG:
- case T_CLOSE_TAG:
- $end_of_current_expr = true;
- $current_line += count(explode("\n", $text)) - 1;
- break;
- case T_COMMENT:
- case T_DOC_COMMENT:
- $current_line += count(explode("\n", $text)) - 1;
- break;
- case T_CLASS:
- $in_class = $open_braces;
- break;
- case T_FUNCTION:
- $in_function = $open_braces;
- $in_function_declaration = true;
- break;
- case T_AND_EQUAL:
- case T_CASE:
- case T_CATCH:
- case T_CLONE:
- case T_CONCAT_EQUAL:
- case T_CONTINUE:
- case T_DEC:
- case T_DECLARE:
- case T_DEFAULT:
- case T_DIV_EQUAL:
- case T_DO:
- case T_ECHO:
- case T_ELSEIF:
- case T_EMPTY:
- case T_ENDDECLARE:
- case T_ENDFOR:
- case T_ENDFOREACH:
- case T_ENDIF:
- case T_ENDSWITCH:
- case T_ENDWHILE:
- case T_EVAL:
- case T_EXIT:
- case T_FOR:
- case T_FOREACH:
- case T_GLOBAL:
- case T_IF:
- case T_INC:
- case T_INCLUDE:
- case T_INCLUDE_ONCE:
- case T_INSTANCEOF:
- case T_ISSET:
- case T_IS_EQUAL:
- case T_IS_GREATER_OR_EQUAL:
- case T_IS_IDENTICAL:
- case T_IS_NOT_EQUAL:
- case T_IS_NOT_IDENTICAL:
- case T_IS_SMALLER_OR_EQUAL:
- case T_LIST:
- case T_LOGICAL_AND:
- case T_LOGICAL_OR:
- case T_LOGICAL_XOR:
- case T_MINUS_EQUAL:
- case T_MOD_EQUAL:
- case T_MUL_EQUAL:
- case T_NEW:
- case T_OBJECT_OPERATOR:
- case T_OR_EQUAL:
- case T_PLUS_EQUAL:
- case T_PRINT:
- case T_REQUIRE:
- case T_REQUIRE_ONCE:
- case T_RETURN:
- case T_SL:
- case T_SL_EQUAL:
- case T_SR:
- case T_SR_EQUAL:
- case T_THROW:
- case T_TRY:
- case T_UNSET:
- case T_UNSET_CAST:
- case T_USE:
- case T_WHILE:
- case T_XOR_EQUAL:
- $php_lines[$current_line] = true;
- $end_of_current_expr = false;
- break;
- default:
- if (false === $end_of_current_expr)
- {
- $php_lines[$current_line] = true;
- }
- //print "$current_line: ".token_name($id)."\n";
- }
- }
-
- return $php_lines;
- }
-
- function compute($content, $cov)
- {
- $php_lines = self::get_php_lines($content);
-
- // we remove from $cov non php lines
- foreach (array_diff_key($cov, $php_lines) as $line => $tmp)
- {
- unset($cov[$line]);
- }
-
- return array($cov, $php_lines);
- }
-
- function format_range($lines)
- {
- sort($lines);
- $formatted = '';
- $first = -1;
- $last = -1;
- foreach ($lines as $line)
- {
- if ($last + 1 != $line)
- {
- if ($first != -1)
- {
- $formatted .= $first == $last ? "$first " : "[$first - $last] ";
- }
- $first = $line;
- $last = $line;
- }
- else
- {
- $last = $line;
- }
- }
- if ($first != -1)
- {
- $formatted .= $first == $last ? "$first " : "[$first - $last] ";
- }
-
- return $formatted;
- }
-}
-
-class lime_registration
-{
- public $files = array();
- public $extension = '.php';
- public $base_dir = '';
-
- function register($files_or_directories)
- {
- foreach ((array) $files_or_directories as $f_or_d)
- {
- if (is_file($f_or_d))
- {
- $this->files[] = realpath($f_or_d);
- }
- elseif (is_dir($f_or_d))
- {
- $this->register_dir($f_or_d);
- }
- else
- {
- throw new Exception(sprintf('The file or directory "%s" does not exist.', $f_or_d));
- }
- }
- }
-
- function register_glob($glob)
- {
- if ($dirs = glob($glob))
- {
- foreach ($dirs as $file)
- {
- $this->files[] = realpath($file);
- }
- }
- }
-
- function register_dir($directory)
- {
- if (!is_dir($directory))
- {
- throw new Exception(sprintf('The directory "%s" does not exist.', $directory));
- }
-
- $files = array();
-
- $current_dir = opendir($directory);
- while ($entry = readdir($current_dir))
- {
- if ($entry == '.' || $entry == '..') continue;
-
- if (is_dir($entry))
- {
- $this->register_dir($entry);
- }
- elseif (preg_match('#'.$this->extension.'$#', $entry))
- {
- $files[] = realpath($directory.DIRECTORY_SEPARATOR.$entry);
- }
- }
-
- $this->files = array_merge($this->files, $files);
- }
-
- protected function get_relative_file($file)
- {
- return str_replace(DIRECTORY_SEPARATOR, '/', str_replace(array(realpath($this->base_dir).DIRECTORY_SEPARATOR, $this->extension), '', $file));
- }
-}
diff --git a/thirdparty/lime/yaml.class.php b/thirdparty/lime/yaml.class.php
deleted file mode 100644
index e170220ca..000000000
--- a/thirdparty/lime/yaml.class.php
+++ /dev/null
@@ -1,93 +0,0 @@
-
- * $array = sfYAML::Load('config.yml');
- * print_r($array);
- *
- *
- * @return array
- * @param string $input Path of YAML file or string containing YAML
- */
- public static function load($input)
- {
- $input = self::getIncludeContents($input);
-
- // if an array is returned by the config file assume it's in plain php form else in yaml
- if (is_array($input))
- {
- return $input;
- }
-
- // syck is prefered over spyc
- if (function_exists('syck_load'))
- {
- $retval = syck_load($input);
-
- return is_array($retval) ? $retval : array();
- }
- else
- {
- require_once(dirname(__FILE__).'/Spyc.class.php');
-
- $spyc = new Spyc();
-
- return $spyc->load($input);
- }
- }
-
- /**
- * Dump YAML from PHP array statically
- *
- * The dump method, when supplied with an array, will do its best
- * to convert the array into friendly YAML.
- *
- * @return string
- * @param array $array PHP array
- */
- public static function dump($array)
- {
- require_once(dirname(__FILE__).'/Spyc.class.php');
-
- $spyc = new Spyc();
-
- return $spyc->dump($array);
- }
-
- protected static function getIncludeContents($input)
- {
- // if input is a file, process it
- if (strpos($input, "\n") === false && is_file($input))
- {
- ob_start();
- $retval = include($input);
- $contents = ob_get_clean();
-
- // if an array is returned by the config file assume it's in plain php form else in yaml
- return is_array($retval) ? $retval : $contents;
- }
-
- // else return original input
- return $input;
- }
-}
-
-/**
- * Wraps echo to automatically provide a newline
- */
-function echoln($string)
-{
- echo $string."\n";
-}