[Joomla-commits] r18743 - in development/trunk: administrator/language/en-GB administrator/language/xx-XX installation libraries/joomla/error libraries/joomla/html/html libraries/joomla/utilities plugins/system/debug tests/unit/suite/libraries/joomla/html/html

0 views
Skip to first unread message

eddi...@jcode001.directrouter.com

unread,
Aug 31, 2010, 10:01:33 PM8/31/10
to joomla-...@joomlacode.org
Author: eddieajau
Date: 2010-08-31 21:01:33 -0500 (Tue, 31 Aug 2010)
New Revision: 18743

Added:
development/trunk/libraries/joomla/html/html/number.php
development/trunk/tests/unit/suite/libraries/joomla/html/html/JHtmlNumber.php
Modified:
development/trunk/administrator/language/en-GB/en-GB.plg_system_debug.ini
development/trunk/administrator/language/xx-XX/xx-XX.plg_system_debug.ini
development/trunk/installation/CHANGELOG
development/trunk/libraries/joomla/error/profiler.php
development/trunk/libraries/joomla/utilities/utility.php
development/trunk/plugins/system/debug/debug.php
development/trunk/plugins/system/debug/debug.xml
Log:
Fixed issue [#21604] The "Memory Usage" debug info has no measurement unit (Javier G?\195?\179mez, Nikolai Plath, Omar Ramos).

Modified: development/trunk/administrator/language/en-GB/en-GB.plg_system_debug.ini
===================================================================
--- development/trunk/administrator/language/en-GB/en-GB.plg_system_debug.ini 2010-09-01 01:02:34 UTC (rev 18742)
+++ development/trunk/administrator/language/en-GB/en-GB.plg_system_debug.ini 2010-09-01 02:01:33 UTC (rev 18743)
@@ -18,6 +18,8 @@
PLG_DEBUG_FIELD_PROFILING_LABEL="Show Profiling"
PLG_DEBUG_FIELD_QUERIES_DESC="Display a list the queries executed while displaying the page."
PLG_DEBUG_FIELD_QUERIES_LABEL="Show Queries"
+PLG_DEBUG_FIELD_QUERY_TYPES_DESC="Display a list of unique query types and their number of occurrences for the current page. Useful for finding out about repeated queries that are either redundant or which can be grouped into a single, more efficient query."
+PLG_DEBUG_FIELD_QUERY_TYPES_LABEL="Show Query Types"
PLG_DEBUG_FIELD_STRIP_FIRST_DESC="In multi-word strings, always strip the first word."
PLG_DEBUG_FIELD_STRIP_FIRST_LABEL="Strip First Word"
PLG_DEBUG_FIELD_STRIP_PREFIX_DESC="Strip words from the beginning of the string. For multiple words, use the format: (word1|word2)"
@@ -30,8 +32,11 @@
PLG_DEBUG_MEMORY_USAGE="Memory Usage"
PLG_DEBUG_PROFILE_INFORMATION="Profile Information"
PLG_DEBUG_QUERIES_LOGGED="%d Queries Logged"
+PLG_DEBUG_QUERY_TYPES_LOGGED="%d Query Types Logged, Sorted by Occurrences DESC"
+PLG_DEBUG_SELECT_QUERIES="SELECT Tables:"
+PLG_DEBUG_OTHER_QUERIES="OTHER Tables:"
+PLG_DEBUG_QUERY_TYPE_AND_OCCURRENCES="%2$d × %1$s"
PLG_DEBUG_UNKNOWN_FILE="Unknown file"
PLG_DEBUG_UNTRANSLATED_STRINGS="Untranslated Strings"
PLG_DEBUG_XML_DESCRIPTION="This plugin provides a variety of system information and assistance for the creation of translation files."
PLG_SYSTEM_DEBUG="System - Debug"
-

Modified: development/trunk/administrator/language/xx-XX/xx-XX.plg_system_debug.ini
===================================================================
--- development/trunk/administrator/language/xx-XX/xx-XX.plg_system_debug.ini 2010-09-01 01:02:34 UTC (rev 18742)
+++ development/trunk/administrator/language/xx-XX/xx-XX.plg_system_debug.ini 2010-09-01 02:01:33 UTC (rev 18743)
@@ -18,6 +18,8 @@
PLG_DEBUG_FIELD_PROFILING_LABEL="Show Profiling"
PLG_DEBUG_FIELD_QUERIES_DESC="Display a list the queries executed while displaying the page."
PLG_DEBUG_FIELD_QUERIES_LABEL="Show Queries"
+PLG_DEBUG_FIELD_QUERY_TYPES_DESC="Display a list of unique query types and their number of occurrences for the current page. Useful for finding out about repeated queries that are either redundant or which can be grouped into a single, more efficient query."
+PLG_DEBUG_FIELD_QUERY_TYPES_LABEL="Show Query Types"
PLG_DEBUG_FIELD_STRIP_FIRST_DESC="In multi-word strings, always strip the first word."
PLG_DEBUG_FIELD_STRIP_FIRST_LABEL="Strip First Word"
PLG_DEBUG_FIELD_STRIP_PREFIX_DESC="Strip words from the beginning of the string. For multiple words, use the format: (word1|word2)"
@@ -30,8 +32,11 @@
PLG_DEBUG_MEMORY_USAGE="Memory Usage"
PLG_DEBUG_PROFILE_INFORMATION="Profile Information"
PLG_DEBUG_QUERIES_LOGGED="%d Queries Logged"
+PLG_DEBUG_QUERY_TYPES_LOGGED="%d Query Types Logged, Sorted by Occurrences DESC"
+PLG_DEBUG_SELECT_QUERIES="SELECT Tables:"
+PLG_DEBUG_OTHER_QUERIES="OTHER Tables:"
+PLG_DEBUG_QUERY_TYPE_AND_OCCURRENCES="%2$d × %1$s"
PLG_DEBUG_UNKNOWN_FILE="Unknown file"
PLG_DEBUG_UNTRANSLATED_STRINGS="Untranslated Strings"
PLG_DEBUG_XML_DESCRIPTION="This plugin provides a variety of system information and assistance for the creation of translation files."
PLG_SYSTEM_DEBUG="System - Debug"
-

Modified: development/trunk/installation/CHANGELOG
===================================================================
--- development/trunk/installation/CHANGELOG 2010-09-01 01:02:34 UTC (rev 18742)
+++ development/trunk/installation/CHANGELOG 2010-09-01 02:01:33 UTC (rev 18743)
@@ -29,6 +29,7 @@

01-Sep-2010 Andrew Eddie (and Happy 5th Birthday Joomla!)
# Fixed issue [#22118] The setRedirect method() overwrites an already set messageType (Roland Dalmulder, Artyom Bisyarin).
+ # Fixed issue [#21604] The "Memory Usage" debug info has no measurement unit (Javier Gómez, Nikolai Plath, Omar Ramos).

31-Aug-2010 Jean-Marie Simonet
# [#22150] hathor menu type - unable to select type. Thanks Bill.

Modified: development/trunk/libraries/joomla/error/profiler.php
===================================================================
--- development/trunk/libraries/joomla/error/profiler.php 2010-09-01 01:02:34 UTC (rev 18742)
+++ development/trunk/libraries/joomla/error/profiler.php 2010-09-01 02:01:33 UTC (rev 18743)
@@ -108,11 +108,10 @@
public function mark($label)
{
$current = self::getmicrotime() - $this->_start;
- if (function_exists('memory_get_usage'))
- {
+ if (function_exists('memory_get_usage')) {
$current_mem = memory_get_usage() / 1048576;
$mark = sprintf(
- '<code>%s %.3f seconds (+%.3f); %0.2f Mb (+%0.2f) - %s</code>',
+ '<code>%s %.3f seconds (+%.3f); %0.2f MB (+%0.2f) - %s</code>',
$this->_prefix,
$current,
$current - $this->_previous_time,
@@ -121,8 +120,7 @@
$label
);
}
- else
- {
+ else {
$mark = sprintf(
'<code>%s %.3f seconds (+%.3f) - %s</code>',
$this->_prefix,
@@ -131,9 +129,11 @@
$label
);
}
+
$this->_previous_time = $current;
$this->_previous_mem = $current_mem;
$this->_buffer[] = $mark;
+
return $mark;
}

@@ -145,6 +145,7 @@
public static function getmicrotime()
{
list($usec, $sec) = explode(' ', microtime());
+
return ((float)$usec + (float)$sec);
}

@@ -159,14 +160,12 @@
if (function_exists('memory_get_usage')) {
return memory_get_usage();
}
- else
- {
+ else {
// Initialise variables.
$output = array();
$pid = getmypid();

- if ($this->_iswin)
- {
+ if ($this->_iswin) {
// Windows workaround
@exec('tasklist /FI "PID eq ' . $pid . '" /FO LIST', $output);
if (!isset($output[5])) {
@@ -174,8 +173,7 @@
}
return substr($output[5], strpos($output[5], ':') + 1);
}
- else
- {
+ else {
@exec("ps -o rss -p $pid", $output);
return $output[1] *1024;
}

Added: development/trunk/libraries/joomla/html/html/number.php
===================================================================
--- development/trunk/libraries/joomla/html/html/number.php (rev 0)
+++ development/trunk/libraries/joomla/html/html/number.php 2010-09-01 02:01:33 UTC (rev 18743)
@@ -0,0 +1,57 @@
+<?php
+/**
+ * @version $Id$
+ * @copyright Copyright (C) 2005 - 2009 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE.txt
+ */
+
+// No direct access.
+defined('_JEXEC') or die;
+
+/**
+ * HTML helper class for rendering numbers.
+ *
+ * @package Joomla.Framework
+ * @subpackage HTML
+ * @since 1.6
+ */
+abstract class JHtmlNumber
+{
+ /**
+ * Converts bytes to more distinguishable formats such as:
+ * kilobytes, megabytes, etc.
+ *
+ * By default, the proper format will automatically be chosen.
+ * However, one of the allowed unit types may also be used instead.
+ *
+ * @param int $bytes The number of bytes.
+ * @param string $unit The type of unit to return.
+ * @param int $precision The number of digits to be used after the decimal place.
+ *
+ * @return string The number of bytes in the proper units.
+ * @since 1.6
+ */
+ public static function bytes($bytes, $unit = 'auto', $precision = 2)
+ {
+ $bytes = (int) $bytes;
+ $precision = (int) $precision;
+
+ if (empty($bytes)) {
+ return 0;
+ }
+
+ $unitTypes = array('b','kb','MB','GB','TB','PB');
+
+ // Default automatic method.
+ $i = floor(log($bytes, 1024));
+
+ // User supplied method:
+ if ($unit !== 'auto' && in_array($unit, $unitTypes)) {
+ $i = array_search($unit, $unitTypes, true);
+ }
+
+ // TODO Allow conversion of units where $bytes = '32M'.
+
+ return round($bytes / pow(1024, $i), $precision).' '.$unitTypes[$i];
+ }
+}
\ No newline at end of file


Property changes on: development/trunk/libraries/joomla/html/html/number.php
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ LF

Modified: development/trunk/libraries/joomla/utilities/utility.php
===================================================================
--- development/trunk/libraries/joomla/utilities/utility.php 2010-09-01 01:02:34 UTC (rev 18742)
+++ development/trunk/libraries/joomla/utilities/utility.php 2010-09-01 02:01:33 UTC (rev 18743)
@@ -13,74 +13,82 @@
/**
* JUtility is a utility functions class
*
- * @static
* @package Joomla.Framework
* @subpackage Utilities
- * @since 1.5
+ * @since 1.5
*/
class JUtility
{
/**
* Mail function (uses phpMailer)
*
- * @param string $from From email address
- * @param string $fromname From name
- * @param mixed $recipient Recipient email address(es)
- * @param string $subject email subject
- * @param string $body Message body
- * @param boolean $mode false = plain text, true = HTML
- * @param mixed $cc CC email address(es)
- * @param mixed $bcc BCC email address(es)
- * @param mixed $attachment Attachment file name(s)
- * @param mixed $replyto Reply to email address(es)
- * @param mixed $replytoname Reply to name(s)
- * @return boolean True on success
+ * @param string $from From email address
+ * @param string $fromname From name
+ * @param mixed $recipient Recipient email address(es)
+ * @param string $subject Email subject
+ * @param string $body Message body
+ * @param boolean $mode false = plain text, true = HTML
+ * @param mixed $cc CC email address(es)
+ * @param mixed $bcc BCC email address(es)
+ * @param mixed $attachment Attachment file name(s)
+ * @param mixed $replyto Reply to email address(es)
+ * @param mixed $replytoname Reply to name(s)
+ * @return boolean True on success
*
+ * @since 1.5
* @deprecated 1.6
- * @see JMail::sendMail()
+ * @see JMail::sendMail()
*/
public static function sendMail($from, $fromname, $recipient, $subject, $body, $mode=0, $cc=null, $bcc=null, $attachment=null, $replyto=null, $replytoname=null)
{
// Get a JMail instance
$mail = JFactory::getMailer();

- return $mail->sendMail($from, $fromname, $recipient, $subject, $body, $mode, $cc,
- $bcc, $attachment, $replyto, $replytoname);
+ return $mail->sendMail(
+ $from, $fromname, $recipient, $subject, $body, $mode, $cc,
+ $bcc, $attachment, $replyto, $replytoname
+ );
}

/**
* Sends mail to administrator for approval of a user submission
*
- * @param string $adminName Name of administrator
- * @param string $adminEmail Email address of administrator
- * @param string $email [NOT USED TODO: Deprecate?]
- * @param string $type Type of item to approve
- * @param string $title Title of item to approve
- * @param string $author Author of item to approve
- * @return boolean True on success
+ * @param string $adminName Name of administrator
+ * @param string $adminEmail Email address of administrator
+ * @param string $email [NOT USED TODO: Deprecate?]
+ * @param string $type Type of item to approve
+ * @param string $title Title of item to approve
+ * @param string $author Author of item to approve
*
+ * @return boolean True on success
+ *
* @deprecated 1.6
- * @see JMail::sendAdminMail()
+ * @see JMail::sendAdminMail()
*/
public static function sendAdminMail($adminName, $adminEmail, $email, $type, $title, $author, $url = null)
{
// Get a JMail instance
$mail = JFactory::getMailer();
- return $mail->sendAdminMail($adminName, $adminEmail, $email, $type, $title, $author, $url);
+
+ return $mail->sendAdminMail(
+ $adminName, $adminEmail, $email, $type, $title, $author, $url
+ );
}

/**
* Provides a secure hash based on a seed
*
- * @param string Seed string
- * @return string
+ * @param string $seed Seed string.
*
+ * @return string
+ *
* @deprecated 1.6
- * @see JApplication:getHash()
+ * @see JApplication:getHash()
*/
public static function getHash($seed)
{
$conf = JFactory::getConfig();
+
return md5($conf->get('secret').$seed);
}

@@ -88,14 +96,15 @@
* Method to determine a hash for anti-spoofing variable names
*
* @return string Hashed var name
- * @since 1.5
+ *
+ * @since 1.5
* @deprecated 1.6
- * @see JApplication:getHash()
- * @static
+ * @see JApplication:getHash()
*/
public static function getToken($forceNew = false)
{
$session = JFactory::getSession();
+
return $session->getFormToken($forceNew);
}

@@ -103,8 +112,10 @@
* Method to extract key/value pairs out of a string with xml style attributes
*
* @param string $string String containing xml style attributes
+ *
* @return array Key/Value pairs for the attributes
- * @since 1.5
+ *
+ * @since 1.5
*/
public static function parseAttributes($string)
{
@@ -115,76 +126,90 @@
// Lets grab all the key/value pairs using a regular expression
preg_match_all('/([\w:-]+)[\s]?=[\s]?"([^"]*)"/i', $string, $attr);

- if (is_array($attr))
- {
+ if (is_array($attr)) {
$numPairs = count($attr[1]);
for ($i = 0; $i < $numPairs; $i++)
{
$retarray[$attr[1][$i]] = $attr[2][$i];
}
}
+
return $retarray;
}

/**
* Method to determine if the host OS is Windows
*
- * @return true if Windows OS
- * @since 1.5
+ * @return boolean True if Windows OS.
+ *
+ * @since 1.5
* @deprecated 1.6
- * @see JApplication::isWinOS()
- * @static
+ * @see JApplication::isWinOS()
*/
- function isWinOS() {
+ public static function isWinOS()
+ {
$application = JFactory::getApplication();
+
return $application->isWinOS();
}

/**
* Method to dump the structure of a variable for debugging purposes
*
- * @param mixed A variable
- * @param boolean True to ensure all characters are htmlsafe
+ * @param mixed $var A variable
+ * @param boolean $htmlSafe True to ensure all characters are htmlsafe
+ *
* @return string
- * @since 1.5
- * @static
*
+ * @since 1.5
* @deprecated 1.6
*/
- function dump(&$var, $htmlSafe = true)
+ public static function dump(&$var, $htmlSafe = true)
{
$result = var_export($var, true);
+
return '<pre>'.($htmlSafe ? htmlspecialchars($result, ENT_COMPAT, 'UTF-8') : $result).'</pre>';
}

/**
- * Prepend a reference to an element to the beginning of an array. Renumbers numeric keys, so $value is always inserted to $array[0]
+ * Prepend a reference to an element to the beginning of an array.
+ * Renumbers numeric keys, so $value is always inserted to $array[0]
*
- * @param $array array
- * @param $value mixed
- * @return int
- * @see http://www.php.net/manual/en/function.array-unshift.php#40270
+ * @param $array array
+ * @param $value mixed
+ *
+ * @return int
+ *
+ * @since 1.5
* @deprecated 1.6
+ * @see http://www.php.net/manual/en/function.array-unshift.php#40270
*/
function array_unshift_ref(&$array, &$value)
{
$return = array_unshift($array,'');
$array[0] = &$value;
+
return $return;
}

/**
* Return the byte value of a particular string
- * @param string String optionally with G, M or K suffix
- * @return int size in bytes
- * @since 1.6
+ *
+ * @param string $val String optionally with G, M or K suffix
+ *
+ * @return int size in bytes
+ *
+ * @since 1.6
* @deprecated 1.6
- * @see InstallerModelWarnings::return_bytes()
+ * @see JHtmlNumber::bytes
*/
- function return_bytes($val) {
+ function return_bytes($val)
+ {
$val = trim($val);
$last = strtolower($val{strlen($val)-1});
- switch($last) {
+
+ switch($last)
+ {
// The 'G' modifier is available since PHP 5.1.0
case 'g':
$val *= 1024;
@@ -196,5 +221,4 @@

return $val;
}
-
}

Modified: development/trunk/plugins/system/debug/debug.php
===================================================================
--- development/trunk/plugins/system/debug/debug.php 2010-09-01 01:02:34 UTC (rev 18742)
+++ development/trunk/plugins/system/debug/debug.php 2010-09-01 02:01:33 UTC (rev 18743)
@@ -86,7 +86,9 @@

if ($this->params->get('memory', 1)) {
echo '<h4>'.JText::_('PLG_DEBUG_MEMORY_USAGE').'</h4>';
- echo number_format($profiler->getMemory());
+ $bytes = $profiler->getMemory();
+ echo JHtml::_('number.bytes', $bytes);
+ echo ' ('.number_format($bytes).' Bytes)';
}

if ($this->params->get('queries', 1)) {
@@ -98,12 +100,75 @@

if ($log = $db->getLog()) {
echo '<ol>';
+ $selectQueryTypeTicker = array();
+ $otherQueryTypeTicker = array();
foreach ($log as $k => $sql) {
+ // Start Query Type Ticker Additions
+ $fromStart = stripos($sql, 'from');
+ $whereStart = stripos($sql, 'where', $fromStart);
+ if ($whereStart === false) {
+ $whereStart = stripos($sql, 'order by', $fromStart);
+ }
+ if ($whereStart === false) {
+ $whereStart = strlen($sql) - 1;
+ }
+ $fromString = substr($sql, 0, $whereStart);
+ $fromString = str_replace("\t", " ", $fromString);
+ $fromString = str_replace("\n", " ", $fromString);
+ $fromString = trim($fromString);
+
+ // Initialize the select/other query type counts the first time:
+ if (!isset($selectQueryTypeTicker[$fromString])) {
+ $selectQueryTypeTicker[$fromString] = 0;
+ }
+ if (!isset($otherQueryTypeTicker[$fromString])) {
+ $otherQueryTypeTicker[$fromString] = 0;
+ }
+ // Increment the count:
+ if (stripos($sql, 'select') === 0) {
+ $selectQueryTypeTicker[$fromString] = $selectQueryTypeTicker[$fromString] + 1;
+ unset($otherQueryTypeTicker[$fromString]);
+ } else {
+ $otherQueryTypeTicker[$fromString] = $otherQueryTypeTicker[$fromString] + 1;
+ unset($selectQueryTypeTicker[$fromString]);
+ }
+ // Finish Query Type Ticker Additions
+
+
$text = htmlspecialchars($sql, ENT_QUOTES);
$text = preg_replace($newlineKeywords, '<br />&#160;&#160;\\0', $text);
echo '<li>'.$text.'</li>';
}
echo '</ol>';
+
+ if ($this->params->get('query_types', 1)) {
+ // Get the totals for the query types:
+ $totalSelectQueryTypes = count($selectQueryTypeTicker);
+ $totalOtherQueryTypes = count($otherQueryTypeTicker);
+ $totalQueryTypes = $totalSelectQueryTypes + $totalOtherQueryTypes;
+
+ echo '<h4>'.JText::sprintf('PLG_DEBUG_QUERY_TYPES_LOGGED', $totalQueryTypes) . '</h4>';
+
+ if ($totalSelectQueryTypes) {
+ echo '<h5>'.JText::sprintf('PLG_DEBUG_SELECT_QUERIES').'</h5>';
+ arsort($selectQueryTypeTicker);
+ echo '<ol>';
+ foreach($selectQueryTypeTicker as $table => $occurrences) {
+ echo '<li>'.JText::sprintf('PLG_DEBUG_QUERY_TYPE_AND_OCCURRENCES', $table, $occurrences).'</li>';
+ }
+ echo '</ol>';
+ }
+
+ if ($totalOtherQueryTypes) {
+ echo '<h5>'.JText::sprintf('PLG_DEBUG_OTHER_QUERIES').'</h5>';
+ arsort($otherQueryTypeTicker);
+ echo '<ol>';
+ foreach($otherQueryTypeTicker as $table => $occurrences) {
+ echo '<li>'.JText::sprintf('PLG_DEBUG_QUERY_TYPE_AND_OCCURRENCES', $table, $occurrences).'</li>';
+ }
+ echo '</ol>';
+ }
+ }
}
}

Modified: development/trunk/plugins/system/debug/debug.xml
===================================================================
--- development/trunk/plugins/system/debug/debug.xml 2010-09-01 01:02:34 UTC (rev 18742)
+++ development/trunk/plugins/system/debug/debug.xml 2010-09-01 02:01:33 UTC (rev 18743)
@@ -43,6 +43,15 @@
<option value="0">JNo</option>
</field>

+ <field name="query_types" type="radio"
+ default="1"
+ description="PLG_DEBUG_FIELD_QUERY_TYPES_DESC"
+ label="PLG_DEBUG_FIELD_QUERY_TYPES_LABEL"
+ >
+ <option value="1">JYes</option>
+ <option value="0">JNo</option>
+ </field>
+
<field name="memory" type="radio"
default="1"
description="PLG_DEBUG_FIELD_MEMORY_DESC"

Added: development/trunk/tests/unit/suite/libraries/joomla/html/html/JHtmlNumber.php
===================================================================
--- development/trunk/tests/unit/suite/libraries/joomla/html/html/JHtmlNumber.php (rev 0)
+++ development/trunk/tests/unit/suite/libraries/joomla/html/html/JHtmlNumber.php 2010-09-01 02:01:33 UTC (rev 18743)
@@ -0,0 +1,117 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+
+require_once JPATH_BASE.'/libraries/joomla/html/html/number.php';
+
+/**
+ * Test class for JHtmlNumberTest.
+ */
+class JHtmlNumberTest extends PHPUnit_Framework_TestCase
+{
+ /**
+ * @return array
+ */
+ public function getTestBytesData()
+ {
+ return array(
+ // Element order: result, bytes, unit, precision
+ array(
+ '1 b',
+ 1,
+ ),
+ array(
+ '1 kb',
+ 1024,
+ ),
+ array(
+ '1 MB',
+ 1024*1024,
+ ),
+ array(
+ '1 GB',
+ 1024*1024*1024,
+ ),
+ array(
+ '1 TB',
+ 1024*1024*1024*1024,
+ ),
+ array(
+ '1 PB',
+ 1024*1024*1024*1024*1024,
+ ),
+
+ // Test units.
+ array(
+ '1024 TB',
+ 1024*1024*1024*1024*1024,
+ 'TB',
+ ),
+ array(
+ '1048576 GB',
+ 1024*1024*1024*1024*1024,
+ 'GB',
+ ),
+ array(
+ '1073741824 MB',
+ 1024*1024*1024*1024*1024,
+ 'MB',
+ ),
+ array(
+ '1099511627776 kb',
+ 1024*1024*1024*1024*1024,
+ 'kb',
+ ),
+ array(
+ '1.1258999068426E+15 b',
+ 1024*1024*1024*1024*1024,
+ 'b',
+ ),
+
+ // Test precision
+ array(
+ '1.33 kb',
+ 1357,
+ ),
+ array(
+ '1.3 kb',
+ 1357,
+ null,
+ 1
+ ),
+ array(
+ '1.33 kb',
+ 1357,
+ null,
+ 2
+ ),
+ array(
+ '1.325 kb',
+ 1357,
+ null,
+ 3
+ ),
+ array(
+ '1.3252 kb',
+ 1357,
+ null,
+ 4
+ ),
+ );
+ }
+
+ /**
+ * @param string $result
+ * @param int $btyes
+ * @param string $unit
+ * @param int $precision
+ *
+ * @dataProvider getTestBytesData
+ */
+ public function testBytes($result, $bytes, $unit = 'auto', $precision = 2)
+ {
+ $this->assertThat(
+ JHtmlNumber::bytes($bytes, $unit, $precision),
+ $this->equalTo($result)
+ );
+ }
+}
\ No newline at end of file


Property changes on: development/trunk/tests/unit/suite/libraries/joomla/html/html/JHtmlNumber.php
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ LF

_______________________________________________
Joomla-commits mailing list
Joomla-...@joomlacode.org
http://joomlacode.org/mailman/listinfo/joomla-commits

Reply all
Reply to author
Forward
0 new messages