Skip to content

Commit

Permalink
Merge pull request joomla#1501 from realityking/tests
Browse files Browse the repository at this point in the history
Improve test coverage some more.
  • Loading branch information
ianmacl committed Aug 29, 2012
2 parents 26f3b0e + 5f1a4de commit 1d62cf3
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 77 deletions.
29 changes: 0 additions & 29 deletions libraries/joomla/archive/zip.php
Expand Up @@ -541,35 +541,6 @@ private function _getFileData($key)
return '';
}

/**
* 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.
*
Expand Down
33 changes: 33 additions & 0 deletions tests/suites/unit/joomla/access/JRulesTest.php
Expand Up @@ -46,6 +46,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
Expand Down
1 change: 1 addition & 0 deletions tests/suites/unit/joomla/archive/JArchiveGzipTest.php
Expand Up @@ -74,6 +74,7 @@ public function testExtract()
* @group JArchive
* @return void
* @covers JArchiveGzip::extract
* @covers JArchiveGzip::_getFilePosition
*/
public function testExtractWithStreams()
{
Expand Down
1 change: 1 addition & 0 deletions tests/suites/unit/joomla/archive/JArchiveTarTest.php
Expand Up @@ -49,6 +49,7 @@ protected function tearDown()
* @group JArchive
* @return void
* @covers JArchiveTar::extract
* @covers JArchiveTar::_getTarInfo
*/
public function testExtract()
{
Expand Down
2 changes: 2 additions & 0 deletions tests/suites/unit/joomla/archive/JArchiveZipTest.php
Expand Up @@ -88,6 +88,8 @@ public function testExtractNative()
* @group JArchive
* @return void
* @covers JArchiveZip::extractCustom
* @covers JArchiveZip::_readZipInfo
* @covers JArchiveZip::_getFileData
*/
public function testExtractCustom()
{
Expand Down
6 changes: 3 additions & 3 deletions tests/suites/unit/joomla/log/JLogEntryTest.php
Expand Up @@ -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.
*/
Expand All @@ -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()
{
Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -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()
{
Expand Down
Expand Up @@ -43,6 +43,7 @@ public function tearDown()

/**
* Test the JLogLoggerMessageQueue::addEntry method.
* @covers JLogLoggerMessageQueue::addEntry
*/
public function testAddEntry01()
{
Expand Down
17 changes: 15 additions & 2 deletions tests/suites/unit/joomla/string/JStringInflectorTest.php
Expand Up @@ -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.
*
Expand Down Expand Up @@ -102,6 +100,7 @@ public function setUp()
* @return void
*
* @since 12.1
* @covers JStringInflector::_addRule
*/
public function test_addRule()
{
Expand Down Expand Up @@ -152,6 +151,7 @@ public function test_addRule()
*
* @since 12.1
* @expectedException InvalidArgumentException
* @covers JStringInflector::_addRule
*/
public function test_addRuleException()
{
Expand All @@ -164,6 +164,7 @@ public function test_addRuleException()
* @return void
*
* @since 12.1
* @covers JStringInflector::_getCachedPlural
*/
public function test_getCachedPlural()
{
Expand All @@ -189,6 +190,7 @@ public function test_getCachedPlural()
* @return void
*
* @since 12.1
* @covers JStringInflector::_getCachedSingular
*/
public function test_getCachedSingular()
{
Expand All @@ -214,6 +216,7 @@ public function test_getCachedSingular()
* @return void
*
* @since 12.1
* @covers JStringInflector::_matchRegexRule
*/
public function test_matchRegexRule()
{
Expand Down Expand Up @@ -242,6 +245,7 @@ public function test_matchRegexRule()
* @return void
*
* @since 12.1
* @covers JStringInflector::_setCache
*/
public function test_setCache()
{
Expand Down Expand Up @@ -272,6 +276,7 @@ public function test_setCache()
* @return void
*
* @since 12.1
* @covers JStringInflector::addCountableRule
*/
public function testAddCountableRule()
{
Expand Down Expand Up @@ -304,6 +309,7 @@ public function testAddCountableRule()
* @return void
*
* @since 12.1
* @covers JStringInflector::addPluraliseRule
*/
public function testAddPluraliseRule()
{
Expand All @@ -330,6 +336,7 @@ public function testAddPluraliseRule()
* @return void
*
* @since 12.1
* @covers JStringInflector::addSingulariseRule
*/
public function testAddSingulariseRule()
{
Expand All @@ -356,6 +363,7 @@ public function testAddSingulariseRule()
* @return void
*
* @since 12.1
* @covers JStringInflector::getInstance
*/
public function testGetInstance()
{
Expand Down Expand Up @@ -391,6 +399,7 @@ public function testGetInstance()
*
* @dataProvider seedIsCountable
* @since 12.1
* @covers JStringInflector::isCountable
*/
public function testIsCountable($input, $expected)
{
Expand All @@ -410,6 +419,7 @@ public function testIsCountable($input, $expected)
*
* @dataProvider seedSinglePlural
* @since 12.1
* @covers JStringInflector::isPlural
*/
public function testIsPlural($singular, $plural)
{
Expand Down Expand Up @@ -439,6 +449,7 @@ public function testIsPlural($singular, $plural)
*
* @dataProvider seedSinglePlural
* @since 12.1
* @covers JStringInflector::isSingular
*/
public function testIsSingular($singular, $plural)
{
Expand Down Expand Up @@ -468,6 +479,7 @@ public function testIsSingular($singular, $plural)
*
* @dataProvider seedSinglePlural
* @since 12.1
* @covers JStringInflector::toPlural
*/
public function testToPlural($singular, $plural)
{
Expand All @@ -487,6 +499,7 @@ public function testToPlural($singular, $plural)
*
* @dataProvider seedSinglePlural
* @since 12.1
* @covers JStringInflector::toSingular
*/
public function testToSingular($singular, $plural)
{
Expand Down

0 comments on commit 1d62cf3

Please sign in to comment.