Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1501 from realityking/tests

Improve test coverage some more.
  • Loading branch information...
commit 1d62cf3edfd3a0d76742e7bf99f3a153ecffa7cc 2 parents 26f3b0e + 5f1a4de
ianmacl ianmacl authored
29 libraries/joomla/archive/zip.php
View
@@ -542,35 +542,6 @@ private function _getFileData($key)
}
/**
- * Converts a UNIX timestamp to a 4-byte DOS date and time format
- * (date in high 2-bytes, time in low 2-bytes allowing magnitude
- * comparison).
- *
- * @param integer $unixtime The current UNIX timestamp.
- *
- * @return integer The current date in a 4-byte DOS format.
- *
- * @since 11.1
- */
- private function _unix2DOSTime($unixtime = null)
- {
- $timearray = (is_null($unixtime)) ? getdate() : getdate($unixtime);
-
- if ($timearray['year'] < 1980)
- {
- $timearray['year'] = 1980;
- $timearray['mon'] = 1;
- $timearray['mday'] = 1;
- $timearray['hours'] = 0;
- $timearray['minutes'] = 0;
- $timearray['seconds'] = 0;
- }
-
- return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | ($timearray['hours'] << 11) |
- ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
- }
-
- /**
* Adds a "file" to the ZIP archive.
*
* @param array &$file File data array to add
33 tests/suites/unit/joomla/access/JRulesTest.php
View
@@ -47,6 +47,39 @@ public function test__constructString()
}
/**
+ * Tests the JAccessRules::getData method.
+ *
+ * @return void
+ *
+ * @since 12.2
+ * @covers JAccessRules::getData
+ */
+ public function testGetData()
+ {
+ $array = array(
+ 'edit' => array(
+ -42 => 1,
+ 2 => 1,
+ 3 => 0
+ )
+ );
+
+ $rule = new JAccessRules($array);
+
+ $data = $rule->getData();
+
+ $this->assertArrayHasKey(
+ 'edit',
+ $data
+ );
+
+ $this->assertInstanceOf(
+ 'JAccessRule',
+ $data['edit']
+ );
+ }
+
+ /**
* @covers JAccessRules::__construct
* @covers JAccessRules::__toString
*/
1  tests/suites/unit/joomla/archive/JArchiveGzipTest.php
View
@@ -74,6 +74,7 @@ public function testExtract()
* @group JArchive
* @return void
* @covers JArchiveGzip::extract
+ * @covers JArchiveGzip::_getFilePosition
*/
public function testExtractWithStreams()
{
1  tests/suites/unit/joomla/archive/JArchiveTarTest.php
View
@@ -49,6 +49,7 @@ protected function tearDown()
* @group JArchive
* @return void
* @covers JArchiveTar::extract
+ * @covers JArchiveTar::_getTarInfo
*/
public function testExtract()
{
2  tests/suites/unit/joomla/archive/JArchiveZipTest.php
View
@@ -88,6 +88,8 @@ public function testExtractNative()
* @group JArchive
* @return void
* @covers JArchiveZip::extractCustom
+ * @covers JArchiveZip::_readZipInfo
+ * @covers JArchiveZip::_getFileData
*/
public function testExtractCustom()
{
6 tests/suites/unit/joomla/log/JLogEntryTest.php
View
@@ -7,9 +7,6 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/
-require_once JPATH_PLATFORM.'/joomla/log/log.php';
-require_once JPATH_PLATFORM.'/joomla/log/entry.php';
-
/**
* Test class for JLogEntry.
*/
@@ -19,6 +16,7 @@ class JLogEntryTest extends PHPUnit_Framework_TestCase
* Verify the default values for the log entry object.
*
* Test the JLogEntry::__construct method.
+ * @covers JLogEntry::__construct
*/
public function testDefaultValues()
{
@@ -58,6 +56,7 @@ public function testDefaultValues()
* Verify the priority for the entry object cannot be something not in the approved list.
*
* Test the JLogEntry::__construct method.
+ * @covers JLogEntry::__construct
*/
public function testBadPriorityValues()
{
@@ -87,6 +86,7 @@ public function testBadPriorityValues()
* Test that non-standard category values are sanitized.
*
* Test the JLogEntry::__construct method.
+ * @covers JLogEntry::__construct
*/
public function testCategorySanitization()
{
1  tests/suites/unit/joomla/log/loggers/JLogLoggerMessageQueueTest.php
View
@@ -43,6 +43,7 @@ public function tearDown()
/**
* Test the JLogLoggerMessageQueue::addEntry method.
+ * @covers JLogLoggerMessageQueue::addEntry
*/
public function testAddEntry01()
{
17 tests/suites/unit/joomla/string/JStringInflectorTest.php
View
@@ -7,8 +7,6 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/
-require_once JPATH_PLATFORM . '/joomla/string/inflector.php';
-
/**
* Test for the JStringInflector class.
*
@@ -102,6 +100,7 @@ public function setUp()
* @return void
*
* @since 12.1
+ * @covers JStringInflector::_addRule
*/
public function test_addRule()
{
@@ -152,6 +151,7 @@ public function test_addRule()
*
* @since 12.1
* @expectedException InvalidArgumentException
+ * @covers JStringInflector::_addRule
*/
public function test_addRuleException()
{
@@ -164,6 +164,7 @@ public function test_addRuleException()
* @return void
*
* @since 12.1
+ * @covers JStringInflector::_getCachedPlural
*/
public function test_getCachedPlural()
{
@@ -189,6 +190,7 @@ public function test_getCachedPlural()
* @return void
*
* @since 12.1
+ * @covers JStringInflector::_getCachedSingular
*/
public function test_getCachedSingular()
{
@@ -214,6 +216,7 @@ public function test_getCachedSingular()
* @return void
*
* @since 12.1
+ * @covers JStringInflector::_matchRegexRule
*/
public function test_matchRegexRule()
{
@@ -242,6 +245,7 @@ public function test_matchRegexRule()
* @return void
*
* @since 12.1
+ * @covers JStringInflector::_setCache
*/
public function test_setCache()
{
@@ -272,6 +276,7 @@ public function test_setCache()
* @return void
*
* @since 12.1
+ * @covers JStringInflector::addCountableRule
*/
public function testAddCountableRule()
{
@@ -304,6 +309,7 @@ public function testAddCountableRule()
* @return void
*
* @since 12.1
+ * @covers JStringInflector::addPluraliseRule
*/
public function testAddPluraliseRule()
{
@@ -330,6 +336,7 @@ public function testAddPluraliseRule()
* @return void
*
* @since 12.1
+ * @covers JStringInflector::addSingulariseRule
*/
public function testAddSingulariseRule()
{
@@ -356,6 +363,7 @@ public function testAddSingulariseRule()
* @return void
*
* @since 12.1
+ * @covers JStringInflector::getInstance
*/
public function testGetInstance()
{
@@ -391,6 +399,7 @@ public function testGetInstance()
*
* @dataProvider seedIsCountable
* @since 12.1
+ * @covers JStringInflector::isCountable
*/
public function testIsCountable($input, $expected)
{
@@ -410,6 +419,7 @@ public function testIsCountable($input, $expected)
*
* @dataProvider seedSinglePlural
* @since 12.1
+ * @covers JStringInflector::isPlural
*/
public function testIsPlural($singular, $plural)
{
@@ -439,6 +449,7 @@ public function testIsPlural($singular, $plural)
*
* @dataProvider seedSinglePlural
* @since 12.1
+ * @covers JStringInflector::isSingular
*/
public function testIsSingular($singular, $plural)
{
@@ -468,6 +479,7 @@ public function testIsSingular($singular, $plural)
*
* @dataProvider seedSinglePlural
* @since 12.1
+ * @covers JStringInflector::toPlural
*/
public function testToPlural($singular, $plural)
{
@@ -487,6 +499,7 @@ public function testToPlural($singular, $plural)
*
* @dataProvider seedSinglePlural
* @since 12.1
+ * @covers JStringInflector::toSingular
*/
public function testToSingular($singular, $plural)
{
91 tests/suites/unit/joomla/string/JStringNormaliseTest.php
View
@@ -7,7 +7,6 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/
-require_once JPATH_PLATFORM . '/joomla/string/normalise.php';
/**
* JStringNormaliseTest
@@ -37,36 +36,38 @@ public function getFromCamelCaseData()
);
}
- /**
- * Method to test JStringNormalise::fromCamelCase(string, false).
- *
- * @param string $expected The expected value from the method.
- * @param string $input The input value for the method.
- *
- * @return void
- *
- * @dataProvider seedFromCamelCase
- * @since 11.3
- */
- public function testFromCamelCase_nongrouped($expected, $input)
- {
- $this->assertEquals($expected, JStringNormalise::fromCamelcase($input));
+ /**
+ * Method to test JStringNormalise::fromCamelCase(string, false).
+ *
+ * @param string $expected The expected value from the method.
+ * @param string $input The input value for the method.
+ *
+ * @return void
+ *
+ * @dataProvider seedFromCamelCase
+ * @since 11.3
+ * @covers JStringNormalise::fromCamelcase
+ */
+ public function testFromCamelCase_nongrouped($expected, $input)
+ {
+ $this->assertEquals($expected, JStringNormalise::fromCamelcase($input));
}
- /**
- * Method to test JStringNormalise::fromCamelCase(string, true).
- *
- * @param string $expected The expected value from the method.
- * @param string $input The input value for the method.
- *
- * @return void
- *
- * @dataProvider getFromCamelCaseData
- * @since 11.3
- */
- public function testFromCamelCase_grouped($input, $expected)
- {
- $this->assertEquals($expected, JStringNormalise::fromCamelcase($input, true));
+ /**
+ * Method to test JStringNormalise::fromCamelCase(string, true).
+ *
+ * @param string $expected The expected value from the method.
+ * @param string $input The input value for the method.
+ *
+ * @return void
+ *
+ * @dataProvider getFromCamelCaseData
+ * @since 11.3
+ * @covers JStringNormalise::fromCamelcase
+ */
+ public function testFromCamelCase_grouped($input, $expected)
+ {
+ $this->assertEquals($expected, JStringNormalise::fromCamelcase($input, true));
}
/**
@@ -79,6 +80,7 @@ public function testFromCamelCase_grouped($input, $expected)
*
* @dataProvider seedToCamelCase
* @since 11.3
+ * @covers JStringNormalise::toCamelcase
*/
public function testToCamelCase($expected, $input)
{
@@ -95,6 +97,7 @@ public function testToCamelCase($expected, $input)
*
* @dataProvider seedToDashSeparated
* @since 11.3
+ * @covers JStringNormalise::toDashSeparated
*/
public function testToDashSeparated($expected, $input)
{
@@ -111,6 +114,7 @@ public function testToDashSeparated($expected, $input)
*
* @dataProvider seedToSpaceSeparated
* @since 11.3
+ * @covers JStringNormalise::toSpaceSeparated
*/
public function testToSpaceSeparated($expected, $input)
{
@@ -127,6 +131,7 @@ public function testToSpaceSeparated($expected, $input)
*
* @dataProvider seedToUnderscoreSeparated
* @since 11.3
+ * @covers JStringNormalise::toUnderscoreSeparated
*/
public function testToUnderscoreSeparated($expected, $input)
{
@@ -143,6 +148,7 @@ public function testToUnderscoreSeparated($expected, $input)
*
* @dataProvider seedToVariable
* @since 11.3
+ * @covers JStringNormalise::toVariable
*/
public function testToVariable($expected, $input)
{
@@ -159,27 +165,28 @@ public function testToVariable($expected, $input)
*
* @dataProvider seedToKey
* @since 11.3
+ * @covers JStringNormalise::toKey
*/
public function testToKey($expected, $input)
{
$this->assertEquals($expected, JStringNormalise::toKey($input));
}
- /**
- * Method to seed data to testFromCamelCase.
- *
- * @return array
- *
- * @since 11.3
- */
- public function seedFromCamelCase()
- {
- return array(
- array('Foo Bar', 'FooBar'),
+ /**
+ * Method to seed data to testFromCamelCase.
+ *
+ * @return array
+ *
+ * @since 11.3
+ */
+ public function seedFromCamelCase()
+ {
+ return array(
+ array('Foo Bar', 'FooBar'),
array('foo Bar', 'fooBar'),
array('Foobar', 'Foobar'),
- array('foobar', 'foobar')
- );
+ array('foobar', 'foobar')
+ );
}
/**
26 tests/suites/unit/joomla/string/JStringTest.php
View
@@ -7,7 +7,6 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/
-require_once JPATH_PLATFORM . '/joomla/string/string.php';
require_once 'TestHelpers/JString-helper-dataset.php';
/**
@@ -257,6 +256,7 @@ public function getValidData()
*
* @dataProvider getIncrementData
* @since 11.2
+ * @covers JString::increment
*/
public function testIncrement($string, $style, $number, $expected)
{
@@ -271,6 +271,7 @@ public function testIncrement($string, $style, $number, $expected)
*
* @dataProvider getStrposData
* @since 11.2
+ * @covers JString::strpos
*/
public function testStrpos($haystack, $needle, $offset = 0, $expect)
{
@@ -283,6 +284,7 @@ public function testStrpos($haystack, $needle, $offset = 0, $expect)
*
* @dataProvider getStrrposData
* @since 11.2
+ * @covers JString::strrpos
*/
public function testStrrpos($haystack, $needle, $offset = 0, $expect)
{
@@ -295,6 +297,7 @@ public function testStrrpos($haystack, $needle, $offset = 0, $expect)
*
* @dataProvider getSubstrData
* @since 11.2
+ * @covers JString::substr
*/
public function testSubstr($string, $start, $length = false, $expect)
{
@@ -307,6 +310,7 @@ public function testSubstr($string, $start, $length = false, $expect)
*
* @dataProvider getStrtolowerData
* @since 11.2
+ * @covers JString::strtolower
*/
public function testStrtolower($string, $expect)
{
@@ -319,6 +323,7 @@ public function testStrtolower($string, $expect)
*
* @dataProvider getStrtoupperData
* @since 11.2
+ * @covers JString::strtoupper
*/
public function testStrtoupper($string, $expect)
{
@@ -331,6 +336,7 @@ public function testStrtoupper($string, $expect)
*
* @dataProvider getStrlenData
* @since 11.2
+ * @covers JString::strlen
*/
public function testStrlen($string, $expect)
{
@@ -343,6 +349,7 @@ public function testStrlen($string, $expect)
*
* @dataProvider getStr_ireplaceData
* @since 11.2
+ * @covers JString::str_ireplace
*/
public function testStr_ireplace($search, $replace, $subject, $count, $expect)
{
@@ -355,6 +362,7 @@ public function testStr_ireplace($search, $replace, $subject, $count, $expect)
*
* @dataProvider getStr_splitData
* @since 11.2
+ * @covers JString::str_split
*/
public function testStr_split($string, $split_length, $expect)
{
@@ -367,6 +375,7 @@ public function testStr_split($string, $split_length, $expect)
*
* @dataProvider getStrcasecmpData
* @since 11.2
+ * @covers JString::strcasecmp
*/
public function testStrcasecmp($string1, $string2, $locale, $expect)
{
@@ -394,6 +403,7 @@ public function testStrcasecmp($string1, $string2, $locale, $expect)
*
* @dataProvider getStrcmpData
* @since 11.2
+ * @covers JString::strcmp
*/
public function testStrcmp($string1, $string2, $locale, $expect)
{
@@ -422,6 +432,7 @@ public function testStrcmp($string1, $string2, $locale, $expect)
*
* @dataProvider getStrcspnData
* @since 11.2
+ * @covers JString::strcspn
*/
public function testStrcspn($haystack, $needles, $start, $len, $expect)
{
@@ -434,6 +445,7 @@ public function testStrcspn($haystack, $needles, $start, $len, $expect)
*
* @dataProvider getStristrData
* @since 11.2
+ * @covers JString::stristr
*/
public function testStristr($haystack, $needle, $expect)
{
@@ -446,6 +458,7 @@ public function testStristr($haystack, $needle, $expect)
*
* @dataProvider getStrrevData
* @since 11.2
+ * @covers JString::strrev
*/
public function testStrrev($string, $expect)
{
@@ -458,6 +471,7 @@ public function testStrrev($string, $expect)
*
* @dataProvider getStrspnData
* @since 11.2
+ * @covers JString::strspn
*/
public function testStrspn($subject, $mask, $start, $length, $expect)
{
@@ -470,6 +484,7 @@ public function testStrspn($subject, $mask, $start, $length, $expect)
*
* @dataProvider getSubstr_replaceData
* @since 11.2
+ * @covers JString::substr_replace
*/
public function testSubstr_replace($string, $replacement, $start, $length, $expect)
{
@@ -482,6 +497,7 @@ public function testSubstr_replace($string, $replacement, $start, $length, $expe
*
* @dataProvider getLtrimData
* @since 11.2
+ * @covers JString::ltrim
*/
public function testLtrim($string, $charlist, $expect)
{
@@ -501,6 +517,7 @@ public function testLtrim($string, $charlist, $expect)
*
* @dataProvider getRtrimData
* @since 11.2
+ * @covers JString::rtrim
*/
public function testRtrim($string, $charlist, $expect)
{
@@ -520,6 +537,7 @@ public function testRtrim($string, $charlist, $expect)
*
* @dataProvider getTrimData
* @since 11.2
+ * @covers JString::trim
*/
public function testTrim($string, $charlist, $expect)
{
@@ -539,6 +557,7 @@ public function testTrim($string, $charlist, $expect)
*
* @dataProvider getUcfirstData
* @since 11.2
+ * @covers JString::ucfirst
*/
public function testUcfirst($string, $delimiter, $newDelimiter, $expect)
{
@@ -551,6 +570,7 @@ public function testUcfirst($string, $delimiter, $newDelimiter, $expect)
*
* @dataProvider getUcwordsData
* @since 11.2
+ * @covers JString::ucwords
*/
public function testUcwords($string, $expect)
{
@@ -563,6 +583,7 @@ public function testUcwords($string, $expect)
*
* @dataProvider getTranscodeData
* @since 11.2
+ * @covers JString::transcode
*/
public function testTranscode($source, $from_encoding, $to_encoding, $expect)
{
@@ -575,6 +596,7 @@ public function testTranscode($source, $from_encoding, $to_encoding, $expect)
*
* @dataProvider getValidData
* @since 11.2
+ * @covers JString::valid
*/
public function testValid($string, $expect)
{
@@ -587,6 +609,7 @@ public function testValid($string, $expect)
*
* @dataProvider getValidData
* @since 11.2
+ * @covers JString::compliant
*/
public function testCompliant($string, $expect)
{
@@ -598,6 +621,7 @@ public function testCompliant($string, $expect)
* @return array
*
* @since 11.2
+ * @covers JString::parse_url
*/
public function testParse_Url()
{
2  tests/suites/unit/joomla/utilities/JArrayHelperTest.php
View
@@ -1342,6 +1342,7 @@ public function testArrayUnique($input, $expected)
*
* @dataProvider getTestFromObjectData
* @covers JArrayHelper::fromObject
+ * @covers JArrayHelper::_fromObject
* @since 11.1
*/
public function testFromObject($input, $recurse, $regex, $expect, $defaults)
@@ -1484,6 +1485,7 @@ public function testPivot($source, $key, $expected)
*
* @dataProvider getTestSortObjectData
* @covers JArrayHelper::sortObjects
+ * @covers JArrayHelper::_sortObjects
* @since 11.1
*/
public function testSortObjects($input, $key, $direction, $casesensitive, $locale, $expect, $message, $defaults)
Please sign in to comment.
Something went wrong with that request. Please try again.