Fix most coding standards issues in Test/Case/Utility

This commit is contained in:
mark_story 2012-03-13 22:59:20 -04:00
parent 4e94ebe710
commit 1efee89169
11 changed files with 217 additions and 198 deletions

View file

@ -108,7 +108,7 @@ class CakeNumberTest extends CakeTestCase {
$expected = '100 100 100,00€'; $expected = '100 100 100,00€';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$result = $this->Number->currency(1000.45, NULL, array('after' => 'øre', 'before' => 'Kr. ', 'decimals' => ',', 'thousands' => '.')); $result = $this->Number->currency(1000.45, null, array('after' => 'øre', 'before' => 'Kr. ', 'decimals' => ',', 'thousands' => '.'));
$expected = 'Kr. 1.000,45'; $expected = 'Kr. 1.000,45';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
@ -116,7 +116,7 @@ class CakeNumberTest extends CakeTestCase {
$expected = '50c'; $expected = '50c';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$result = $this->Number->currency(0.5, NULL, array('after' => 'øre')); $result = $this->Number->currency(0.5, null, array('after' => 'øre'));
$expected = '50øre'; $expected = '50øre';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
@ -247,7 +247,6 @@ class CakeNumberTest extends CakeTestCase {
$result = $this->Number->currency($value, 'GBP', array('negative' => '-')); $result = $this->Number->currency($value, 'GBP', array('negative' => '-'));
$expected = '-£100,100,100.00'; $expected = '-£100,100,100.00';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
/** /**
@ -400,39 +399,39 @@ class CakeNumberTest extends CakeTestCase {
$expected = '1 KB'; $expected = '1 KB';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$result = $this->Number->toReadableSize(1024*512); $result = $this->Number->toReadableSize(1024 * 512);
$expected = '512 KB'; $expected = '512 KB';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$result = $this->Number->toReadableSize(1024*1024-1); $result = $this->Number->toReadableSize(1024 * 1024 - 1);
$expected = '1.00 MB'; $expected = '1.00 MB';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$result = $this->Number->toReadableSize(1024*1024*512); $result = $this->Number->toReadableSize(1024 * 1024 * 512);
$expected = '512.00 MB'; $expected = '512.00 MB';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$result = $this->Number->toReadableSize(1024*1024*1024-1); $result = $this->Number->toReadableSize(1024 * 1024 * 1024 - 1);
$expected = '1.00 GB'; $expected = '1.00 GB';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$result = $this->Number->toReadableSize(1024*1024*1024*512); $result = $this->Number->toReadableSize(1024 * 1024 * 1024 * 512);
$expected = '512.00 GB'; $expected = '512.00 GB';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$result = $this->Number->toReadableSize(1024*1024*1024*1024-1); $result = $this->Number->toReadableSize(1024 * 1024 * 1024 * 1024 - 1);
$expected = '1.00 TB'; $expected = '1.00 TB';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$result = $this->Number->toReadableSize(1024*1024*1024*1024*512); $result = $this->Number->toReadableSize(1024 * 1024 * 1024 * 1024 * 512);
$expected = '512.00 TB'; $expected = '512.00 TB';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$result = $this->Number->toReadableSize(1024*1024*1024*1024*1024-1); $result = $this->Number->toReadableSize(1024 * 1024 * 1024 * 1024 * 1024 - 1);
$expected = '1024.00 TB'; $expected = '1024.00 TB';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$result = $this->Number->toReadableSize(1024*1024*1024*1024*1024*1024); $result = $this->Number->toReadableSize(1024 * 1024 * 1024 * 1024 * 1024 * 1024);
$expected = (1024 * 1024) . '.00 TB'; $expected = (1024 * 1024) . '.00 TB';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
@ -459,4 +458,5 @@ class CakeNumberTest extends CakeTestCase {
$expected = '0.0000%'; $expected = '0.0000%';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
} }

View file

@ -121,7 +121,7 @@ class CakeTimeTest extends CakeTestCase {
$hours = 0; $hours = 0;
$minutes = 0; $minutes = 0;
$seconds = 0; $seconds = 0;
$relative_date = ''; $relativeDate = '';
// Trying to take into account the number of days in a month // Trying to take into account the number of days in a month
$month = date('m') - $months; $month = date('m') - $months;
@ -137,43 +137,43 @@ class CakeTimeTest extends CakeTestCase {
if ($years > 0) { if ($years > 0) {
// years and months and days // years and months and days
$relative_date .= ($relative_date ? ', -' : '-') . $years . ' year' . ($years > 1 ? 's' : ''); $relativeDate .= ($relativeDate ? ', -' : '-') . $years . ' year' . ($years > 1 ? 's' : '');
$relative_date .= $months > 0 ? ($relative_date ? ', -' : '-') . $months . ' month' . ($months > 1 ? 's' : '') : ''; $relativeDate .= $months > 0 ? ($relativeDate ? ', -' : '-') . $months . ' month' . ($months > 1 ? 's' : '') : '';
$relative_date .= $weeks > 0 ? ($relative_date ? ', -' : '-') . $weeks . ' week' . ($weeks > 1 ? 's' : '') : ''; $relativeDate .= $weeks > 0 ? ($relativeDate ? ', -' : '-') . $weeks . ' week' . ($weeks > 1 ? 's' : '') : '';
$relative_date .= $days > 0 ? ($relative_date ? ', -' : '-') . $days . ' day' . ($days > 1 ? 's' : '') : ''; $relativeDate .= $days > 0 ? ($relativeDate ? ', -' : '-') . $days . ' day' . ($days > 1 ? 's' : '') : '';
} elseif (abs($months) > 0) { } elseif (abs($months) > 0) {
// months, weeks and days // months, weeks and days
$relative_date .= ($relative_date ? ', -' : '-') . $months . ' month' . ($months > 1 ? 's' : ''); $relativeDate .= ($relativeDate ? ', -' : '-') . $months . ' month' . ($months > 1 ? 's' : '');
$relative_date .= $weeks > 0 ? ($relative_date ? ', -' : '-') . $weeks . ' week' . ($weeks > 1 ? 's' : '') : ''; $relativeDate .= $weeks > 0 ? ($relativeDate ? ', -' : '-') . $weeks . ' week' . ($weeks > 1 ? 's' : '') : '';
$relative_date .= $days > 0 ? ($relative_date ? ', -' : '-') . $days . ' day' . ($days > 1 ? 's' : '') : ''; $relativeDate .= $days > 0 ? ($relativeDate ? ', -' : '-') . $days . ' day' . ($days > 1 ? 's' : '') : '';
} elseif (abs($weeks) > 0) { } elseif (abs($weeks) > 0) {
// weeks and days // weeks and days
$relative_date .= ($relative_date ? ', -' : '-') . $weeks . ' week' . ($weeks > 1 ? 's' : ''); $relativeDate .= ($relativeDate ? ', -' : '-') . $weeks . ' week' . ($weeks > 1 ? 's' : '');
$relative_date .= $days > 0 ? ($relative_date ? ', -' : '-') . $days . ' day' . ($days > 1 ? 's' : '') : ''; $relativeDate .= $days > 0 ? ($relativeDate ? ', -' : '-') . $days . ' day' . ($days > 1 ? 's' : '') : '';
} elseif (abs($days) > 0) { } elseif (abs($days) > 0) {
// days and hours // days and hours
$relative_date .= ($relative_date ? ', -' : '-') . $days . ' day' . ($days > 1 ? 's' : ''); $relativeDate .= ($relativeDate ? ', -' : '-') . $days . ' day' . ($days > 1 ? 's' : '');
$relative_date .= $hours > 0 ? ($relative_date ? ', -' : '-') . $hours . ' hour' . ($hours > 1 ? 's' : '') : ''; $relativeDate .= $hours > 0 ? ($relativeDate ? ', -' : '-') . $hours . ' hour' . ($hours > 1 ? 's' : '') : '';
} elseif (abs($hours) > 0) { } elseif (abs($hours) > 0) {
// hours and minutes // hours and minutes
$relative_date .= ($relative_date ? ', -' : '-') . $hours . ' hour' . ($hours > 1 ? 's' : ''); $relativeDate .= ($relativeDate ? ', -' : '-') . $hours . ' hour' . ($hours > 1 ? 's' : '');
$relative_date .= $minutes > 0 ? ($relative_date ? ', -' : '-') . $minutes . ' minute' . ($minutes > 1 ? 's' : '') : ''; $relativeDate .= $minutes > 0 ? ($relativeDate ? ', -' : '-') . $minutes . ' minute' . ($minutes > 1 ? 's' : '') : '';
} elseif (abs($minutes) > 0) { } elseif (abs($minutes) > 0) {
// minutes only // minutes only
$relative_date .= ($relative_date ? ', -' : '-') . $minutes . ' minute' . ($minutes > 1 ? 's' : ''); $relativeDate .= ($relativeDate ? ', -' : '-') . $minutes . ' minute' . ($minutes > 1 ? 's' : '');
} else { } else {
// seconds only // seconds only
$relative_date .= ($relative_date ? ', -' : '-') . $seconds . ' second' . ($seconds != 1 ? 's' : ''); $relativeDate .= ($relativeDate ? ', -' : '-') . $seconds . ' second' . ($seconds != 1 ? 's' : '');
} }
if (date('j/n/y', strtotime(str_replace(',', '', $relative_date))) != '1/1/70') { if (date('j/n/y', strtotime(str_replace(',', '', $relativeDate))) != '1/1/70') {
$result = $this->Time->timeAgoInWords(strtotime(str_replace(',', '', $relative_date)), array('end' => '8 years'), true); $result = $this->Time->timeAgoInWords(strtotime(str_replace(',', '', $relativeDate)), array('end' => '8 years'), true);
if ($relative_date == '0 seconds') { if ($relativeDate == '0 seconds') {
$relative_date = '0 seconds ago'; $relativeDate = '0 seconds ago';
} }
$relative_date = str_replace('-', '', $relative_date) . ' ago'; $relativeDate = str_replace('-', '', $relativeDate) . ' ago';
$this->assertEquals($result, $relative_date); $this->assertEquals($result, $relativeDate);
} }
} }
@ -187,47 +187,47 @@ class CakeTimeTest extends CakeTestCase {
$minutes = 0; $minutes = 0;
$seconds = 0; $seconds = 0;
$relative_date = ''; $relativeDate = '';
if ($years > 0) { if ($years > 0) {
// years and months and days // years and months and days
$relative_date .= ($relative_date ? ', ' : '') . $years . ' year' . ($years > 1 ? 's' : ''); $relativeDate .= ($relativeDate ? ', ' : '') . $years . ' year' . ($years > 1 ? 's' : '');
$relative_date .= $months > 0 ? ($relative_date ? ', ' : '') . $months . ' month' . ($months > 1 ? 's' : '') : ''; $relativeDate .= $months > 0 ? ($relativeDate ? ', ' : '') . $months . ' month' . ($months > 1 ? 's' : '') : '';
$relative_date .= $weeks > 0 ? ($relative_date ? ', ' : '') . $weeks . ' week' . ($weeks > 1 ? 's' : '') : ''; $relativeDate .= $weeks > 0 ? ($relativeDate ? ', ' : '') . $weeks . ' week' . ($weeks > 1 ? 's' : '') : '';
$relative_date .= $days > 0 ? ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '') : ''; $relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '') : '';
} elseif (abs($months) > 0) { } elseif (abs($months) > 0) {
// months, weeks and days // months, weeks and days
$relative_date .= ($relative_date ? ', ' : '') . $months . ' month' . ($months > 1 ? 's' : ''); $relativeDate .= ($relativeDate ? ', ' : '') . $months . ' month' . ($months > 1 ? 's' : '');
$relative_date .= $weeks > 0 ? ($relative_date ? ', ' : '') . $weeks . ' week' . ($weeks > 1 ? 's' : '') : ''; $relativeDate .= $weeks > 0 ? ($relativeDate ? ', ' : '') . $weeks . ' week' . ($weeks > 1 ? 's' : '') : '';
$relative_date .= $days > 0 ? ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '') : ''; $relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '') : '';
} elseif (abs($weeks) > 0) { } elseif (abs($weeks) > 0) {
// weeks and days // weeks and days
$relative_date .= ($relative_date ? ', ' : '') . $weeks . ' week' . ($weeks > 1 ? 's' : ''); $relativeDate .= ($relativeDate ? ', ' : '') . $weeks . ' week' . ($weeks > 1 ? 's' : '');
$relative_date .= $days > 0 ? ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '') : ''; $relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '') : '';
} elseif (abs($days) > 0) { } elseif (abs($days) > 0) {
// days and hours // days and hours
$relative_date .= ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : ''); $relativeDate .= ($relativeDate ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '');
$relative_date .= $hours > 0 ? ($relative_date ? ', ' : '') . $hours . ' hour' . ($hours > 1 ? 's' : '') : ''; $relativeDate .= $hours > 0 ? ($relativeDate ? ', ' : '') . $hours . ' hour' . ($hours > 1 ? 's' : '') : '';
} elseif (abs($hours) > 0) { } elseif (abs($hours) > 0) {
// hours and minutes // hours and minutes
$relative_date .= ($relative_date ? ', ' : '') . $hours . ' hour' . ($hours > 1 ? 's' : ''); $relativeDate .= ($relativeDate ? ', ' : '') . $hours . ' hour' . ($hours > 1 ? 's' : '');
$relative_date .= $minutes > 0 ? ($relative_date ? ', ' : '') . $minutes . ' minute' . ($minutes > 1 ? 's' : '') : ''; $relativeDate .= $minutes > 0 ? ($relativeDate ? ', ' : '') . $minutes . ' minute' . ($minutes > 1 ? 's' : '') : '';
} elseif (abs($minutes) > 0) { } elseif (abs($minutes) > 0) {
// minutes only // minutes only
$relative_date .= ($relative_date ? ', ' : '') . $minutes . ' minute' . ($minutes > 1 ? 's' : ''); $relativeDate .= ($relativeDate ? ', ' : '') . $minutes . ' minute' . ($minutes > 1 ? 's' : '');
} else { } else {
// seconds only // seconds only
$relative_date .= ($relative_date ? ', ' : '') . $seconds . ' second' . ($seconds != 1 ? 's' : ''); $relativeDate .= ($relativeDate ? ', ' : '') . $seconds . ' second' . ($seconds != 1 ? 's' : '');
} }
if (date('j/n/y', strtotime(str_replace(',', '', $relative_date))) != '1/1/70') { if (date('j/n/y', strtotime(str_replace(',', '', $relativeDate))) != '1/1/70') {
$result = $this->Time->timeAgoInWords(strtotime(str_replace(',', '', $relative_date)), array('end' => '8 years'), true); $result = $this->Time->timeAgoInWords(strtotime(str_replace(',', '', $relativeDate)), array('end' => '8 years'), true);
if ($relative_date == '0 seconds') { if ($relativeDate == '0 seconds') {
$relative_date = '0 seconds ago'; $relativeDate = '0 seconds ago';
} }
$relative_date = str_replace('-', '', $relative_date) . ''; $relativeDate = str_replace('-', '', $relativeDate) . '';
$this->assertEquals($result, $relative_date); $this->assertEquals($result, $relativeDate);
} }
} }
@ -364,7 +364,7 @@ class CakeTimeTest extends CakeTestCase {
$begin = time(); $begin = time();
$end = time() + DAY; $end = time() + DAY;
$field = 'my_field'; $field = 'my_field';
$expected = '(my_field >= \''.date('Y-m-d', $begin).' 00:00:00\') AND (my_field <= \''.date('Y-m-d', $end).' 23:59:59\')'; $expected = '(my_field >= \'' . date('Y-m-d', $begin) . ' 00:00:00\') AND (my_field <= \'' . date('Y-m-d', $end) . ' 23:59:59\')';
$this->assertEquals($expected, $this->Time->daysAsSql($begin, $end, $field)); $this->assertEquals($expected, $this->Time->daysAsSql($begin, $end, $field));
} }
@ -376,7 +376,7 @@ class CakeTimeTest extends CakeTestCase {
public function testDayAsSql() { public function testDayAsSql() {
$time = time(); $time = time();
$field = 'my_field'; $field = 'my_field';
$expected = '(my_field >= \''.date('Y-m-d', $time).' 00:00:00\') AND (my_field <= \''.date('Y-m-d', $time).' 23:59:59\')'; $expected = '(my_field >= \'' . date('Y-m-d', $time) . ' 00:00:00\') AND (my_field <= \'' . date('Y-m-d', $time) . ' 23:59:59\')';
$this->assertEquals($expected, $this->Time->dayAsSql($time, $field)); $this->assertEquals($expected, $this->Time->dayAsSql($time, $field));
} }
@ -515,7 +515,6 @@ class CakeTimeTest extends CakeTestCase {
$this->assertFalse($result); $this->assertFalse($result);
$result = $this->Time->isThisMonth(mktime(0, 0, 0, date('m'), mt_rand(1, 28), date('Y') + mt_rand(1, 12))); $result = $this->Time->isThisMonth(mktime(0, 0, 0, date('m'), mt_rand(1, 28), date('Y') + mt_rand(1, 12)));
$this->assertFalse($result); $this->assertFalse($result);
} }
/** /**

View file

@ -122,7 +122,7 @@ class RegisterCategory extends ClassRegisterModel {
*/ */
public $name = 'RegisterCategory'; public $name = 'RegisterCategory';
} }
/** /**
* RegisterPrefixedDs class * RegisterPrefixedDs class
* *
* @package Cake.Test.Case.Utility * @package Cake.Test.Case.Utility
@ -142,7 +142,8 @@ class RegisterPrefixedDs extends ClassRegisterModel {
*/ */
abstract class ClassRegistryAbstractModel extends ClassRegisterModel { abstract class ClassRegistryAbstractModel extends ClassRegisterModel {
abstract function doSomething(); public abstract function doSomething();
} }
/** /**
@ -151,6 +152,7 @@ abstract class ClassRegistryAbstractModel extends ClassRegisterModel {
interface ClassRegistryInterfaceTest { interface ClassRegistryInterfaceTest {
public function doSomething(); public function doSomething();
} }
/** /**
@ -166,7 +168,6 @@ class ClassRegistryTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testAddModel() { public function testAddModel() {
$Tag = ClassRegistry::init('RegisterArticleTag'); $Tag = ClassRegistry::init('RegisterArticleTag');
$this->assertTrue(is_a($Tag, 'RegisterArticleTag')); $this->assertTrue(is_a($Tag, 'RegisterArticleTag'));
@ -183,7 +184,6 @@ class ClassRegistryTest extends CakeTestCase {
$NewTag = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag')); $NewTag = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag'));
$this->assertTrue(is_a($Tag, 'RegisterArticleTag')); $this->assertTrue(is_a($Tag, 'RegisterArticleTag'));
$NewTagCopy = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag')); $NewTagCopy = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag'));
$this->assertNotSame($Tag, $NewTag); $this->assertNotSame($Tag, $NewTag);
@ -336,7 +336,7 @@ class ClassRegistryTest extends CakeTestCase {
public function testInitAbstractClass() { public function testInitAbstractClass() {
ClassRegistry::init('ClassRegistryAbstractModel'); ClassRegistry::init('ClassRegistryAbstractModel');
} }
/** /**
* Test that you cannot init() an abstract class. A exception will be raised. * Test that you cannot init() an abstract class. A exception will be raised.
* *

View file

@ -29,13 +29,13 @@ class DebuggerTestCaseDebugger extends Debugger {
/** /**
* DebuggerTest class * DebuggerTest class
* *
* !!! Be careful with changing code below as it may
* !!! change line numbers which are used in the tests
*
* @package Cake.Test.Case.Utility * @package Cake.Test.Case.Utility
*/ */
class DebuggerTest extends CakeTestCase { class DebuggerTest extends CakeTestCase {
// !!!
// !!! Be careful with changing code below as it may
// !!! change line numbers which are used in the tests
// !!!
protected $_restoreError = false; protected $_restoreError = false;
/** /**

View file

@ -76,7 +76,7 @@ class FileTest extends CakeTestCase {
'dirname' => dirname(__FILE__), 'dirname' => dirname(__FILE__),
'basename' => basename(__FILE__), 'basename' => basename(__FILE__),
'extension' => 'php', 'extension' => 'php',
'filename' =>'FileTest', 'filename' => 'FileTest',
'filesize' => filesize($file), 'filesize' => filesize($file),
'mime' => 'text/x-php' 'mime' => 'text/x-php'
); );
@ -179,7 +179,7 @@ class FileTest extends CakeTestCase {
$this->assertEquals($expecting, $result); $this->assertEquals($expecting, $result);
$result = $this->File->offset(); $result = $this->File->offset();
$expecting = 5+3; $expecting = 5 + 3;
$this->assertSame($result, $expecting); $this->assertSame($result, $expecting);
} }
@ -230,7 +230,7 @@ class FileTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testCreate() { public function testCreate() {
$tmpFile = TMP.'tests' . DS . 'cakephp.file.test.tmp'; $tmpFile = TMP . 'tests' . DS . 'cakephp.file.test.tmp';
$File = new File($tmpFile, true, 0777); $File = new File($tmpFile, true, 0777);
$this->assertTrue($File->exists()); $this->assertTrue($File->exists());
} }

View file

@ -115,7 +115,7 @@ class FolderTest extends CakeTestCase {
$this->assertTrue($result); $this->assertTrue($result);
$result = $Folder->realpath('Test/'); $result = $Folder->realpath('Test/');
$this->assertEquals($result, $path . DS .'Test' . DS); $this->assertEquals($result, $path . DS . 'Test' . DS);
$result = $Folder->inPath('Test' . DS); $result = $Folder->inPath('Test' . DS);
$this->assertTrue($result); $this->assertTrue($result);
@ -285,7 +285,7 @@ class FolderTest extends CakeTestCase {
$this->assertTrue($Folder->chmod($new, 0755, true)); $this->assertTrue($Folder->chmod($new, 0755, true));
$perms = substr(sprintf('%o', fileperms($new . DS . 'test2')), -4); $perms = substr(sprintf('%o', fileperms($new . DS . 'test2')), -4);
$this->assertEquals($perms, '0755'); $this->assertEquals($perms, '0755');
$this->assertTrue($Folder->chmod($new, 0744, true, array('skip_me.php', 'test2'))); $this->assertTrue($Folder->chmod($new, 0744, true, array('skip_me.php', 'test2')));
$perms = substr(sprintf('%o', fileperms($new . DS . 'test2')), -4); $perms = substr(sprintf('%o', fileperms($new . DS . 'test2')), -4);
@ -406,27 +406,27 @@ class FolderTest extends CakeTestCase {
array( array(
CAKE . 'Config', CAKE . 'Config',
CAKE . 'Config' . DS . 'unicode', CAKE . 'Config' . DS . 'unicode',
CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding'
), ),
array( array(
CAKE . 'Config' . DS . 'config.php', CAKE . 'Config' . DS . 'config.php',
CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0080_00ff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0080_00ff.php',
CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0100_017f.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0100_017f.php',
CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0180_024F.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0180_024F.php',
CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0250_02af.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0250_02af.php',
CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0370_03ff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0370_03ff.php',
CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0400_04ff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0400_04ff.php',
CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0500_052f.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0500_052f.php',
CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0530_058f.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0530_058f.php',
CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '1e00_1eff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '1e00_1eff.php',
CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '1f00_1fff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '1f00_1fff.php',
CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2100_214f.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2100_214f.php',
CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2150_218f.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2150_218f.php',
CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2460_24ff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2460_24ff.php',
CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c00_2c5f.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c00_2c5f.php',
CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c60_2c7f.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c60_2c7f.php',
CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c80_2cff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c80_2cff.php',
CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . 'ff00_ffef.php' CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . 'ff00_ffef.php'
) )
); );
@ -809,46 +809,46 @@ class FolderTest extends CakeTestCase {
*/ */
public function testCopy() { public function testCopy() {
$path = TMP . 'folder_test'; $path = TMP . 'folder_test';
$folder1 = $path . DS . 'folder1'; $folderOne = $path . DS . 'folder1';
$folder2 = $folder1 . DS . 'folder2'; $folderTwo = $folderOne . DS . 'folder2';
$folder3 = $path . DS . 'folder3'; $folderThree = $path . DS . 'folder3';
$file1 = $folder1 . DS . 'file1.php'; $fileOne = $folderOne . DS . 'file1.php';
$file2 = $folder2 . DS . 'file2.php'; $fileTwo = $folderTwo . DS . 'file2.php';
new Folder($path, true); new Folder($path, true);
new Folder($folder1, true); new Folder($folderOne, true);
new Folder($folder2, true); new Folder($folderTwo, true);
new Folder($folder3, true); new Folder($folderThree, true);
touch($file1); touch($fileOne);
touch($file2); touch($fileTwo);
$Folder = new Folder($folder1); $Folder = new Folder($folderOne);
$result = $Folder->copy($folder3); $result = $Folder->copy($folderThree);
$this->assertTrue($result); $this->assertTrue($result);
$this->assertTrue(file_exists($folder3 . DS . 'file1.php')); $this->assertTrue(file_exists($folderThree . DS . 'file1.php'));
$this->assertTrue(file_exists($folder3 . DS . 'folder2' . DS . 'file2.php')); $this->assertTrue(file_exists($folderThree . DS . 'folder2' . DS . 'file2.php'));
$Folder = new Folder($folder3); $Folder = new Folder($folderThree);
$Folder->delete(); $Folder->delete();
$Folder = new Folder($folder1); $Folder = new Folder($folderOne);
$result = $Folder->copy($folder3); $result = $Folder->copy($folderThree);
$this->assertTrue($result); $this->assertTrue($result);
$this->assertTrue(file_exists($folder3 . DS . 'file1.php')); $this->assertTrue(file_exists($folderThree . DS . 'file1.php'));
$this->assertTrue(file_exists($folder3 . DS . 'folder2' . DS . 'file2.php')); $this->assertTrue(file_exists($folderThree . DS . 'folder2' . DS . 'file2.php'));
$Folder = new Folder($folder3); $Folder = new Folder($folderThree);
$Folder->delete(); $Folder->delete();
new Folder($folder3, true); new Folder($folderThree, true);
new Folder($folder3 . DS . 'folder2', true); new Folder($folderThree . DS . 'folder2', true);
file_put_contents($folder3 . DS . 'folder2' . DS . 'file2.php', 'untouched'); file_put_contents($folderThree . DS . 'folder2' . DS . 'file2.php', 'untouched');
$Folder = new Folder($folder1); $Folder = new Folder($folderOne);
$result = $Folder->copy($folder3); $result = $Folder->copy($folderThree);
$this->assertTrue($result); $this->assertTrue($result);
$this->assertTrue(file_exists($folder3 . DS . 'file1.php')); $this->assertTrue(file_exists($folderThree . DS . 'file1.php'));
$this->assertEquals(file_get_contents($folder3 . DS . 'folder2' . DS . 'file2.php'), 'untouched'); $this->assertEquals(file_get_contents($folderThree . DS . 'folder2' . DS . 'file2.php'), 'untouched');
$Folder = new Folder($path); $Folder = new Folder($path);
$Folder->delete(); $Folder->delete();
@ -866,68 +866,69 @@ class FolderTest extends CakeTestCase {
*/ */
public function testMove() { public function testMove() {
$path = TMP . 'folder_test'; $path = TMP . 'folder_test';
$folder1 = $path . DS . 'folder1'; $folderOne = $path . DS . 'folder1';
$folder2 = $folder1 . DS . 'folder2'; $folderTwo = $folderOne . DS . 'folder2';
$folder3 = $path . DS . 'folder3'; $folderThree = $path . DS . 'folder3';
$file1 = $folder1 . DS . 'file1.php'; $fileOne = $folderOne . DS . 'file1.php';
$file2 = $folder2 . DS . 'file2.php'; $fileTwo = $folderTwo . DS . 'file2.php';
new Folder($path, true); new Folder($path, true);
new Folder($folder1, true); new Folder($folderOne, true);
new Folder($folder2, true); new Folder($folderTwo, true);
new Folder($folder3, true); new Folder($folderThree, true);
touch($file1); touch($fileOne);
touch($file2); touch($fileTwo);
$Folder = new Folder($folder1); $Folder = new Folder($folderOne);
$result = $Folder->move($folder3); $result = $Folder->move($folderThree);
$this->assertTrue($result); $this->assertTrue($result);
$this->assertTrue(file_exists($folder3 . DS . 'file1.php')); $this->assertTrue(file_exists($folderThree . DS . 'file1.php'));
$this->assertTrue(is_dir($folder3 . DS . 'folder2')); $this->assertTrue(is_dir($folderThree . DS . 'folder2'));
$this->assertTrue(file_exists($folder3 . DS . 'folder2' . DS . 'file2.php')); $this->assertTrue(file_exists($folderThree . DS . 'folder2' . DS . 'file2.php'));
$this->assertFalse(file_exists($file1)); $this->assertFalse(file_exists($fileOne));
$this->assertFalse(file_exists($folder2)); $this->assertFalse(file_exists($folderTwo));
$this->assertFalse(file_exists($file2)); $this->assertFalse(file_exists($fileTwo));
$Folder = new Folder($folder3); $Folder = new Folder($folderThree);
$Folder->delete(); $Folder->delete();
new Folder($folder1, true); new Folder($folderOne, true);
new Folder($folder2, true); new Folder($folderTwo, true);
touch($file1); touch($fileOne);
touch($file2); touch($fileTwo);
$Folder = new Folder($folder1); $Folder = new Folder($folderOne);
$result = $Folder->move($folder3); $result = $Folder->move($folderThree);
$this->assertTrue($result); $this->assertTrue($result);
$this->assertTrue(file_exists($folder3 . DS . 'file1.php')); $this->assertTrue(file_exists($folderThree . DS . 'file1.php'));
$this->assertTrue(is_dir($folder3 . DS . 'folder2')); $this->assertTrue(is_dir($folderThree . DS . 'folder2'));
$this->assertTrue(file_exists($folder3 . DS . 'folder2' . DS . 'file2.php')); $this->assertTrue(file_exists($folderThree . DS . 'folder2' . DS . 'file2.php'));
$this->assertFalse(file_exists($file1)); $this->assertFalse(file_exists($fileOne));
$this->assertFalse(file_exists($folder2)); $this->assertFalse(file_exists($folderTwo));
$this->assertFalse(file_exists($file2)); $this->assertFalse(file_exists($fileTwo));
$Folder = new Folder($folder3); $Folder = new Folder($folderThree);
$Folder->delete(); $Folder->delete();
new Folder($folder1, true); new Folder($folderOne, true);
new Folder($folder2, true); new Folder($folderTwo, true);
new Folder($folder3, true); new Folder($folderThree, true);
new Folder($folder3 . DS . 'folder2', true); new Folder($folderThree . DS . 'folder2', true);
touch($file1); touch($fileOne);
touch($file2); touch($fileTwo);
file_put_contents($folder3 . DS . 'folder2' . DS . 'file2.php', 'untouched'); file_put_contents($folderThree . DS . 'folder2' . DS . 'file2.php', 'untouched');
$Folder = new Folder($folder1); $Folder = new Folder($folderOne);
$result = $Folder->move($folder3); $result = $Folder->move($folderThree);
$this->assertTrue($result); $this->assertTrue($result);
$this->assertTrue(file_exists($folder3 . DS . 'file1.php')); $this->assertTrue(file_exists($folderThree . DS . 'file1.php'));
$this->assertEquals(file_get_contents($folder3 . DS . 'folder2' . DS . 'file2.php'), 'untouched'); $this->assertEquals(file_get_contents($folderThree . DS . 'folder2' . DS . 'file2.php'), 'untouched');
$this->assertFalse(file_exists($file1)); $this->assertFalse(file_exists($fileOne));
$this->assertFalse(file_exists($folder2)); $this->assertFalse(file_exists($folderTwo));
$this->assertFalse(file_exists($file2)); $this->assertFalse(file_exists($fileTwo));
$Folder = new Folder($path); $Folder = new Folder($path);
$Folder->delete(); $Folder->delete();
} }
} }

View file

@ -24,6 +24,7 @@ App::uses('CakeEvent', 'Event');
* A generic object class * A generic object class
*/ */
class GenericObject { class GenericObject {
/** /**
* Constructor * Constructor
* *
@ -34,33 +35,40 @@ class GenericObject {
$this->_Collection = $collection; $this->_Collection = $collection;
$this->settings = $settings; $this->settings = $settings;
} }
} }
/** /**
* First Extension of Generic Object * First Extension of Generic Object
*/ */
class FirstGenericObject extends GenericObject { class FirstGenericObject extends GenericObject {
/** /**
* A generic callback * A generic callback
*/ */
public function callback() { public function callback() {
} }
} }
/** /**
* Second Extension of Generic Object * Second Extension of Generic Object
*/ */
class SecondGenericObject extends GenericObject { class SecondGenericObject extends GenericObject {
public function callback() { public function callback() {
} }
} }
/** /**
* Third Extension of Generic Object * Third Extension of Generic Object
*/ */
class ThirdGenericObject extends GenericObject { class ThirdGenericObject extends GenericObject {
public function callback() { public function callback() {
} }
} }
/** /**
@ -88,9 +96,11 @@ class GenericObjectCollection extends ObjectCollection {
} }
return $this->_loaded[$name]; return $this->_loaded[$name];
} }
} }
class ObjectCollectionTest extends CakeTestCase { class ObjectCollectionTest extends CakeTestCase {
/** /**
* setUp * setUp
* *
@ -525,7 +535,7 @@ class ObjectCollectionTest extends CakeTestCase {
$result = ObjectCollection::normalizeObjectArray($components); $result = ObjectCollection::normalizeObjectArray($components);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
/** /**
* tests that passing an instance of CakeEvent to trigger will prepend the subject to the list of arguments * tests that passing an instance of CakeEvent to trigger will prepend the subject to the list of arguments
* *
@ -581,4 +591,5 @@ class ObjectCollectionTest extends CakeTestCase {
$event->omitSubject = true; $event->omitSubject = true;
$this->assertTrue($this->Objects->trigger($event)); $this->assertTrue($this->Objects->trigger($event));
} }
}
}

View file

@ -331,8 +331,13 @@ class SanitizeTest extends CakeTestCase {
$result = Sanitize::stripScripts($string); $result = Sanitize::stripScripts($string);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$string = '<link href="/css/styles.css" media="screen" rel="stylesheet" />' . "\n" . '<link rel="icon" href="/favicon.ico" type="image/x-icon" />' . "\n" . '<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />' . "\n" . '<link rel="alternate" href="/feed.xml" title="RSS Feed" type="application/rss+xml" />'; $string = '<link href="/css/styles.css" media="screen" rel="stylesheet" />' . "\n" .
$expected = "\n" . '<link rel="icon" href="/favicon.ico" type="image/x-icon" />' . "\n" . '<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />'."\n".'<link rel="alternate" href="/feed.xml" title="RSS Feed" type="application/rss+xml" />'; '<link rel="icon" href="/favicon.ico" type="image/x-icon" />' . "\n" .
'<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />' . "\n" .
'<link rel="alternate" href="/feed.xml" title="RSS Feed" type="application/rss+xml" />';
$expected = "\n" . '<link rel="icon" href="/favicon.ico" type="image/x-icon" />' . "\n" .
'<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />' . "\n" .
'<link rel="alternate" href="/feed.xml" title="RSS Feed" type="application/rss+xml" />';
$result = Sanitize::stripScripts($string); $result = Sanitize::stripScripts($string);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
@ -390,7 +395,7 @@ HTML;
*/ */
public function testStripAll() { public function testStripAll() {
$string = '<img """><script>alert("xss")</script>"/>'; $string = '<img """><script>alert("xss")</script>"/>';
$expected ='"/>'; $expected = '"/>';
$result = Sanitize::stripAll($string); $result = Sanitize::stripAll($string);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
@ -404,14 +409,13 @@ HTML;
$result = Sanitize::stripAll($string); $result = Sanitize::stripAll($string);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$string = '<img src="http://google.com/images/logo.gif" onload="window.location=\'http://sam.com/\'" />'."\n". $string = '<img src="http://google.com/images/logo.gif" onload="window.location=\'http://sam.com/\'" />' . "\n" .
"<p>This is ok \t\n text</p>\n". "<p>This is ok \t\n text</p>\n" .
'<link rel="stylesheet" href="/css/master.css" type="text/css" media="screen" title="my sheet" charset="utf-8">'."\n". '<link rel="stylesheet" href="/css/master.css" type="text/css" media="screen" title="my sheet" charset="utf-8">' . "\n" .
'<script src="xss.js" type="text/javascript" charset="utf-8"></script>'; '<script src="xss.js" type="text/javascript" charset="utf-8"></script>';
$expected = '<p>This is ok text</p>'; $expected = '<p>This is ok text</p>';
$result = Sanitize::stripAll($string); $result = Sanitize::stripAll($string);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
/** /**

View file

@ -43,7 +43,7 @@ class StringTest extends CakeTestCase {
public function testUuidGeneration() { public function testUuidGeneration() {
$result = String::uuid(); $result = String::uuid();
$pattern = "/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/"; $pattern = "/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/";
$match = (bool) preg_match($pattern, $result); $match = (bool)preg_match($pattern, $result);
$this->assertTrue($match); $this->assertTrue($match);
} }
@ -59,7 +59,7 @@ class StringTest extends CakeTestCase {
for ($i = 0; $i < $count; $i++) { for ($i = 0; $i < $count; $i++) {
$result = String::uuid(); $result = String::uuid();
$match = (bool) preg_match($pattern, $result); $match = (bool)preg_match($pattern, $result);
$this->assertTrue($match); $this->assertTrue($match);
$this->assertFalse(in_array($result, $check)); $this->assertFalse(in_array($result, $check));
$check[] = $result; $check[] = $result;
@ -393,7 +393,7 @@ TEXT;
$this->assertSame($this->Text->truncate($text6, 57, array('exact' => false, 'html' => true)), "<p><strong>Extra dates have been announced for this year's...</strong></p>"); $this->assertSame($this->Text->truncate($text6, 57, array('exact' => false, 'html' => true)), "<p><strong>Extra dates have been announced for this year's...</strong></p>");
$this->assertSame($this->Text->truncate($text7, 255), $text7); $this->assertSame($this->Text->truncate($text7, 255), $text7);
$this->assertSame($this->Text->truncate($text7, 15), 'El moño está...'); $this->assertSame($this->Text->truncate($text7, 15), 'El moño está...');
$this->assertSame($this->Text->truncate($text8, 15), 'Vive la R'.chr(195).chr(169).'pu...'); $this->assertSame($this->Text->truncate($text8, 15), 'Vive la R' . chr(195) . chr(169) . 'pu...');
$this->assertSame($this->Text->truncate($text9, 10), 'НОПРСТУ...'); $this->assertSame($this->Text->truncate($text9, 10), 'НОПРСТУ...');
$this->assertSame($this->Text->truncate($text10, 30), 'http://example.com/somethin...'); $this->assertSame($this->Text->truncate($text10, 30), 'http://example.com/somethin...');
@ -509,7 +509,6 @@ podeís adquirirla.</span></p>
$result = $this->Text->highlight($text, $phrases, array('format' => array('<b>\1</b>', '<em>\1</em>'))); $result = $this->Text->highlight($text, $phrases, array('format' => array('<b>\1</b>', '<em>\1</em>')));
$expected = '<b>This</b> is a test <em>text</em>'; $expected = '<b>This</b> is a test <em>text</em>';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
/** /**

View file

@ -31,9 +31,10 @@ class CustomValidator {
* @param string $email * @param string $email
* @return boolean * @return boolean
*/ */
static function customValidate($check) { public static function customValidate($check) {
return (bool)preg_match('/^[0-9]{3}$/', $check); return (bool)preg_match('/^[0-9]{3}$/', $check);
} }
} }
/** /**
@ -44,13 +45,14 @@ class CustomValidator {
* @package Cake.Test.Case.Utility * @package Cake.Test.Case.Utility
*/ */
class TestNlValidation { class TestNlValidation {
/** /**
* postal function, for testing postal pass through. * postal function, for testing postal pass through.
* *
* @param string $check * @param string $check
* @return void * @return void
*/ */
static function postal($check) { public static function postal($check) {
return true; return true;
} }
@ -59,9 +61,10 @@ class TestNlValidation {
* *
* @return void * @return void
*/ */
static function ssn($check) { public static function ssn($check) {
return true; return true;
} }
} }
/** /**
@ -72,15 +75,17 @@ class TestNlValidation {
* @package Cake.Test.Case.Utility * @package Cake.Test.Case.Utility
*/ */
class TestDeValidation { class TestDeValidation {
/** /**
* phone function, for testing phone pass through. * phone function, for testing phone pass through.
* *
* @param string $check * @param string $check
* @return void * @return void
*/ */
static function phone($check) { public static function phone($check) {
return true; return true;
} }
} }
/** /**
@ -118,7 +123,7 @@ class ValidationTest extends CakeTestCase {
public function testNotEmpty() { public function testNotEmpty() {
$this->assertTrue(Validation::notEmpty('abcdefg')); $this->assertTrue(Validation::notEmpty('abcdefg'));
$this->assertTrue(Validation::notEmpty('fasdf ')); $this->assertTrue(Validation::notEmpty('fasdf '));
$this->assertTrue(Validation::notEmpty('fooo'.chr(243).'blabla')); $this->assertTrue(Validation::notEmpty('fooo' . chr(243) . 'blabla'));
$this->assertTrue(Validation::notEmpty('abçďĕʑʘπй')); $this->assertTrue(Validation::notEmpty('abçďĕʑʘπй'));
$this->assertTrue(Validation::notEmpty('José')); $this->assertTrue(Validation::notEmpty('José'));
$this->assertTrue(Validation::notEmpty('é')); $this->assertTrue(Validation::notEmpty('é'));
@ -136,7 +141,7 @@ class ValidationTest extends CakeTestCase {
Configure::write('App.encoding', 'ISO-8859-1'); Configure::write('App.encoding', 'ISO-8859-1');
$this->assertTrue(Validation::notEmpty('abcdefg')); $this->assertTrue(Validation::notEmpty('abcdefg'));
$this->assertTrue(Validation::notEmpty('fasdf ')); $this->assertTrue(Validation::notEmpty('fasdf '));
$this->assertTrue(Validation::notEmpty('fooo'.chr(243).'blabla')); $this->assertTrue(Validation::notEmpty('fooo' . chr(243) . 'blabla'));
$this->assertTrue(Validation::notEmpty('abçďĕʑʘπй')); $this->assertTrue(Validation::notEmpty('abçďĕʑʘπй'));
$this->assertTrue(Validation::notEmpty('José')); $this->assertTrue(Validation::notEmpty('José'));
$this->assertTrue(Validation::notEmpty(utf8_decode('José'))); $this->assertTrue(Validation::notEmpty(utf8_decode('José')));
@ -184,8 +189,8 @@ class ValidationTest extends CakeTestCase {
$this->assertFalse(Validation::alphaNumeric(array('check' => "\n"))); $this->assertFalse(Validation::alphaNumeric(array('check' => "\n")));
$this->assertFalse(Validation::alphaNumeric(array('check' => "\t"))); $this->assertFalse(Validation::alphaNumeric(array('check' => "\t")));
$this->assertFalse(Validation::alphaNumeric(array('check' => "\r"))); $this->assertFalse(Validation::alphaNumeric(array('check' => "\r")));
$this->assertFalse(Validation::alphaNumeric(array('check' => ' '))); $this->assertFalse(Validation::alphaNumeric(array('check' => ' ')));
$this->assertFalse(Validation::alphaNumeric(array('check' => ''))); $this->assertFalse(Validation::alphaNumeric(array('check' => '')));
} }
/** /**
@ -930,7 +935,7 @@ class ValidationTest extends CakeTestCase {
$this->assertTrue(Validation::comparison(array('check1' => 6, 'operator' => '<', 'check2' => 7))); $this->assertTrue(Validation::comparison(array('check1' => 6, 'operator' => '<', 'check2' => 7)));
$this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => 'greater or equal', 'check2' => 7))); $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => 'greater or equal', 'check2' => 7)));
$this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => '>=', 'check2' => 7))); $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => '>=', 'check2' => 7)));
$this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => 'greater or equal','check2' => 6))); $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => 'greater or equal','check2' => 6)));
$this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => '>=', 'check2' => 6))); $this->assertTrue(Validation::comparison(array('check1' => 7, 'operator' => '>=', 'check2' => 6)));
$this->assertTrue(Validation::comparison(array('check1' => 6, 'operator' => 'less or equal', 'check2' => 7))); $this->assertTrue(Validation::comparison(array('check1' => 6, 'operator' => 'less or equal', 'check2' => 7)));
$this->assertTrue(Validation::comparison(array('check1' => 6, 'operator' => '<=', 'check2' => 7))); $this->assertTrue(Validation::comparison(array('check1' => 6, 'operator' => '<=', 'check2' => 7)));
@ -949,7 +954,7 @@ class ValidationTest extends CakeTestCase {
$this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => 'less or equal', 'check2' => 6))); $this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => 'less or equal', 'check2' => 6)));
$this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => '<=', 'check2' => 6))); $this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => '<=', 'check2' => 6)));
$this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => 'equal to', 'check2' => 6))); $this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => 'equal to', 'check2' => 6)));
$this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => '==','check2' => 6))); $this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => '==','check2' => 6)));
$this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => 'not equal', 'check2' => 7))); $this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => 'not equal', 'check2' => 7)));
$this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => '!=', 'check2' => 7))); $this->assertFalse(Validation::comparison(array('check1' => 7, 'operator' => '!=', 'check2' => 7)));
} }
@ -1498,21 +1503,21 @@ class ValidationTest extends CakeTestCase {
*/ */
public function testDecimalWithPlaces() { public function testDecimalWithPlaces() {
$this->assertTrue(Validation::decimal('.27', '2')); $this->assertTrue(Validation::decimal('.27', '2'));
$this->assertTrue(Validation::decimal(.27, 2)); $this->assertTrue(Validation::decimal(0.27, 2));
$this->assertTrue(Validation::decimal(-.27, 2)); $this->assertTrue(Validation::decimal(-0.27, 2));
$this->assertTrue(Validation::decimal(+.27, 2)); $this->assertTrue(Validation::decimal(0.27, 2));
$this->assertTrue(Validation::decimal('.277', '3')); $this->assertTrue(Validation::decimal('0.277', '3'));
$this->assertTrue(Validation::decimal(.277, 3)); $this->assertTrue(Validation::decimal(0.277, 3));
$this->assertTrue(Validation::decimal(-.277, 3)); $this->assertTrue(Validation::decimal(-0.277, 3));
$this->assertTrue(Validation::decimal(+.277, 3)); $this->assertTrue(Validation::decimal(0.277, 3));
$this->assertTrue(Validation::decimal('1234.5678', '4')); $this->assertTrue(Validation::decimal('1234.5678', '4'));
$this->assertTrue(Validation::decimal(1234.5678, 4)); $this->assertTrue(Validation::decimal(1234.5678, 4));
$this->assertTrue(Validation::decimal(-1234.5678, 4)); $this->assertTrue(Validation::decimal(-1234.5678, 4));
$this->assertTrue(Validation::decimal(+1234.5678, 4)); $this->assertTrue(Validation::decimal(1234.5678, 4));
$this->assertFalse(Validation::decimal('1234.5678', '3')); $this->assertFalse(Validation::decimal('1234.5678', '3'));
$this->assertFalse(Validation::decimal(1234.5678, 3)); $this->assertFalse(Validation::decimal(1234.5678, 3));
$this->assertFalse(Validation::decimal(-1234.5678, 3)); $this->assertFalse(Validation::decimal(-1234.5678, 3));
$this->assertFalse(Validation::decimal(+1234.5678, 3)); $this->assertFalse(Validation::decimal(1234.5678, 3));
} }
/** /**

View file

@ -865,7 +865,7 @@ class XmlTest extends CakeTestCase {
$expected .= '<published>Y</published><created>2007-03-18 10:43:23</created><updated>2007-03-18 10:45:31</updated></Article>'; $expected .= '<published>Y</published><created>2007-03-18 10:43:23</created><updated>2007-03-18 10:45:31</updated></Article>';
$expected .= '</data>'; $expected .= '</data>';
$this->assertEquals(str_replace(array("\r", "\n"), '', $obj->asXML()), $expected); $this->assertEquals(str_replace(array("\r", "\n"), '', $obj->asXML()), $expected);
//multiple model results - without a records key it would fatal error //multiple model results - without a records key it would fatal error
$data = $user->find('all', array('limit' => 2)); $data = $user->find('all', array('limit' => 2));
$data = array('records' => $data); $data = array('records' => $data);