correcting all the inverted assertEqual tests

$expected is the first argument. Now certain test results start to make
sense:

	1) MultibyteTest::testUsingMbStrtolower
	Failed asserting that two strings are equal.
	--- Expected
	+++ Actual
	@@ @@
	-ႠႡႢႣႤႥႦႧႨႩႪႫႬႭႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅ
	+ⴀⴁⴂⴃⴄⴅⴆⴇⴈⴉⴊⴋⴌⴍⴎⴏⴐⴑⴒⴓⴔⴕⴖⴗⴘⴙⴚⴛⴜⴝⴞⴟⴠⴡⴢⴣⴤⴥ
This commit is contained in:
AD7six 2011-05-17 00:49:00 +02:00
parent e24ef781e5
commit 0a53242e3e
59 changed files with 3691 additions and 3691 deletions

View file

@ -59,19 +59,19 @@ class BasicsTest extends CakeTestCase {
$two = array('one' => 'one', 'two' => 'two'); $two = array('one' => 'one', 'two' => 'two');
$result = array_diff_key($one, $two); $result = array_diff_key($one, $two);
$expected = array('three' => 3); $expected = array('three' => 3);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$one = array('one' => array('value', 'value-two'), 'two' => 2, 'three' => 3); $one = array('one' => array('value', 'value-two'), 'two' => 2, 'three' => 3);
$two = array('two' => 'two'); $two = array('two' => 'two');
$result = array_diff_key($one, $two); $result = array_diff_key($one, $two);
$expected = array('one' => array('value', 'value-two'), 'three' => 3); $expected = array('one' => array('value', 'value-two'), 'three' => 3);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$one = array('one' => null, 'two' => 2, 'three' => '', 'four' => 0); $one = array('one' => null, 'two' => 2, 'three' => '', 'four' => 0);
$two = array('two' => 'two'); $two = array('two' => 'two');
$result = array_diff_key($one, $two); $result = array_diff_key($one, $two);
$expected = array('one' => null, 'three' => '', 'four' => 0); $expected = array('one' => null, 'three' => '', 'four' => 0);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$one = array('minYear' => null, 'maxYear' => null, 'separator' => '-', 'interval' => 1, 'monthNames' => true); $one = array('minYear' => null, 'maxYear' => null, 'separator' => '-', 'interval' => 1, 'monthNames' => true);
$two = array('minYear' => null, 'maxYear' => null, 'separator' => '-', 'interval' => 1, 'monthNames' => true); $two = array('minYear' => null, 'maxYear' => null, 'separator' => '-', 'interval' => 1, 'monthNames' => true);
@ -244,11 +244,11 @@ class BasicsTest extends CakeTestCase {
public function testAm() { public function testAm() {
$result = am(array('one', 'two'), 2, 3, 4); $result = am(array('one', 'two'), 2, 3, 4);
$expected = array('one', 'two', 2, 3, 4); $expected = array('one', 'two', 2, 3, 4);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = am(array('one' => array(2, 3), 'two' => array('foo')), array('one' => array(4, 5))); $result = am(array('one' => array(2, 3), 'two' => array('foo')), array('one' => array(4, 5)));
$expected = array('one' => array(4, 5),'two' => array('foo')); $expected = array('one' => array(4, 5),'two' => array('foo'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -360,35 +360,35 @@ class BasicsTest extends CakeTestCase {
$result = __('Plural Rule 1'); $result = __('Plural Rule 1');
$expected = 'Plural Rule 1 (translated)'; $expected = 'Plural Rule 1 (translated)';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __('Plural Rule 1 (from core)'); $result = __('Plural Rule 1 (from core)');
$expected = 'Plural Rule 1 (from core translated)'; $expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __('Some string with %s', 'arguments'); $result = __('Some string with %s', 'arguments');
$expected = 'Some string with arguments'; $expected = 'Some string with arguments';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __('Some string with %s %s', 'multiple', 'arguments'); $result = __('Some string with %s %s', 'multiple', 'arguments');
$expected = 'Some string with multiple arguments'; $expected = 'Some string with multiple arguments';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __('Some string with %s %s', array('multiple', 'arguments')); $result = __('Some string with %s %s', array('multiple', 'arguments'));
$expected = 'Some string with multiple arguments'; $expected = 'Some string with multiple arguments';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __('Testing %2$s %1$s', 'order', 'different'); $result = __('Testing %2$s %1$s', 'order', 'different');
$expected = 'Testing different order'; $expected = 'Testing different order';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __('Testing %2$s %1$s', array('order', 'different')); $result = __('Testing %2$s %1$s', array('order', 'different'));
$expected = 'Testing different order'; $expected = 'Testing different order';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __('Testing %.2f number', 1.2345); $result = __('Testing %.2f number', 1.2345);
$expected = 'Testing 1.23 number'; $expected = 'Testing 1.23 number';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -401,27 +401,27 @@ class BasicsTest extends CakeTestCase {
$result = __n('%d = 1', '%d = 0 or > 1', 0); $result = __n('%d = 1', '%d = 0 or > 1', 0);
$expected = '%d = 0 or > 1 (translated)'; $expected = '%d = 0 or > 1 (translated)';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __n('%d = 1', '%d = 0 or > 1', 1); $result = __n('%d = 1', '%d = 0 or > 1', 1);
$expected = '%d = 1 (translated)'; $expected = '%d = 1 (translated)';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', 2); $result = __n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', 2);
$expected = '%d = 0 or > 1 (from core translated)'; $expected = '%d = 0 or > 1 (from core translated)';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __n('%d item.', '%d items.', 1, 1); $result = __n('%d item.', '%d items.', 1, 1);
$expected = '1 item.'; $expected = '1 item.';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __n('%d item for id %s', '%d items for id %s', 2, 2, '1234'); $result = __n('%d item for id %s', '%d items for id %s', 2, 2, '1234');
$expected = '2 items for id 1234'; $expected = '2 items for id 1234';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __n('%d item for id %s', '%d items for id %s', 2, array(2, '1234')); $result = __n('%d item for id %s', '%d items for id %s', 2, array(2, '1234'));
$expected = '2 items for id 1234'; $expected = '2 items for id 1234';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -434,27 +434,27 @@ class BasicsTest extends CakeTestCase {
$result = __d('default', 'Plural Rule 1'); $result = __d('default', 'Plural Rule 1');
$expected = 'Plural Rule 1 (translated)'; $expected = 'Plural Rule 1 (translated)';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __d('core', 'Plural Rule 1'); $result = __d('core', 'Plural Rule 1');
$expected = 'Plural Rule 1'; $expected = 'Plural Rule 1';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __d('core', 'Plural Rule 1 (from core)'); $result = __d('core', 'Plural Rule 1 (from core)');
$expected = 'Plural Rule 1 (from core translated)'; $expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __d('core', 'Some string with %s', 'arguments'); $result = __d('core', 'Some string with %s', 'arguments');
$expected = 'Some string with arguments'; $expected = 'Some string with arguments';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __d('core', 'Some string with %s %s', 'multiple', 'arguments'); $result = __d('core', 'Some string with %s %s', 'multiple', 'arguments');
$expected = 'Some string with multiple arguments'; $expected = 'Some string with multiple arguments';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __d('core', 'Some string with %s %s', array('multiple', 'arguments')); $result = __d('core', 'Some string with %s %s', array('multiple', 'arguments'));
$expected = 'Some string with multiple arguments'; $expected = 'Some string with multiple arguments';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -467,31 +467,31 @@ class BasicsTest extends CakeTestCase {
$result = __dn('default', '%d = 1', '%d = 0 or > 1', 0); $result = __dn('default', '%d = 1', '%d = 0 or > 1', 0);
$expected = '%d = 0 or > 1 (translated)'; $expected = '%d = 0 or > 1 (translated)';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __dn('core', '%d = 1', '%d = 0 or > 1', 0); $result = __dn('core', '%d = 1', '%d = 0 or > 1', 0);
$expected = '%d = 0 or > 1'; $expected = '%d = 0 or > 1';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __dn('core', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 0); $result = __dn('core', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 0);
$expected = '%d = 0 or > 1 (from core translated)'; $expected = '%d = 0 or > 1 (from core translated)';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __dn('default', '%d = 1', '%d = 0 or > 1', 1); $result = __dn('default', '%d = 1', '%d = 0 or > 1', 1);
$expected = '%d = 1 (translated)'; $expected = '%d = 1 (translated)';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __dn('core', '%d item.', '%d items.', 1, 1); $result = __dn('core', '%d item.', '%d items.', 1, 1);
$expected = '1 item.'; $expected = '1 item.';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __dn('core', '%d item for id %s', '%d items for id %s', 2, 2, '1234'); $result = __dn('core', '%d item for id %s', '%d items for id %s', 2, 2, '1234');
$expected = '2 items for id 1234'; $expected = '2 items for id 1234';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __dn('core', '%d item for id %s', '%d items for id %s', 2, array(2, '1234')); $result = __dn('core', '%d item for id %s', '%d items for id %s', 2, array(2, '1234'));
$expected = '2 items for id 1234'; $expected = '2 items for id 1234';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -504,23 +504,23 @@ class BasicsTest extends CakeTestCase {
$result = __c('Plural Rule 1', 6); $result = __c('Plural Rule 1', 6);
$expected = 'Plural Rule 1 (translated)'; $expected = 'Plural Rule 1 (translated)';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __c('Plural Rule 1 (from core)', 6); $result = __c('Plural Rule 1 (from core)', 6);
$expected = 'Plural Rule 1 (from core translated)'; $expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __c('Some string with %s', 6, 'arguments'); $result = __c('Some string with %s', 6, 'arguments');
$expected = 'Some string with arguments'; $expected = 'Some string with arguments';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __c('Some string with %s %s', 6, 'multiple', 'arguments'); $result = __c('Some string with %s %s', 6, 'multiple', 'arguments');
$expected = 'Some string with multiple arguments'; $expected = 'Some string with multiple arguments';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __c('Some string with %s %s', 6, array('multiple', 'arguments')); $result = __c('Some string with %s %s', 6, array('multiple', 'arguments'));
$expected = 'Some string with multiple arguments'; $expected = 'Some string with multiple arguments';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -533,31 +533,31 @@ class BasicsTest extends CakeTestCase {
$result = __dc('default', 'Plural Rule 1', 6); $result = __dc('default', 'Plural Rule 1', 6);
$expected = 'Plural Rule 1 (translated)'; $expected = 'Plural Rule 1 (translated)';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __dc('default', 'Plural Rule 1 (from core)', 6); $result = __dc('default', 'Plural Rule 1 (from core)', 6);
$expected = 'Plural Rule 1 (from core translated)'; $expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __dc('core', 'Plural Rule 1', 6); $result = __dc('core', 'Plural Rule 1', 6);
$expected = 'Plural Rule 1'; $expected = 'Plural Rule 1';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __dc('core', 'Plural Rule 1 (from core)', 6); $result = __dc('core', 'Plural Rule 1 (from core)', 6);
$expected = 'Plural Rule 1 (from core translated)'; $expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __dc('core', 'Some string with %s', 6, 'arguments'); $result = __dc('core', 'Some string with %s', 6, 'arguments');
$expected = 'Some string with arguments'; $expected = 'Some string with arguments';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __dc('core', 'Some string with %s %s', 6, 'multiple', 'arguments'); $result = __dc('core', 'Some string with %s %s', 6, 'multiple', 'arguments');
$expected = 'Some string with multiple arguments'; $expected = 'Some string with multiple arguments';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __dc('core', 'Some string with %s %s', 6, array('multiple', 'arguments')); $result = __dc('core', 'Some string with %s %s', 6, array('multiple', 'arguments'));
$expected = 'Some string with multiple arguments'; $expected = 'Some string with multiple arguments';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -570,27 +570,27 @@ class BasicsTest extends CakeTestCase {
$result = __dcn('default', '%d = 1', '%d = 0 or > 1', 0, 6); $result = __dcn('default', '%d = 1', '%d = 0 or > 1', 0, 6);
$expected = '%d = 0 or > 1 (translated)'; $expected = '%d = 0 or > 1 (translated)';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __dcn('default', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 1, 6); $result = __dcn('default', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 1, 6);
$expected = '%d = 1 (from core translated)'; $expected = '%d = 1 (from core translated)';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __dcn('core', '%d = 1', '%d = 0 or > 1', 0, 6); $result = __dcn('core', '%d = 1', '%d = 0 or > 1', 0, 6);
$expected = '%d = 0 or > 1'; $expected = '%d = 0 or > 1';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __dcn('core', '%d item.', '%d items.', 1, 6, 1); $result = __dcn('core', '%d item.', '%d items.', 1, 6, 1);
$expected = '1 item.'; $expected = '1 item.';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __dcn('core', '%d item for id %s', '%d items for id %s', 2, 6, 2, '1234'); $result = __dcn('core', '%d item for id %s', '%d items for id %s', 2, 6, 2, '1234');
$expected = '2 items for id 1234'; $expected = '2 items for id 1234';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __dcn('core', '%d item for id %s', '%d items for id %s', 2, 6, array(2, '1234')); $result = __dcn('core', '%d item for id %s', '%d items for id %s', 2, 6, array(2, '1234'));
$expected = '2 items for id 1234'; $expected = '2 items for id 1234';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -662,11 +662,11 @@ class BasicsTest extends CakeTestCase {
public function testConvertSlash() { public function testConvertSlash() {
$result = convertSlash('\path\to\location\\'); $result = convertSlash('\path\to\location\\');
$expected = '\path\to\location\\'; $expected = '\path\to\location\\';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = convertSlash('/path/to/location/'); $result = convertSlash('/path/to/location/');
$expected = 'path_to_location'; $expected = 'path_to_location';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -710,13 +710,13 @@ class BasicsTest extends CakeTestCase {
pr('this is a test'); pr('this is a test');
$result = ob_get_clean(); $result = ob_get_clean();
$expected = "<pre>this is a test</pre>"; $expected = "<pre>this is a test</pre>";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
ob_start(); ob_start();
pr(array('this' => 'is', 'a' => 'test')); pr(array('this' => 'is', 'a' => 'test'));
$result = ob_get_clean(); $result = ob_get_clean();
$expected = "<pre>Array\n(\n [this] => is\n [a] => test\n)\n</pre>"; $expected = "<pre>Array\n(\n [this] => is\n [a] => test\n)\n</pre>";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**

View file

@ -117,13 +117,13 @@ class ControllerTaskTest extends CakeTestCase {
$expected = array('BakeArticles', 'BakeArticlesBakeTags', 'BakeComments', 'BakeTags'); $expected = array('BakeArticles', 'BakeArticlesBakeTags', 'BakeComments', 'BakeTags');
$result = $this->Task->listAll('test'); $result = $this->Task->listAll('test');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Task->interactive = false; $this->Task->interactive = false;
$result = $this->Task->listAll(); $result = $this->Task->listAll();
$expected = array('bake_articles', 'bake_articles_bake_tags', 'bake_comments', 'bake_tags'); $expected = array('bake_articles', 'bake_articles_bake_tags', 'bake_comments', 'bake_tags');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -143,11 +143,11 @@ class ControllerTaskTest extends CakeTestCase {
$result = $this->Task->getName('test'); $result = $this->Task->getName('test');
$expected = 'BakeComments'; $expected = 'BakeComments';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Task->getName('test'); $result = $this->Task->getName('test');
$expected = 'BakeArticles'; $expected = 'BakeArticles';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -187,7 +187,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' Javascript, Ajax, CustomOne ')); $this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' Javascript, Ajax, CustomOne '));
$result = $this->Task->doHelpers(); $result = $this->Task->doHelpers();
$expected = array('Javascript', 'Ajax', 'CustomOne'); $expected = array('Javascript', 'Ajax', 'CustomOne');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -200,7 +200,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' Javascript, Ajax, CustomOne, , ')); $this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' Javascript, Ajax, CustomOne, , '));
$result = $this->Task->doHelpers(); $result = $this->Task->doHelpers();
$expected = array('Javascript', 'Ajax', 'CustomOne'); $expected = array('Javascript', 'Ajax', 'CustomOne');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -225,7 +225,7 @@ class ControllerTaskTest extends CakeTestCase {
$result = $this->Task->doComponents(); $result = $this->Task->doComponents();
$expected = array('RequestHandler', 'Security'); $expected = array('RequestHandler', 'Security');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -239,7 +239,7 @@ class ControllerTaskTest extends CakeTestCase {
$result = $this->Task->doComponents(); $result = $this->Task->doComponents();
$expected = array('RequestHandler', 'Security'); $expected = array('RequestHandler', 'Security');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -644,4 +644,4 @@ class ControllerTaskTest extends CakeTestCase {
); );
$this->Task->execute(); $this->Task->execute();
} }
} }

View file

@ -50,7 +50,7 @@ class FixtureTaskTest extends CakeTestCase {
$out = $this->getMock('ConsoleOutput', array(), array(), '', false); $out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false); $in = $this->getMock('ConsoleInput', array(), array(), '', false);
$this->Task = $this->getMock('FixtureTask', $this->Task = $this->getMock('FixtureTask',
array('in', 'err', 'createFile', '_stop', 'clear'), array('in', 'err', 'createFile', '_stop', 'clear'),
array($out, $out, $in) array($out, $out, $in)
); );
@ -97,7 +97,7 @@ class FixtureTaskTest extends CakeTestCase {
$result = $this->Task->importOptions('Article'); $result = $this->Task->importOptions('Article');
$expected = array('schema' => 'Article', 'records' => true); $expected = array('schema' => 'Article', 'records' => true);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -112,9 +112,9 @@ class FixtureTaskTest extends CakeTestCase {
$result = $this->Task->importOptions('Article'); $result = $this->Task->importOptions('Article');
$expected = array(); $expected = array();
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
* test importOptions choosing from Table. * test importOptions choosing from Table.
* *
@ -126,7 +126,7 @@ class FixtureTaskTest extends CakeTestCase {
$this->Task->expects($this->at(2))->method('in')->will($this->returnValue('y')); $this->Task->expects($this->at(2))->method('in')->will($this->returnValue('y'));
$result = $this->Task->importOptions('Article'); $result = $this->Task->importOptions('Article');
$expected = array('fromTable' => true); $expected = array('fromTable' => true);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -178,7 +178,7 @@ class FixtureTaskTest extends CakeTestCase {
$this->Task->expects($this->at(0))->method('createFile') $this->Task->expects($this->at(0))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class ArticleFixture/')); ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class ArticleFixture/'));
$this->Task->execute(); $this->Task->execute();
} }

View file

@ -131,12 +131,12 @@ class ModelTaskTest extends CakeTestCase {
$result = $this->Task->listAll('test'); $result = $this->Task->listAll('test');
$expected = array('bake_articles', 'bake_articles_bake_tags', 'bake_comments', 'bake_tags', 'category_threads'); $expected = array('bake_articles', 'bake_articles_bake_tags', 'bake_comments', 'bake_tags', 'category_threads');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Task->connection = 'test'; $this->Task->connection = 'test';
$result = $this->Task->listAll(); $result = $this->Task->listAll();
$expected = array('bake_articles', 'bake_articles_bake_tags', 'bake_comments', 'bake_tags', 'category_threads'); $expected = array('bake_articles', 'bake_articles_bake_tags', 'bake_comments', 'bake_tags', 'category_threads');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -187,7 +187,7 @@ class ModelTaskTest extends CakeTestCase {
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y')); $this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y'));
$result = $this->Task->getTable('BakeArticle', 'test'); $result = $this->Task->getTable('BakeArticle', 'test');
$expected = 'bake_articles'; $expected = 'bake_articles';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -199,7 +199,7 @@ class ModelTaskTest extends CakeTestCase {
$this->Task->expects($this->any())->method('in')->will($this->onConsecutiveCalls('n', 'my_table')); $this->Task->expects($this->any())->method('in')->will($this->onConsecutiveCalls('n', 'my_table'));
$result = $this->Task->getTable('BakeArticle', 'test'); $result = $this->Task->getTable('BakeArticle', 'test');
$expected = 'my_table'; $expected = 'my_table';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -254,7 +254,7 @@ class ModelTaskTest extends CakeTestCase {
$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
$expected = array('notempty' => 'notempty', 'maxlength' => 'maxlength'); $expected = array('notempty' => 'notempty', 'maxlength' => 'maxlength');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -275,7 +275,7 @@ class ModelTaskTest extends CakeTestCase {
$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
$expected = array('notempty' => 'notempty'); $expected = array('notempty' => 'notempty');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -291,7 +291,7 @@ class ModelTaskTest extends CakeTestCase {
$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
$expected = array('a_z_0_9' => '/^[a-z]{0,9}$/'); $expected = array('a_z_0_9' => '/^[a-z]{0,9}$/');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -352,7 +352,7 @@ class ModelTaskTest extends CakeTestCase {
'time' => 'time' 'time' => 'time'
), ),
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -370,10 +370,10 @@ class ModelTaskTest extends CakeTestCase {
$this->Task->expects($this->once())->method('in') $this->Task->expects($this->once())->method('in')
->with($anything, null, 'key') ->with($anything, null, 'key')
->will($this->returnValue('my_field')); ->will($this->returnValue('my_field'));
$result = $this->Task->findPrimaryKey($fields); $result = $this->Task->findPrimaryKey($fields);
$expected = 'my_field'; $expected = 'my_field';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -430,7 +430,7 @@ class ModelTaskTest extends CakeTestCase {
), ),
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$model = new Model(array('ds' => 'test', 'name' => 'CategoryThread')); $model = new Model(array('ds' => 'test', 'name' => 'CategoryThread'));
$result = $this->Task->findBelongsTo($model, array()); $result = $this->Task->findBelongsTo($model, array());
@ -443,7 +443,7 @@ class ModelTaskTest extends CakeTestCase {
), ),
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -472,7 +472,7 @@ class ModelTaskTest extends CakeTestCase {
), ),
), ),
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$model = new Model(array('ds' => 'test', 'name' => 'CategoryThread')); $model = new Model(array('ds' => 'test', 'name' => 'CategoryThread'));
$result = $this->Task->findHasOneAndMany($model, array()); $result = $this->Task->findHasOneAndMany($model, array());
@ -492,7 +492,7 @@ class ModelTaskTest extends CakeTestCase {
), ),
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -516,7 +516,7 @@ class ModelTaskTest extends CakeTestCase {
), ),
), ),
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -750,7 +750,7 @@ STRINGEND;
$path = APP . 'Plugin' . DS . 'ControllerTest' . DS . 'Model' . DS . 'BakeArticle.php'; $path = APP . 'Plugin' . DS . 'ControllerTest' . DS . 'Model' . DS . 'BakeArticle.php';
$this->Task->expects($this->once())->method('createFile') $this->Task->expects($this->once())->method('createFile')
->with($path, new PHPUnit_Framework_Constraint_PCREMatch('/BakeArticle extends ControllerTestAppModel/')); ->with($path, new PHPUnit_Framework_Constraint_PCREMatch('/BakeArticle extends ControllerTestAppModel/'));
$this->Task->bake('BakeArticle', array(), array()); $this->Task->bake('BakeArticle', array(), array());
$this->assertEqual(count(ClassRegistry::keys()), 0); $this->assertEqual(count(ClassRegistry::keys()), 0);
@ -767,7 +767,7 @@ STRINGEND;
$this->Task->path = '/my/path/'; $this->Task->path = '/my/path/';
$this->Task->args = array('BakeArticle'); $this->Task->args = array('BakeArticle');
$filename = '/my/path/BakeArticle.php'; $filename = '/my/path/BakeArticle.php';
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1)); $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1));
$this->Task->expects($this->once())->method('createFile') $this->Task->expects($this->once())->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle extends AppModel/')); ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle extends AppModel/'));
@ -818,7 +818,7 @@ STRINGEND;
$this->Task->path = '/my/path/'; $this->Task->path = '/my/path/';
$this->Task->args = array('BakeArticle'); $this->Task->args = array('BakeArticle');
$filename = '/my/path/BakeArticle.php'; $filename = '/my/path/BakeArticle.php';
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1)); $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1));
$this->Task->expects($this->at(0))->method('createFile') $this->Task->expects($this->at(0))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch("/'BakeComment' \=\> array\(/")); ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch("/'BakeComment' \=\> array\(/"));
@ -860,7 +860,7 @@ STRINGEND;
$filename = '/my/path/BakeTag.php'; $filename = '/my/path/BakeTag.php';
$this->Task->expects($this->at(4)) $this->Task->expects($this->at(4))
->method('createFile')->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeTag/')); ->method('createFile')->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeTag/'));
$filename = '/my/path/CategoryThread.php'; $filename = '/my/path/CategoryThread.php';
$this->Task->expects($this->at(5))->method('createFile') $this->Task->expects($this->at(5))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class CategoryThread/')); ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class CategoryThread/'));

View file

@ -134,7 +134,7 @@ class TemplateTaskTest extends CakeTestCase {
$result = $this->Task->generate('classes', 'test_object', array('test' => 'foo')); $result = $this->Task->generate('classes', 'test_object', array('test' => 'foo'));
$expected = "I got rendered\nfoo"; $expected = "I got rendered\nfoo";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**

View file

@ -401,7 +401,7 @@ class TestTaskTest extends CakeTestCase {
$result = $this->Task->getUserFixtures(); $result = $this->Task->getUserFixtures();
$expected = array('app.pizza', 'app.topping', 'app.side_dish'); $expected = array('app.pizza', 'app.topping', 'app.side_dish');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -497,15 +497,15 @@ class TestTaskTest extends CakeTestCase {
public function testGenerateConstructor() { public function testGenerateConstructor() {
$result = $this->Task->generateConstructor('controller', 'PostsController'); $result = $this->Task->generateConstructor('controller', 'PostsController');
$expected = "new TestPostsController();\n\t\t\$this->Posts->constructClasses();\n"; $expected = "new TestPostsController();\n\t\t\$this->Posts->constructClasses();\n";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Task->generateConstructor('model', 'Post'); $result = $this->Task->generateConstructor('model', 'Post');
$expected = "ClassRegistry::init('Post');\n"; $expected = "ClassRegistry::init('Post');\n";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Task->generateConstructor('helper', 'FormHelper'); $result = $this->Task->generateConstructor('helper', 'FormHelper');
$expected = "new FormHelper();\n"; $expected = "new FormHelper();\n";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -578,29 +578,29 @@ class TestTaskTest extends CakeTestCase {
$result = $this->Task->testCaseFileName('Model', 'Post'); $result = $this->Task->testCaseFileName('Model', 'Post');
$expected = $this->Task->path . 'Case' . DS . 'Model' . DS . 'PostTest.php'; $expected = $this->Task->path . 'Case' . DS . 'Model' . DS . 'PostTest.php';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Task->testCaseFileName('Helper', 'Form'); $result = $this->Task->testCaseFileName('Helper', 'Form');
$expected = $this->Task->path . 'Case' . DS . 'View' . DS . 'Helper' . DS . 'FormHelperTest.php'; $expected = $this->Task->path . 'Case' . DS . 'View' . DS . 'Helper' . DS . 'FormHelperTest.php';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Task->testCaseFileName('Controller', 'Posts'); $result = $this->Task->testCaseFileName('Controller', 'Posts');
$expected = $this->Task->path . 'Case' . DS . 'Controller' . DS . 'PostsControllerTest.php'; $expected = $this->Task->path . 'Case' . DS . 'Controller' . DS . 'PostsControllerTest.php';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Task->testCaseFileName('Behavior', 'Containable'); $result = $this->Task->testCaseFileName('Behavior', 'Containable');
$expected = $this->Task->path . 'Case' . DS . 'Model' . DS . 'Behavior' . DS . 'ContainableBehaviorTest.php'; $expected = $this->Task->path . 'Case' . DS . 'Model' . DS . 'Behavior' . DS . 'ContainableBehaviorTest.php';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Task->testCaseFileName('Component', 'Auth'); $result = $this->Task->testCaseFileName('Component', 'Auth');
$expected = $this->Task->path . 'Case' . DS . 'Controller' . DS . 'Component' . DS . 'AuthComponentTest.php'; $expected = $this->Task->path . 'Case' . DS . 'Controller' . DS . 'Component' . DS . 'AuthComponentTest.php';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
CakePlugin::load('TestTest', array('path' => APP . 'Plugin' . DS . 'TestTest' . DS )); CakePlugin::load('TestTest', array('path' => APP . 'Plugin' . DS . 'TestTest' . DS ));
$this->Task->plugin = 'TestTest'; $this->Task->plugin = 'TestTest';
$result = $this->Task->testCaseFileName('Model', 'Post'); $result = $this->Task->testCaseFileName('Model', 'Post');
$expected = APP . 'Plugin' . DS . 'TestTest' . DS . 'tests' . DS . 'Case' . DS . 'Model' . DS . 'PostTest.php'; $expected = APP . 'Plugin' . DS . 'TestTest' . DS . 'tests' . DS . 'Case' . DS . 'Model' . DS . 'PostTest.php';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**

View file

@ -97,7 +97,7 @@ class ConsoleOutputTest extends CakeTestCase {
function testStylesGet() { function testStylesGet() {
$result = $this->output->styles('error'); $result = $this->output->styles('error');
$expected = array('text' => 'red', 'underline' => true); $expected = array('text' => 'red', 'underline' => true);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertNull($this->output->styles('made_up_goop')); $this->assertNull($this->output->styles('made_up_goop'));
@ -116,7 +116,7 @@ class ConsoleOutputTest extends CakeTestCase {
$result = $this->output->styles('test'); $result = $this->output->styles('test');
$expected = array('text' => 'red', 'background' => 'black'); $expected = array('text' => 'red', 'background' => 'black');
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$this->assertTrue($this->output->styles('test', false), 'Removing a style should return true.'); $this->assertTrue($this->output->styles('test', false), 'Removing a style should return true.');
$this->assertNull($this->output->styles('test'), 'Removed styles should be null.'); $this->assertNull($this->output->styles('test'), 'Removed styles should be null.');
} }
@ -225,4 +225,4 @@ class ConsoleOutputTest extends CakeTestCase {
$this->output->write('<error>Bad</error> Regular', false); $this->output->write('<error>Bad</error> Regular', false);
} }
} }

View file

@ -549,7 +549,7 @@ class DbAclTest extends CakeTestCase {
array('AroTwoTest' => array('id' => '4', 'parent_id' => '1', 'model' => 'Group', 'foreign_key' => 3, 'alias' => 'users')), array('AroTwoTest' => array('id' => '4', 'parent_id' => '1', 'model' => 'Group', 'foreign_key' => 3, 'alias' => 'users')),
array('AroTwoTest' => array('id' => '1', 'parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'root')) array('AroTwoTest' => array('id' => '1', 'parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'root'))
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Acl->Aco->node('ROOT/tpsReports/view/current'); $result = $this->Acl->Aco->node('ROOT/tpsReports/view/current');
$expected = array( $expected = array(
@ -558,7 +558,7 @@ class DbAclTest extends CakeTestCase {
array('AcoTwoTest' => array('id' => '2', 'parent_id' => '1', 'model' => null, 'foreign_key' => null, 'alias' => 'tpsReports')), array('AcoTwoTest' => array('id' => '2', 'parent_id' => '1', 'model' => null, 'foreign_key' => null, 'alias' => 'tpsReports')),
array('AcoTwoTest' => array('id' => '1', 'parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'ROOT')), array('AcoTwoTest' => array('id' => '1', 'parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'ROOT')),
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**

View file

@ -582,18 +582,18 @@ HTMLBLOC;
$result = $this->Controller->EmailTest->strip($content, true); $result = $this->Controller->EmailTest->strip($content, true);
$expected = "Previous content\n--alt-\n text/html; utf-8\n 7bit\n\n<p>My own html content</p>"; $expected = "Previous content\n--alt-\n text/html; utf-8\n 7bit\n\n<p>My own html content</p>";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$content = '<p>Some HTML content with an <a href="mailto:test@example.com">email link</a>'; $content = '<p>Some HTML content with an <a href="mailto:test@example.com">email link</a>';
$result = $this->Controller->EmailTest->strip($content, true); $result = $this->Controller->EmailTest->strip($content, true);
$expected = $content; $expected = $content;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$content = '<p>Some HTML content with an '; $content = '<p>Some HTML content with an ';
$content .= '<a href="mailto:test@example.com,test2@example.com">email link</a>'; $content .= '<a href="mailto:test@example.com,test2@example.com">email link</a>';
$result = $this->Controller->EmailTest->strip($content, true); $result = $this->Controller->EmailTest->strip($content, true);
$expected = $content; $expected = $content;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**

View file

@ -147,10 +147,10 @@ class SessionComponentTest extends CakeTestCase {
$expected = $Session->id(); $expected = $Session->id();
$result = $Object->requestAction('/session_test/session_id'); $result = $Object->requestAction('/session_test/session_id');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $Object->requestAction('/orange_session_test/session_id'); $result = $Object->requestAction('/orange_session_test/session_id');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**

View file

@ -569,7 +569,7 @@ class ControllerTest extends CakeTestCase {
</html>'; </html>';
$result = str_replace(array("\t", "\r\n", "\n"), "", $result); $result = str_replace(array("\t", "\r\n", "\n"), "", $result);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $expected); $expected = str_replace(array("\t", "\r\n", "\n"), "", $expected);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
App::build(array( App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS) 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
@ -1035,7 +1035,7 @@ class ControllerTest extends CakeTestCase {
$comment->set('someVar', 'data'); $comment->set('someVar', 'data');
$result = $TestController->validateErrors($comment); $result = $TestController->validateErrors($comment);
$expected = array('some_field' => array('error_message'), 'some_field2' => array('error_message2')); $expected = array('some_field' => array('error_message'), 'some_field2' => array('error_message2'));
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$this->assertEqual($TestController->validate($comment), 2); $this->assertEqual($TestController->validate($comment), 2);
} }
@ -1053,7 +1053,7 @@ class ControllerTest extends CakeTestCase {
$result = $TestController->validateErrors($Post); $result = $TestController->validateErrors($Post);
$expected = array('title' => array('This field cannot be left blank')); $expected = array('title' => array('This field cannot be left blank'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -1078,7 +1078,7 @@ class ControllerTest extends CakeTestCase {
'Model3.field3' => '23', 'Model3.field3' => '23',
); );
$result = $Controller->postConditions($data); $result = $Controller->postConditions($data);
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$data = array(); $data = array();
@ -1093,7 +1093,7 @@ class ControllerTest extends CakeTestCase {
'Model3.field3' => '23', 'Model3.field3' => '23',
); );
$result = $Controller->postConditions($data); $result = $Controller->postConditions($data);
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$data = array(); $data = array();
@ -1119,7 +1119,7 @@ class ControllerTest extends CakeTestCase {
'Model3.field3 <=' => '23', 'Model3.field3 <=' => '23',
); );
$result = $Controller->postConditions($data, $ops); $result = $Controller->postConditions($data, $ops);
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
} }
/** /**

View file

@ -293,7 +293,7 @@ class AppImportTest extends CakeTestCase {
$result = App::objects('file', 'non_existing_configure'); $result = App::objects('file', 'non_existing_configure');
$expected = array(); $expected = array();
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = App::objects('NonExistingType'); $result = App::objects('NonExistingType');
$this->assertEqual($result, array()); $this->assertEqual($result, array());
@ -335,11 +335,11 @@ class AppImportTest extends CakeTestCase {
$result = App::objects('TestPlugin.helper'); $result = App::objects('TestPlugin.helper');
sort($result); sort($result);
$expected = array('OtherHelperHelper', 'PluggedHelperHelper', 'TestPluginAppHelper'); $expected = array('OtherHelperHelper', 'PluggedHelperHelper', 'TestPluginAppHelper');
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = App::objects('TestPlugin.View/Helper'); $result = App::objects('TestPlugin.View/Helper');
sort($result); sort($result);
$expected = array('OtherHelperHelper', 'PluggedHelperHelper', 'TestPluginAppHelper'); $expected = array('OtherHelperHelper', 'PluggedHelperHelper', 'TestPluginAppHelper');
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = App::objects('TestPlugin.component'); $result = App::objects('TestPlugin.component');
$this->assertTrue(in_array('OtherComponent', $result)); $this->assertTrue(in_array('OtherComponent', $result));

View file

@ -447,7 +447,7 @@ class ObjectTest extends CakeTestCase {
$this->object->testPersist('ObjectTestModel', true, $model, 'registry'); $this->object->testPersist('ObjectTestModel', true, $model, 'registry');
$result = ClassRegistry::keys(); $result = ClassRegistry::keys();
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$newModel = ClassRegistry::getObject('object_test_model'); $newModel = ClassRegistry::getObject('object_test_model');
$this->assertEqual('ObjectTestModel', $newModel->name); $this->assertEqual('ObjectTestModel', $newModel->name);
@ -575,7 +575,7 @@ class ObjectTest extends CakeTestCase {
)); ));
$result = $this->object->requestAction('/request_action_persistent/index'); $result = $this->object->requestAction('/request_action_persistent/index');
$expected = 'This is a test'; $expected = 'This is a test';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
@unlink(CACHE . 'persistent' . DS . 'persisterone.php'); @unlink(CACHE . 'persistent' . DS . 'persisterone.php');
@unlink(CACHE . 'persistent' . DS . 'persisteroneregistry.php'); @unlink(CACHE . 'persistent' . DS . 'persisteroneregistry.php');
@ -685,26 +685,26 @@ class ObjectTest extends CakeTestCase {
$result = $this->object->requestAction('/request_action/test_request_action'); $result = $this->object->requestAction('/request_action/test_request_action');
$expected = 'This is a test'; $expected = 'This is a test';
$this->assertEqual($result, $expected);; $this->assertEqual($expected, $result);;
$result = $this->object->requestAction('/request_action/another_ra_test/2/5'); $result = $this->object->requestAction('/request_action/another_ra_test/2/5');
$expected = 7; $expected = 7;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->object->requestAction('/tests_apps/index', array('return')); $result = $this->object->requestAction('/tests_apps/index', array('return'));
$expected = 'This is the TestsAppsController index view'; $expected = 'This is the TestsAppsController index view';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->object->requestAction('/tests_apps/some_method'); $result = $this->object->requestAction('/tests_apps/some_method');
$expected = 5; $expected = 5;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->object->requestAction('/request_action/paginate_request_action'); $result = $this->object->requestAction('/request_action/paginate_request_action');
$this->assertTrue($result); $this->assertTrue($result);
$result = $this->object->requestAction('/request_action/normal_request_action'); $result = $this->object->requestAction('/request_action/normal_request_action');
$expected = 'Hello World'; $expected = 'Hello World';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
App::build(); App::build();
} }
@ -723,27 +723,27 @@ class ObjectTest extends CakeTestCase {
$result = $this->object->requestAction('/test_plugin/tests/index', array('return')); $result = $this->object->requestAction('/test_plugin/tests/index', array('return'));
$expected = 'test plugin index'; $expected = 'test plugin index';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->object->requestAction('/test_plugin/tests/index/some_param', array('return')); $result = $this->object->requestAction('/test_plugin/tests/index/some_param', array('return'));
$expected = 'test plugin index'; $expected = 'test plugin index';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->object->requestAction( $result = $this->object->requestAction(
array('controller' => 'tests', 'action' => 'index', 'plugin' => 'test_plugin'), array('return') array('controller' => 'tests', 'action' => 'index', 'plugin' => 'test_plugin'), array('return')
); );
$expected = 'test plugin index'; $expected = 'test plugin index';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->object->requestAction('/test_plugin/tests/some_method'); $result = $this->object->requestAction('/test_plugin/tests/some_method');
$expected = 25; $expected = 25;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->object->requestAction( $result = $this->object->requestAction(
array('controller' => 'tests', 'action' => 'some_method', 'plugin' => 'test_plugin') array('controller' => 'tests', 'action' => 'some_method', 'plugin' => 'test_plugin')
); );
$expected = 25; $expected = 25;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
App::build(); App::build();
CakePlugin::unload(); CakePlugin::unload();
@ -767,30 +767,30 @@ class ObjectTest extends CakeTestCase {
array('controller' => 'request_action', 'action' => 'test_request_action') array('controller' => 'request_action', 'action' => 'test_request_action')
); );
$expected = 'This is a test'; $expected = 'This is a test';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->object->requestAction( $result = $this->object->requestAction(
array('controller' => 'request_action', 'action' => 'another_ra_test'), array('controller' => 'request_action', 'action' => 'another_ra_test'),
array('pass' => array('5', '7')) array('pass' => array('5', '7'))
); );
$expected = 12; $expected = 12;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->object->requestAction( $result = $this->object->requestAction(
array('controller' => 'tests_apps', 'action' => 'index'), array('return') array('controller' => 'tests_apps', 'action' => 'index'), array('return')
); );
$expected = 'This is the TestsAppsController index view'; $expected = 'This is the TestsAppsController index view';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->object->requestAction(array('controller' => 'tests_apps', 'action' => 'some_method')); $result = $this->object->requestAction(array('controller' => 'tests_apps', 'action' => 'some_method'));
$expected = 5; $expected = 5;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->object->requestAction( $result = $this->object->requestAction(
array('controller' => 'request_action', 'action' => 'normal_request_action') array('controller' => 'request_action', 'action' => 'normal_request_action')
); );
$expected = 'Hello World'; $expected = 'Hello World';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->object->requestAction( $result = $this->object->requestAction(
array('controller' => 'request_action', 'action' => 'paginate_request_action') array('controller' => 'request_action', 'action' => 'paginate_request_action')

View file

@ -2487,7 +2487,7 @@ class I18nTest extends CakeTestCase {
$expected .= "broken up over multiple lines.\n"; $expected .= "broken up over multiple lines.\n";
$expected .= "This is the third line.\n"; $expected .= "This is the third line.\n";
$expected .= "This is the forth line. (translated)"; $expected .= "This is the forth line. (translated)";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
// Windows Newline is \r\n // Windows Newline is \r\n
$string = "This is a multiline translation\r\n"; $string = "This is a multiline translation\r\n";
@ -2495,18 +2495,18 @@ class I18nTest extends CakeTestCase {
$string .= "This is the third line.\r\n"; $string .= "This is the third line.\r\n";
$string .= "This is the forth line."; $string .= "This is the forth line.";
$result = __($string); $result = __($string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$singular = "valid\nsecond line"; $singular = "valid\nsecond line";
$plural = "valids\nsecond line"; $plural = "valids\nsecond line";
$result = __n($singular, $plural, 1); $result = __n($singular, $plural, 1);
$expected = "v\nsecond line"; $expected = "v\nsecond line";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __n($singular, $plural, 2); $result = __n($singular, $plural, 2);
$expected = "vs\nsecond line"; $expected = "vs\nsecond line";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = "This is a multiline translation\n"; $string = "This is a multiline translation\n";
$string .= "broken up over multiple lines.\n"; $string .= "broken up over multiple lines.\n";
@ -2518,11 +2518,11 @@ class I18nTest extends CakeTestCase {
$result = __n($singular, $plural, 1); $result = __n($singular, $plural, 1);
$expected = "%d is 1\n" . $string; $expected = "%d is 1\n" . $string;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __n($singular, $plural, 2); $result = __n($singular, $plural, 2);
$expected = "%d is 2-4\n" . $string; $expected = "%d is 2-4\n" . $string;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
// Windows Newline is \r\n // Windows Newline is \r\n
$string = "This is a multiline translation\r\n"; $string = "This is a multiline translation\r\n";
@ -2535,11 +2535,11 @@ class I18nTest extends CakeTestCase {
$result = __n($singular, $plural, 1); $result = __n($singular, $plural, 1);
$expected = "%d is 1\n" . str_replace("\r\n", "\n", $string); $expected = "%d is 1\n" . str_replace("\r\n", "\n", $string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __n($singular, $plural, 2); $result = __n($singular, $plural, 2);
$expected = "%d is 2-4\n" . str_replace("\r\n", "\n", $string); $expected = "%d is 2-4\n" . str_replace("\r\n", "\n", $string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -2576,15 +2576,15 @@ class I18nTest extends CakeTestCase {
$result = __n('%d = 1', '%d = 0 or > 1', (float)1); $result = __n('%d = 1', '%d = 0 or > 1', (float)1);
$expected = '%d is 1 (translated)'; $expected = '%d is 1 (translated)';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __n('%d = 1', '%d = 0 or > 1', (float)2); $result = __n('%d = 1', '%d = 0 or > 1', (float)2);
$expected = "%d ends in 2-4, not 12-14 (translated)"; $expected = "%d ends in 2-4, not 12-14 (translated)";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __n('%d = 1', '%d = 0 or > 1', (float)5); $result = __n('%d = 1', '%d = 0 or > 1', (float)5);
$expected = "%d everything else (translated)"; $expected = "%d everything else (translated)";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -2635,15 +2635,15 @@ class I18nTest extends CakeTestCase {
Configure::write('Config.language', 'po'); Configure::write('Config.language', 'po');
$result = __c('d_fmt', 5); $result = __c('d_fmt', 5);
$expected = '%m/%d/%Y'; $expected = '%m/%d/%Y';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __c('am_pm', 5); $result = __c('am_pm', 5);
$expected = array('AM', 'PM'); $expected = array('AM', 'PM');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __c('abmon', 5); $result = __c('abmon', 5);
$expected = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); $expected = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
function testTimeDefinitionJapanese(){ function testTimeDefinitionJapanese(){
@ -2652,15 +2652,15 @@ class I18nTest extends CakeTestCase {
$expected = "%Y年%m月%d日"; $expected = "%Y年%m月%d日";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __c('am_pm', 5); $result = __c('am_pm', 5);
$expected = array("午前", "午後"); $expected = array("午前", "午後");
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = __c('abmon', 5); $result = __c('abmon', 5);
$expected = array(" 1月", " 2月", " 3月", " 4月", " 5月", " 6月", " 7月", " 8月", " 9月", "10月", "11月", "12月"); $expected = array(" 1月", " 2月", " 3月", " 4月", " 5月", " 6月", " 7月", " 8月", " 9月", "10月", "11月", "12月");
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**

View file

@ -123,323 +123,323 @@ class L10nTest extends CakeTestCase {
$result = $l10n->map(array('afr', 'af')); $result = $l10n->map(array('afr', 'af'));
$expected = array('afr' => 'af', 'af' => 'afr'); $expected = array('afr' => 'af', 'af' => 'afr');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('alb', 'sq')); $result = $l10n->map(array('alb', 'sq'));
$expected = array('alb' => 'sq', 'sq' => 'alb'); $expected = array('alb' => 'sq', 'sq' => 'alb');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('ara', 'ar')); $result = $l10n->map(array('ara', 'ar'));
$expected = array('ara' => 'ar', 'ar' => 'ara'); $expected = array('ara' => 'ar', 'ar' => 'ara');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('hye', 'hy')); $result = $l10n->map(array('hye', 'hy'));
$expected = array('hye' => 'hy', 'hy' => 'hye'); $expected = array('hye' => 'hy', 'hy' => 'hye');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('baq', 'eu')); $result = $l10n->map(array('baq', 'eu'));
$expected = array('baq' => 'eu', 'eu' => 'baq'); $expected = array('baq' => 'eu', 'eu' => 'baq');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('baq', 'eu')); $result = $l10n->map(array('baq', 'eu'));
$expected = array('baq' => 'eu', 'eu' => 'baq'); $expected = array('baq' => 'eu', 'eu' => 'baq');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('bos', 'bs')); $result = $l10n->map(array('bos', 'bs'));
$expected = array('bos' => 'bs', 'bs' => 'bos'); $expected = array('bos' => 'bs', 'bs' => 'bos');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('bul', 'bg')); $result = $l10n->map(array('bul', 'bg'));
$expected = array('bul' => 'bg', 'bg' => 'bul'); $expected = array('bul' => 'bg', 'bg' => 'bul');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('bel', 'be')); $result = $l10n->map(array('bel', 'be'));
$expected = array('bel' => 'be', 'be' => 'bel'); $expected = array('bel' => 'be', 'be' => 'bel');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('cat', 'ca')); $result = $l10n->map(array('cat', 'ca'));
$expected = array('cat' => 'ca', 'ca' => 'cat'); $expected = array('cat' => 'ca', 'ca' => 'cat');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('chi', 'zh')); $result = $l10n->map(array('chi', 'zh'));
$expected = array('chi' => 'zh', 'zh' => 'chi'); $expected = array('chi' => 'zh', 'zh' => 'chi');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('zho', 'zh')); $result = $l10n->map(array('zho', 'zh'));
$expected = array('zho' => 'zh', 'zh' => 'chi'); $expected = array('zho' => 'zh', 'zh' => 'chi');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('hrv', 'hr')); $result = $l10n->map(array('hrv', 'hr'));
$expected = array('hrv' => 'hr', 'hr' => 'hrv'); $expected = array('hrv' => 'hr', 'hr' => 'hrv');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('ces', 'cs')); $result = $l10n->map(array('ces', 'cs'));
$expected = array('ces' => 'cs', 'cs' => 'cze'); $expected = array('ces' => 'cs', 'cs' => 'cze');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('cze', 'cs')); $result = $l10n->map(array('cze', 'cs'));
$expected = array('cze' => 'cs', 'cs' => 'cze'); $expected = array('cze' => 'cs', 'cs' => 'cze');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('dan', 'da')); $result = $l10n->map(array('dan', 'da'));
$expected = array('dan' => 'da', 'da' => 'dan'); $expected = array('dan' => 'da', 'da' => 'dan');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('dut', 'nl')); $result = $l10n->map(array('dut', 'nl'));
$expected = array('dut' => 'nl', 'nl' => 'dut'); $expected = array('dut' => 'nl', 'nl' => 'dut');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('nld', 'nl')); $result = $l10n->map(array('nld', 'nl'));
$expected = array('nld' => 'nl', 'nl' => 'dut'); $expected = array('nld' => 'nl', 'nl' => 'dut');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('nld')); $result = $l10n->map(array('nld'));
$expected = array('nld' => 'nl'); $expected = array('nld' => 'nl');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('eng', 'en')); $result = $l10n->map(array('eng', 'en'));
$expected = array('eng' => 'en', 'en' => 'eng'); $expected = array('eng' => 'en', 'en' => 'eng');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('est', 'et')); $result = $l10n->map(array('est', 'et'));
$expected = array('est' => 'et', 'et' => 'est'); $expected = array('est' => 'et', 'et' => 'est');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('fao', 'fo')); $result = $l10n->map(array('fao', 'fo'));
$expected = array('fao' => 'fo', 'fo' => 'fao'); $expected = array('fao' => 'fo', 'fo' => 'fao');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('fas', 'fa')); $result = $l10n->map(array('fas', 'fa'));
$expected = array('fas' => 'fa', 'fa' => 'fas'); $expected = array('fas' => 'fa', 'fa' => 'fas');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('per', 'fa')); $result = $l10n->map(array('per', 'fa'));
$expected = array('per' => 'fa', 'fa' => 'fas'); $expected = array('per' => 'fa', 'fa' => 'fas');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('fin', 'fi')); $result = $l10n->map(array('fin', 'fi'));
$expected = array('fin' => 'fi', 'fi' => 'fin'); $expected = array('fin' => 'fi', 'fi' => 'fin');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('fra', 'fr')); $result = $l10n->map(array('fra', 'fr'));
$expected = array('fra' => 'fr', 'fr' => 'fre'); $expected = array('fra' => 'fr', 'fr' => 'fre');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('fre', 'fr')); $result = $l10n->map(array('fre', 'fr'));
$expected = array('fre' => 'fr', 'fr' => 'fre'); $expected = array('fre' => 'fr', 'fr' => 'fre');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('gla', 'gd')); $result = $l10n->map(array('gla', 'gd'));
$expected = array('gla' => 'gd', 'gd' => 'gla'); $expected = array('gla' => 'gd', 'gd' => 'gla');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('glg', 'gl')); $result = $l10n->map(array('glg', 'gl'));
$expected = array('glg' => 'gl', 'gl' => 'glg'); $expected = array('glg' => 'gl', 'gl' => 'glg');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('deu', 'de')); $result = $l10n->map(array('deu', 'de'));
$expected = array('deu' => 'de', 'de' => 'deu'); $expected = array('deu' => 'de', 'de' => 'deu');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('ger', 'de')); $result = $l10n->map(array('ger', 'de'));
$expected = array('ger' => 'de', 'de' => 'deu'); $expected = array('ger' => 'de', 'de' => 'deu');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('ell', 'el')); $result = $l10n->map(array('ell', 'el'));
$expected = array('ell' => 'el', 'el' => 'gre'); $expected = array('ell' => 'el', 'el' => 'gre');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('gre', 'el')); $result = $l10n->map(array('gre', 'el'));
$expected = array('gre' => 'el', 'el' => 'gre'); $expected = array('gre' => 'el', 'el' => 'gre');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('heb', 'he')); $result = $l10n->map(array('heb', 'he'));
$expected = array('heb' => 'he', 'he' => 'heb'); $expected = array('heb' => 'he', 'he' => 'heb');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('hin', 'hi')); $result = $l10n->map(array('hin', 'hi'));
$expected = array('hin' => 'hi', 'hi' => 'hin'); $expected = array('hin' => 'hi', 'hi' => 'hin');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('hun', 'hu')); $result = $l10n->map(array('hun', 'hu'));
$expected = array('hun' => 'hu', 'hu' => 'hun'); $expected = array('hun' => 'hu', 'hu' => 'hun');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('ice', 'is')); $result = $l10n->map(array('ice', 'is'));
$expected = array('ice' => 'is', 'is' => 'ice'); $expected = array('ice' => 'is', 'is' => 'ice');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('isl', 'is')); $result = $l10n->map(array('isl', 'is'));
$expected = array('isl' => 'is', 'is' => 'ice'); $expected = array('isl' => 'is', 'is' => 'ice');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('ind', 'id')); $result = $l10n->map(array('ind', 'id'));
$expected = array('ind' => 'id', 'id' => 'ind'); $expected = array('ind' => 'id', 'id' => 'ind');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('gle', 'ga')); $result = $l10n->map(array('gle', 'ga'));
$expected = array('gle' => 'ga', 'ga' => 'gle'); $expected = array('gle' => 'ga', 'ga' => 'gle');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('ita', 'it')); $result = $l10n->map(array('ita', 'it'));
$expected = array('ita' => 'it', 'it' => 'ita'); $expected = array('ita' => 'it', 'it' => 'ita');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('jpn', 'ja')); $result = $l10n->map(array('jpn', 'ja'));
$expected = array('jpn' => 'ja', 'ja' => 'jpn'); $expected = array('jpn' => 'ja', 'ja' => 'jpn');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('kor', 'ko')); $result = $l10n->map(array('kor', 'ko'));
$expected = array('kor' => 'ko', 'ko' => 'kor'); $expected = array('kor' => 'ko', 'ko' => 'kor');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('lav', 'lv')); $result = $l10n->map(array('lav', 'lv'));
$expected = array('lav' => 'lv', 'lv' => 'lav'); $expected = array('lav' => 'lv', 'lv' => 'lav');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('lit', 'lt')); $result = $l10n->map(array('lit', 'lt'));
$expected = array('lit' => 'lt', 'lt' => 'lit'); $expected = array('lit' => 'lt', 'lt' => 'lit');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('mac', 'mk')); $result = $l10n->map(array('mac', 'mk'));
$expected = array('mac' => 'mk', 'mk' => 'mac'); $expected = array('mac' => 'mk', 'mk' => 'mac');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('mkd', 'mk')); $result = $l10n->map(array('mkd', 'mk'));
$expected = array('mkd' => 'mk', 'mk' => 'mac'); $expected = array('mkd' => 'mk', 'mk' => 'mac');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('may', 'ms')); $result = $l10n->map(array('may', 'ms'));
$expected = array('may' => 'ms', 'ms' => 'may'); $expected = array('may' => 'ms', 'ms' => 'may');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('msa', 'ms')); $result = $l10n->map(array('msa', 'ms'));
$expected = array('msa' => 'ms', 'ms' => 'may'); $expected = array('msa' => 'ms', 'ms' => 'may');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('mlt', 'mt')); $result = $l10n->map(array('mlt', 'mt'));
$expected = array('mlt' => 'mt', 'mt' => 'mlt'); $expected = array('mlt' => 'mt', 'mt' => 'mlt');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('nor', 'no')); $result = $l10n->map(array('nor', 'no'));
$expected = array('nor' => 'no', 'no' => 'nor'); $expected = array('nor' => 'no', 'no' => 'nor');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('nob', 'nb')); $result = $l10n->map(array('nob', 'nb'));
$expected = array('nob' => 'nb', 'nb' => 'nob'); $expected = array('nob' => 'nb', 'nb' => 'nob');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('nno', 'nn')); $result = $l10n->map(array('nno', 'nn'));
$expected = array('nno' => 'nn', 'nn' => 'nno'); $expected = array('nno' => 'nn', 'nn' => 'nno');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('pol', 'pl')); $result = $l10n->map(array('pol', 'pl'));
$expected = array('pol' => 'pl', 'pl' => 'pol'); $expected = array('pol' => 'pl', 'pl' => 'pol');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('por', 'pt')); $result = $l10n->map(array('por', 'pt'));
$expected = array('por' => 'pt', 'pt' => 'por'); $expected = array('por' => 'pt', 'pt' => 'por');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('roh', 'rm')); $result = $l10n->map(array('roh', 'rm'));
$expected = array('roh' => 'rm', 'rm' => 'roh'); $expected = array('roh' => 'rm', 'rm' => 'roh');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('ron', 'ro')); $result = $l10n->map(array('ron', 'ro'));
$expected = array('ron' => 'ro', 'ro' => 'rum'); $expected = array('ron' => 'ro', 'ro' => 'rum');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('rum', 'ro')); $result = $l10n->map(array('rum', 'ro'));
$expected = array('rum' => 'ro', 'ro' => 'rum'); $expected = array('rum' => 'ro', 'ro' => 'rum');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('rus', 'ru')); $result = $l10n->map(array('rus', 'ru'));
$expected = array('rus' => 'ru', 'ru' => 'rus'); $expected = array('rus' => 'ru', 'ru' => 'rus');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('smi', 'sz')); $result = $l10n->map(array('smi', 'sz'));
$expected = array('smi' => 'sz', 'sz' => 'smi'); $expected = array('smi' => 'sz', 'sz' => 'smi');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('scc', 'sr')); $result = $l10n->map(array('scc', 'sr'));
$expected = array('scc' => 'sr', 'sr' => 'scc'); $expected = array('scc' => 'sr', 'sr' => 'scc');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('srp', 'sr')); $result = $l10n->map(array('srp', 'sr'));
$expected = array('srp' => 'sr', 'sr' => 'scc'); $expected = array('srp' => 'sr', 'sr' => 'scc');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('slk', 'sk')); $result = $l10n->map(array('slk', 'sk'));
$expected = array('slk' => 'sk', 'sk' => 'slo'); $expected = array('slk' => 'sk', 'sk' => 'slo');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('slo', 'sk')); $result = $l10n->map(array('slo', 'sk'));
$expected = array('slo' => 'sk', 'sk' => 'slo'); $expected = array('slo' => 'sk', 'sk' => 'slo');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('slv', 'sl')); $result = $l10n->map(array('slv', 'sl'));
$expected = array('slv' => 'sl', 'sl' => 'slv'); $expected = array('slv' => 'sl', 'sl' => 'slv');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('wen', 'sb')); $result = $l10n->map(array('wen', 'sb'));
$expected = array('wen' => 'sb', 'sb' => 'wen'); $expected = array('wen' => 'sb', 'sb' => 'wen');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('spa', 'es')); $result = $l10n->map(array('spa', 'es'));
$expected = array('spa' => 'es', 'es' => 'spa'); $expected = array('spa' => 'es', 'es' => 'spa');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('swe', 'sv')); $result = $l10n->map(array('swe', 'sv'));
$expected = array('swe' => 'sv', 'sv' => 'swe'); $expected = array('swe' => 'sv', 'sv' => 'swe');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('tha', 'th')); $result = $l10n->map(array('tha', 'th'));
$expected = array('tha' => 'th', 'th' => 'tha'); $expected = array('tha' => 'th', 'th' => 'tha');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('tso', 'ts')); $result = $l10n->map(array('tso', 'ts'));
$expected = array('tso' => 'ts', 'ts' => 'tso'); $expected = array('tso' => 'ts', 'ts' => 'tso');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('tsn', 'tn')); $result = $l10n->map(array('tsn', 'tn'));
$expected = array('tsn' => 'tn', 'tn' => 'tsn'); $expected = array('tsn' => 'tn', 'tn' => 'tsn');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('tur', 'tr')); $result = $l10n->map(array('tur', 'tr'));
$expected = array('tur' => 'tr', 'tr' => 'tur'); $expected = array('tur' => 'tr', 'tr' => 'tur');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('ukr', 'uk')); $result = $l10n->map(array('ukr', 'uk'));
$expected = array('ukr' => 'uk', 'uk' => 'ukr'); $expected = array('ukr' => 'uk', 'uk' => 'ukr');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('urd', 'ur')); $result = $l10n->map(array('urd', 'ur'));
$expected = array('urd' => 'ur', 'ur' => 'urd'); $expected = array('urd' => 'ur', 'ur' => 'urd');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('ven', 've')); $result = $l10n->map(array('ven', 've'));
$expected = array('ven' => 've', 've' => 'ven'); $expected = array('ven' => 've', 've' => 'ven');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('vie', 'vi')); $result = $l10n->map(array('vie', 'vi'));
$expected = array('vie' => 'vi', 'vi' => 'vie'); $expected = array('vie' => 'vi', 'vi' => 'vie');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('xho', 'xh')); $result = $l10n->map(array('xho', 'xh'));
$expected = array('xho' => 'xh', 'xh' => 'xho'); $expected = array('xho' => 'xh', 'xh' => 'xho');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('cy', 'cym')); $result = $l10n->map(array('cy', 'cym'));
$expected = array('cym' => 'cy', 'cy' => 'cym'); $expected = array('cym' => 'cy', 'cy' => 'cym');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('yid', 'yi')); $result = $l10n->map(array('yid', 'yi'));
$expected = array('yid' => 'yi', 'yi' => 'yid'); $expected = array('yid' => 'yi', 'yi' => 'yid');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->map(array('zul', 'zu')); $result = $l10n->map(array('zul', 'zu'));
$expected = array('zul' => 'zu', 'zu' => 'zul'); $expected = array('zul' => 'zu', 'zu' => 'zul');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -455,7 +455,7 @@ class L10nTest extends CakeTestCase {
$expected = array( $expected = array(
'af' => array('language' => 'Afrikaans', 'locale' => 'afr', 'localeFallback' => 'afr', 'charset' => 'utf-8', 'direction' => 'ltr') 'af' => array('language' => 'Afrikaans', 'locale' => 'afr', 'localeFallback' => 'afr', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('ar', 'ar-ae', 'ar-bh', 'ar-dz', 'ar-eg', 'ar-iq', 'ar-jo', 'ar-kw', 'ar-lb', 'ar-ly', 'ar-ma', $result = $l10n->catalog(array('ar', 'ar-ae', 'ar-bh', 'ar-dz', 'ar-eg', 'ar-iq', 'ar-jo', 'ar-kw', 'ar-lb', 'ar-ly', 'ar-ma',
'ar-om', 'ar-qa', 'ar-sa', 'ar-sy', 'ar-tn', 'ar-ye')); 'ar-om', 'ar-qa', 'ar-sa', 'ar-sy', 'ar-tn', 'ar-ye'));
@ -478,43 +478,43 @@ class L10nTest extends CakeTestCase {
'ar-tn' => array('language' => 'Arabic (Tunisia)', 'locale' => 'ar_tn', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), 'ar-tn' => array('language' => 'Arabic (Tunisia)', 'locale' => 'ar_tn', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'),
'ar-ye' => array('language' => 'Arabic (Yemen)', 'locale' => 'ar_ye', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl') 'ar-ye' => array('language' => 'Arabic (Yemen)', 'locale' => 'ar_ye', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('be')); $result = $l10n->catalog(array('be'));
$expected = array( $expected = array(
'be' => array('language' => 'Byelorussian', 'locale' => 'bel', 'localeFallback' => 'bel', 'charset' => 'utf-8', 'direction' => 'ltr') 'be' => array('language' => 'Byelorussian', 'locale' => 'bel', 'localeFallback' => 'bel', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('bg')); $result = $l10n->catalog(array('bg'));
$expected = array( $expected = array(
'bg' => array('language' => 'Bulgarian', 'locale' => 'bul', 'localeFallback' => 'bul', 'charset' => 'utf-8', 'direction' => 'ltr') 'bg' => array('language' => 'Bulgarian', 'locale' => 'bul', 'localeFallback' => 'bul', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('bs')); $result = $l10n->catalog(array('bs'));
$expected = array( $expected = array(
'bs' => array('language' => 'Bosnian', 'locale' => 'bos', 'localeFallback' => 'bos', 'charset' => 'utf-8', 'direction' => 'ltr') 'bs' => array('language' => 'Bosnian', 'locale' => 'bos', 'localeFallback' => 'bos', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('ca')); $result = $l10n->catalog(array('ca'));
$expected = array( $expected = array(
'ca' => array('language' => 'Catalan', 'locale' => 'cat', 'localeFallback' => 'cat', 'charset' => 'utf-8', 'direction' => 'ltr') 'ca' => array('language' => 'Catalan', 'locale' => 'cat', 'localeFallback' => 'cat', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('cs')); $result = $l10n->catalog(array('cs'));
$expected = array( $expected = array(
'cs' => array('language' => 'Czech', 'locale' => 'cze', 'localeFallback' => 'cze', 'charset' => 'utf-8', 'direction' => 'ltr') 'cs' => array('language' => 'Czech', 'locale' => 'cze', 'localeFallback' => 'cze', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('da')); $result = $l10n->catalog(array('da'));
$expected = array( $expected = array(
'da' => array('language' => 'Danish', 'locale' => 'dan', 'localeFallback' => 'dan', 'charset' => 'utf-8', 'direction' => 'ltr') 'da' => array('language' => 'Danish', 'locale' => 'dan', 'localeFallback' => 'dan', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('de', 'de-at', 'de-ch', 'de-de', 'de-li', 'de-lu')); $result = $l10n->catalog(array('de', 'de-at', 'de-ch', 'de-de', 'de-li', 'de-lu'));
$expected = array( $expected = array(
@ -525,14 +525,14 @@ class L10nTest extends CakeTestCase {
'de-li' => array('language' => 'German (Liechtenstein)', 'locale' => 'de_li', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), 'de-li' => array('language' => 'German (Liechtenstein)', 'locale' => 'de_li', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'),
'de-lu' => array('language' => 'German (Luxembourg)', 'locale' => 'de_lu', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr') 'de-lu' => array('language' => 'German (Luxembourg)', 'locale' => 'de_lu', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('e', 'el')); $result = $l10n->catalog(array('e', 'el'));
$expected = array( $expected = array(
'e' => array('language' => 'Greek', 'locale' => 'gre', 'localeFallback' => 'gre', 'charset' => 'utf-8', 'direction' => 'ltr'), 'e' => array('language' => 'Greek', 'locale' => 'gre', 'localeFallback' => 'gre', 'charset' => 'utf-8', 'direction' => 'ltr'),
'el' => array('language' => 'Greek', 'locale' => 'gre', 'localeFallback' => 'gre', 'charset' => 'utf-8', 'direction' => 'ltr') 'el' => array('language' => 'Greek', 'locale' => 'gre', 'localeFallback' => 'gre', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('en', 'en-au', 'en-bz', 'en-ca', 'en-gb', 'en-ie', 'en-jm', 'en-nz', 'en-tt', 'en-us', 'en-za')); $result = $l10n->catalog(array('en', 'en-au', 'en-bz', 'en-ca', 'en-gb', 'en-ie', 'en-jm', 'en-nz', 'en-tt', 'en-us', 'en-za'));
$expected = array( $expected = array(
@ -548,7 +548,7 @@ class L10nTest extends CakeTestCase {
'en-us' => array('language' => 'English (United States)', 'locale' => 'en_us', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), 'en-us' => array('language' => 'English (United States)', 'locale' => 'en_us', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'),
'en-za' => array('language' => 'English (South Africa)', 'locale' => 'en_za', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr') 'en-za' => array('language' => 'English (South Africa)', 'locale' => 'en_za', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('es', 'es-ar', 'es-bo', 'es-cl', 'es-co', 'es-cr', 'es-do', 'es-ec', 'es-es', 'es-gt', 'es-hn', $result = $l10n->catalog(array('es', 'es-ar', 'es-bo', 'es-cl', 'es-co', 'es-cr', 'es-do', 'es-ec', 'es-es', 'es-gt', 'es-hn',
'es-mx', 'es-ni', 'es-pa', 'es-pe', 'es-pr', 'es-py', 'es-sv', 'es-uy', 'es-ve')); 'es-mx', 'es-ni', 'es-pa', 'es-pe', 'es-pr', 'es-py', 'es-sv', 'es-uy', 'es-ve'));
@ -574,37 +574,37 @@ class L10nTest extends CakeTestCase {
'es-uy' => array('language' => 'Spanish (Uruguay)', 'locale' => 'es_uy', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), 'es-uy' => array('language' => 'Spanish (Uruguay)', 'locale' => 'es_uy', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'),
'es-ve' => array('language' => 'Spanish (Venezuela)', 'locale' => 'es_ve', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr') 'es-ve' => array('language' => 'Spanish (Venezuela)', 'locale' => 'es_ve', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('et')); $result = $l10n->catalog(array('et'));
$expected = array( $expected = array(
'et' => array('language' => 'Estonian', 'locale' => 'est', 'localeFallback' => 'est', 'charset' => 'utf-8', 'direction' => 'ltr') 'et' => array('language' => 'Estonian', 'locale' => 'est', 'localeFallback' => 'est', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('eu')); $result = $l10n->catalog(array('eu'));
$expected = array( $expected = array(
'eu' => array('language' => 'Basque', 'locale' => 'baq', 'localeFallback' => 'baq', 'charset' => 'utf-8', 'direction' => 'ltr') 'eu' => array('language' => 'Basque', 'locale' => 'baq', 'localeFallback' => 'baq', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('fa')); $result = $l10n->catalog(array('fa'));
$expected = array( $expected = array(
'fa' => array('language' => 'Farsi', 'locale' => 'per', 'localeFallback' => 'per', 'charset' => 'utf-8', 'direction' => 'rtl') 'fa' => array('language' => 'Farsi', 'locale' => 'per', 'localeFallback' => 'per', 'charset' => 'utf-8', 'direction' => 'rtl')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('fi')); $result = $l10n->catalog(array('fi'));
$expected = array( $expected = array(
'fi' => array('language' => 'Finnish', 'locale' => 'fin', 'localeFallback' => 'fin', 'charset' => 'utf-8', 'direction' => 'ltr') 'fi' => array('language' => 'Finnish', 'locale' => 'fin', 'localeFallback' => 'fin', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('fo')); $result = $l10n->catalog(array('fo'));
$expected = array( $expected = array(
'fo' => array('language' => 'Faeroese', 'locale' => 'fao', 'localeFallback' => 'fao', 'charset' => 'utf-8', 'direction' => 'ltr') 'fo' => array('language' => 'Faeroese', 'locale' => 'fao', 'localeFallback' => 'fao', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('fr', 'fr-be', 'fr-ca', 'fr-ch', 'fr-fr', 'fr-lu')); $result = $l10n->catalog(array('fr', 'fr-be', 'fr-ca', 'fr-ch', 'fr-fr', 'fr-lu'));
$expected = array( $expected = array(
@ -615,82 +615,82 @@ class L10nTest extends CakeTestCase {
'fr-fr' => array('language' => 'French (France)', 'locale' => 'fr_fr', 'localeFallback' => 'fre', 'charset' => 'utf-8', 'direction' => 'ltr'), 'fr-fr' => array('language' => 'French (France)', 'locale' => 'fr_fr', 'localeFallback' => 'fre', 'charset' => 'utf-8', 'direction' => 'ltr'),
'fr-lu' => array('language' => 'French (Luxembourg)', 'locale' => 'fr_lu', 'localeFallback' => 'fre', 'charset' => 'utf-8', 'direction' => 'ltr') 'fr-lu' => array('language' => 'French (Luxembourg)', 'locale' => 'fr_lu', 'localeFallback' => 'fre', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('ga')); $result = $l10n->catalog(array('ga'));
$expected = array( $expected = array(
'ga' => array('language' => 'Irish', 'locale' => 'gle', 'localeFallback' => 'gle', 'charset' => 'utf-8', 'direction' => 'ltr') 'ga' => array('language' => 'Irish', 'locale' => 'gle', 'localeFallback' => 'gle', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('gd', 'gd-ie')); $result = $l10n->catalog(array('gd', 'gd-ie'));
$expected = array( $expected = array(
'gd' => array('language' => 'Gaelic (Scots)', 'locale' => 'gla', 'localeFallback' => 'gla', 'charset' => 'utf-8', 'direction' => 'ltr'), 'gd' => array('language' => 'Gaelic (Scots)', 'locale' => 'gla', 'localeFallback' => 'gla', 'charset' => 'utf-8', 'direction' => 'ltr'),
'gd-ie' => array('language' => 'Gaelic (Irish)', 'locale' => 'gd_ie', 'localeFallback' => 'gla', 'charset' => 'utf-8', 'direction' => 'ltr') 'gd-ie' => array('language' => 'Gaelic (Irish)', 'locale' => 'gd_ie', 'localeFallback' => 'gla', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('gl')); $result = $l10n->catalog(array('gl'));
$expected = array( $expected = array(
'gl' => array('language' => 'Galician', 'locale' => 'glg', 'localeFallback' => 'glg', 'charset' => 'utf-8', 'direction' => 'ltr') 'gl' => array('language' => 'Galician', 'locale' => 'glg', 'localeFallback' => 'glg', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('he')); $result = $l10n->catalog(array('he'));
$expected = array( $expected = array(
'he' => array('language' => 'Hebrew', 'locale' => 'heb', 'localeFallback' => 'heb', 'charset' => 'utf-8', 'direction' => 'rtl') 'he' => array('language' => 'Hebrew', 'locale' => 'heb', 'localeFallback' => 'heb', 'charset' => 'utf-8', 'direction' => 'rtl')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('hi')); $result = $l10n->catalog(array('hi'));
$expected = array( $expected = array(
'hi' => array('language' => 'Hindi', 'locale' => 'hin', 'localeFallback' => 'hin', 'charset' => 'utf-8', 'direction' => 'ltr') 'hi' => array('language' => 'Hindi', 'locale' => 'hin', 'localeFallback' => 'hin', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('hr')); $result = $l10n->catalog(array('hr'));
$expected = array( $expected = array(
'hr' => array('language' => 'Croatian', 'locale' => 'hrv', 'localeFallback' => 'hrv', 'charset' => 'utf-8', 'direction' => 'ltr') 'hr' => array('language' => 'Croatian', 'locale' => 'hrv', 'localeFallback' => 'hrv', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('hu')); $result = $l10n->catalog(array('hu'));
$expected = array( $expected = array(
'hu' => array('language' => 'Hungarian', 'locale' => 'hun', 'localeFallback' => 'hun', 'charset' => 'utf-8', 'direction' => 'ltr') 'hu' => array('language' => 'Hungarian', 'locale' => 'hun', 'localeFallback' => 'hun', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('hy')); $result = $l10n->catalog(array('hy'));
$expected = array( $expected = array(
'hy' => array('language' => 'Armenian - Armenia', 'locale' => 'hye', 'localeFallback' => 'hye', 'charset' => 'utf-8', 'direction' => 'ltr') 'hy' => array('language' => 'Armenian - Armenia', 'locale' => 'hye', 'localeFallback' => 'hye', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('id', 'in')); $result = $l10n->catalog(array('id', 'in'));
$expected = array( $expected = array(
'id' => array('language' => 'Indonesian', 'locale' => 'ind', 'localeFallback' => 'ind', 'charset' => 'utf-8', 'direction' => 'ltr'), 'id' => array('language' => 'Indonesian', 'locale' => 'ind', 'localeFallback' => 'ind', 'charset' => 'utf-8', 'direction' => 'ltr'),
'in' => array('language' => 'Indonesian', 'locale' => 'ind', 'localeFallback' => 'ind', 'charset' => 'utf-8', 'direction' => 'ltr') 'in' => array('language' => 'Indonesian', 'locale' => 'ind', 'localeFallback' => 'ind', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('is')); $result = $l10n->catalog(array('is'));
$expected = array( $expected = array(
'is' => array('language' => 'Icelandic', 'locale' => 'ice', 'localeFallback' => 'ice', 'charset' => 'utf-8', 'direction' => 'ltr') 'is' => array('language' => 'Icelandic', 'locale' => 'ice', 'localeFallback' => 'ice', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('it', 'it-ch')); $result = $l10n->catalog(array('it', 'it-ch'));
$expected = array( $expected = array(
'it' => array('language' => 'Italian', 'locale' => 'ita', 'localeFallback' => 'ita', 'charset' => 'utf-8', 'direction' => 'ltr'), 'it' => array('language' => 'Italian', 'locale' => 'ita', 'localeFallback' => 'ita', 'charset' => 'utf-8', 'direction' => 'ltr'),
'it-ch' => array('language' => 'Italian (Swiss) ', 'locale' => 'it_ch', 'localeFallback' => 'ita', 'charset' => 'utf-8', 'direction' => 'ltr') 'it-ch' => array('language' => 'Italian (Swiss) ', 'locale' => 'it_ch', 'localeFallback' => 'ita', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('ja')); $result = $l10n->catalog(array('ja'));
$expected = array( $expected = array(
'ja' => array('language' => 'Japanese', 'locale' => 'jpn', 'localeFallback' => 'jpn', 'charset' => 'utf-8', 'direction' => 'ltr') 'ja' => array('language' => 'Japanese', 'locale' => 'jpn', 'localeFallback' => 'jpn', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('ko', 'ko-kp', 'ko-kr')); $result = $l10n->catalog(array('ko', 'ko-kp', 'ko-kr'));
$expected = array( $expected = array(
@ -698,7 +698,7 @@ class L10nTest extends CakeTestCase {
'ko-kp' => array('language' => 'Korea (North)', 'locale' => 'ko_kp', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr'), 'ko-kp' => array('language' => 'Korea (North)', 'locale' => 'ko_kp', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr'),
'ko-kr' => array('language' => 'Korea (South)', 'locale' => 'ko_kr', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr') 'ko-kr' => array('language' => 'Korea (South)', 'locale' => 'ko_kr', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('koi8-r', 'ru', 'ru-mo')); $result = $l10n->catalog(array('koi8-r', 'ru', 'ru-mo'));
$expected = array( $expected = array(
@ -706,38 +706,38 @@ class L10nTest extends CakeTestCase {
'ru' => array('language' => 'Russian', 'locale' => 'rus', 'localeFallback' => 'rus', 'charset' => 'utf-8', 'direction' => 'ltr'), 'ru' => array('language' => 'Russian', 'locale' => 'rus', 'localeFallback' => 'rus', 'charset' => 'utf-8', 'direction' => 'ltr'),
'ru-mo' => array('language' => 'Russian (Moldavia)', 'locale' => 'ru_mo', 'localeFallback' => 'rus', 'charset' => 'utf-8', 'direction' => 'ltr') 'ru-mo' => array('language' => 'Russian (Moldavia)', 'locale' => 'ru_mo', 'localeFallback' => 'rus', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('lt')); $result = $l10n->catalog(array('lt'));
$expected = array( $expected = array(
'lt' => array('language' => 'Lithuanian', 'locale' => 'lit', 'localeFallback' => 'lit', 'charset' => 'utf-8', 'direction' => 'ltr') 'lt' => array('language' => 'Lithuanian', 'locale' => 'lit', 'localeFallback' => 'lit', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('lv')); $result = $l10n->catalog(array('lv'));
$expected = array( $expected = array(
'lv' => array('language' => 'Latvian', 'locale' => 'lav', 'localeFallback' => 'lav', 'charset' => 'utf-8', 'direction' => 'ltr') 'lv' => array('language' => 'Latvian', 'locale' => 'lav', 'localeFallback' => 'lav', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('mk', 'mk-mk')); $result = $l10n->catalog(array('mk', 'mk-mk'));
$expected = array( $expected = array(
'mk' => array('language' => 'FYRO Macedonian', 'locale' => 'mk', 'localeFallback' => 'mac', 'charset' => 'utf-8', 'direction' => 'ltr'), 'mk' => array('language' => 'FYRO Macedonian', 'locale' => 'mk', 'localeFallback' => 'mac', 'charset' => 'utf-8', 'direction' => 'ltr'),
'mk-mk' => array('language' => 'Macedonian', 'locale' => 'mk_mk', 'localeFallback' => 'mac', 'charset' => 'utf-8', 'direction' => 'ltr') 'mk-mk' => array('language' => 'Macedonian', 'locale' => 'mk_mk', 'localeFallback' => 'mac', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('ms')); $result = $l10n->catalog(array('ms'));
$expected = array( $expected = array(
'ms' => array('language' => 'Malaysian', 'locale' => 'may', 'localeFallback' => 'may', 'charset' => 'utf-8', 'direction' => 'ltr') 'ms' => array('language' => 'Malaysian', 'locale' => 'may', 'localeFallback' => 'may', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('mt')); $result = $l10n->catalog(array('mt'));
$expected = array( $expected = array(
'mt' => array('language' => 'Maltese', 'locale' => 'mlt', 'localeFallback' => 'mlt', 'charset' => 'utf-8', 'direction' => 'ltr') 'mt' => array('language' => 'Maltese', 'locale' => 'mlt', 'localeFallback' => 'mlt', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('n', 'nl', 'nl-be')); $result = $l10n->catalog(array('n', 'nl', 'nl-be'));
$expected = array( $expected = array(
@ -745,175 +745,175 @@ class L10nTest extends CakeTestCase {
'nl' => array('language' => 'Dutch (Standard)', 'locale' => 'dut', 'localeFallback' => 'dut', 'charset' => 'utf-8', 'direction' => 'ltr'), 'nl' => array('language' => 'Dutch (Standard)', 'locale' => 'dut', 'localeFallback' => 'dut', 'charset' => 'utf-8', 'direction' => 'ltr'),
'nl-be' => array('language' => 'Dutch (Belgium)', 'locale' => 'nl_be', 'localeFallback' => 'dut', 'charset' => 'utf-8', 'direction' => 'ltr') 'nl-be' => array('language' => 'Dutch (Belgium)', 'locale' => 'nl_be', 'localeFallback' => 'dut', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog('nl'); $result = $l10n->catalog('nl');
$expected = array('language' => 'Dutch (Standard)', 'locale' => 'dut', 'localeFallback' => 'dut', 'charset' => 'utf-8', 'direction' => 'ltr'); $expected = array('language' => 'Dutch (Standard)', 'locale' => 'dut', 'localeFallback' => 'dut', 'charset' => 'utf-8', 'direction' => 'ltr');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog('nld'); $result = $l10n->catalog('nld');
$expected = array('language' => 'Dutch (Standard)', 'locale' => 'dut', 'localeFallback' => 'dut', 'charset' => 'utf-8', 'direction' => 'ltr'); $expected = array('language' => 'Dutch (Standard)', 'locale' => 'dut', 'localeFallback' => 'dut', 'charset' => 'utf-8', 'direction' => 'ltr');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog('dut'); $result = $l10n->catalog('dut');
$expected = array('language' => 'Dutch (Standard)', 'locale' => 'dut', 'localeFallback' => 'dut', 'charset' => 'utf-8', 'direction' => 'ltr'); $expected = array('language' => 'Dutch (Standard)', 'locale' => 'dut', 'localeFallback' => 'dut', 'charset' => 'utf-8', 'direction' => 'ltr');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('nb')); $result = $l10n->catalog(array('nb'));
$expected = array( $expected = array(
'nb' => array('language' => 'Norwegian Bokmal', 'locale' => 'nob', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr') 'nb' => array('language' => 'Norwegian Bokmal', 'locale' => 'nob', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('nn', 'no')); $result = $l10n->catalog(array('nn', 'no'));
$expected = array( $expected = array(
'nn' => array('language' => 'Norwegian Nynorsk', 'locale' => 'nno', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr'), 'nn' => array('language' => 'Norwegian Nynorsk', 'locale' => 'nno', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr'),
'no' => array('language' => 'Norwegian', 'locale' => 'nor', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr') 'no' => array('language' => 'Norwegian', 'locale' => 'nor', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('p', 'pl')); $result = $l10n->catalog(array('p', 'pl'));
$expected = array( $expected = array(
'p' => array('language' => 'Polish', 'locale' => 'pol', 'localeFallback' => 'pol', 'charset' => 'utf-8', 'direction' => 'ltr'), 'p' => array('language' => 'Polish', 'locale' => 'pol', 'localeFallback' => 'pol', 'charset' => 'utf-8', 'direction' => 'ltr'),
'pl' => array('language' => 'Polish', 'locale' => 'pol', 'localeFallback' => 'pol', 'charset' => 'utf-8', 'direction' => 'ltr') 'pl' => array('language' => 'Polish', 'locale' => 'pol', 'localeFallback' => 'pol', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('pt', 'pt-br')); $result = $l10n->catalog(array('pt', 'pt-br'));
$expected = array( $expected = array(
'pt' => array('language' => 'Portuguese (Portugal)', 'locale' => 'por', 'localeFallback' => 'por', 'charset' => 'utf-8', 'direction' => 'ltr'), 'pt' => array('language' => 'Portuguese (Portugal)', 'locale' => 'por', 'localeFallback' => 'por', 'charset' => 'utf-8', 'direction' => 'ltr'),
'pt-br' => array('language' => 'Portuguese (Brazil)', 'locale' => 'pt_br', 'localeFallback' => 'por', 'charset' => 'utf-8', 'direction' => 'ltr') 'pt-br' => array('language' => 'Portuguese (Brazil)', 'locale' => 'pt_br', 'localeFallback' => 'por', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('rm')); $result = $l10n->catalog(array('rm'));
$expected = array( $expected = array(
'rm' => array('language' => 'Rhaeto-Romanic', 'locale' => 'roh', 'localeFallback' => 'roh', 'charset' => 'utf-8', 'direction' => 'ltr') 'rm' => array('language' => 'Rhaeto-Romanic', 'locale' => 'roh', 'localeFallback' => 'roh', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('ro', 'ro-mo')); $result = $l10n->catalog(array('ro', 'ro-mo'));
$expected = array( $expected = array(
'ro' => array('language' => 'Romanian', 'locale' => 'rum', 'localeFallback' => 'rum', 'charset' => 'utf-8', 'direction' => 'ltr'), 'ro' => array('language' => 'Romanian', 'locale' => 'rum', 'localeFallback' => 'rum', 'charset' => 'utf-8', 'direction' => 'ltr'),
'ro-mo' => array('language' => 'Romanian (Moldavia)', 'locale' => 'ro_mo', 'localeFallback' => 'rum', 'charset' => 'utf-8', 'direction' => 'ltr') 'ro-mo' => array('language' => 'Romanian (Moldavia)', 'locale' => 'ro_mo', 'localeFallback' => 'rum', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('sb')); $result = $l10n->catalog(array('sb'));
$expected = array( $expected = array(
'sb' => array('language' => 'Sorbian', 'locale' => 'wen', 'localeFallback' => 'wen', 'charset' => 'utf-8', 'direction' => 'ltr') 'sb' => array('language' => 'Sorbian', 'locale' => 'wen', 'localeFallback' => 'wen', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('sk')); $result = $l10n->catalog(array('sk'));
$expected = array( $expected = array(
'sk' => array('language' => 'Slovak', 'locale' => 'slo', 'localeFallback' => 'slo', 'charset' => 'utf-8', 'direction' => 'ltr') 'sk' => array('language' => 'Slovak', 'locale' => 'slo', 'localeFallback' => 'slo', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('sl')); $result = $l10n->catalog(array('sl'));
$expected = array( $expected = array(
'sl' => array('language' => 'Slovenian', 'locale' => 'slv', 'localeFallback' => 'slv', 'charset' => 'utf-8', 'direction' => 'ltr') 'sl' => array('language' => 'Slovenian', 'locale' => 'slv', 'localeFallback' => 'slv', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('sq')); $result = $l10n->catalog(array('sq'));
$expected = array( $expected = array(
'sq' => array('language' => 'Albanian', 'locale' => 'alb', 'localeFallback' => 'alb', 'charset' => 'utf-8', 'direction' => 'ltr') 'sq' => array('language' => 'Albanian', 'locale' => 'alb', 'localeFallback' => 'alb', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('sr')); $result = $l10n->catalog(array('sr'));
$expected = array( $expected = array(
'sr' => array('language' => 'Serbian', 'locale' => 'scc', 'localeFallback' => 'scc', 'charset' => 'utf-8', 'direction' => 'ltr') 'sr' => array('language' => 'Serbian', 'locale' => 'scc', 'localeFallback' => 'scc', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('sv', 'sv-fi')); $result = $l10n->catalog(array('sv', 'sv-fi'));
$expected = array( $expected = array(
'sv' => array('language' => 'Swedish', 'locale' => 'swe', 'localeFallback' => 'swe', 'charset' => 'utf-8', 'direction' => 'ltr'), 'sv' => array('language' => 'Swedish', 'locale' => 'swe', 'localeFallback' => 'swe', 'charset' => 'utf-8', 'direction' => 'ltr'),
'sv-fi' => array('language' => 'Swedish (Finland)', 'locale' => 'sv_fi', 'localeFallback' => 'swe', 'charset' => 'utf-8', 'direction' => 'ltr') 'sv-fi' => array('language' => 'Swedish (Finland)', 'locale' => 'sv_fi', 'localeFallback' => 'swe', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('sx')); $result = $l10n->catalog(array('sx'));
$expected = array( $expected = array(
'sx' => array('language' => 'Sutu', 'locale' => 'sx', 'localeFallback' => 'sx', 'charset' => 'utf-8', 'direction' => 'ltr') 'sx' => array('language' => 'Sutu', 'locale' => 'sx', 'localeFallback' => 'sx', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('sz')); $result = $l10n->catalog(array('sz'));
$expected = array( $expected = array(
'sz' => array('language' => 'Sami (Lappish)', 'locale' => 'smi', 'localeFallback' => 'smi', 'charset' => 'utf-8', 'direction' => 'ltr') 'sz' => array('language' => 'Sami (Lappish)', 'locale' => 'smi', 'localeFallback' => 'smi', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('th')); $result = $l10n->catalog(array('th'));
$expected = array( $expected = array(
'th' => array('language' => 'Thai', 'locale' => 'tha', 'localeFallback' => 'tha', 'charset' => 'utf-8', 'direction' => 'ltr') 'th' => array('language' => 'Thai', 'locale' => 'tha', 'localeFallback' => 'tha', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('tn')); $result = $l10n->catalog(array('tn'));
$expected = array( $expected = array(
'tn' => array('language' => 'Tswana', 'locale' => 'tsn', 'localeFallback' => 'tsn', 'charset' => 'utf-8', 'direction' => 'ltr') 'tn' => array('language' => 'Tswana', 'locale' => 'tsn', 'localeFallback' => 'tsn', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('tr')); $result = $l10n->catalog(array('tr'));
$expected = array( $expected = array(
'tr' => array('language' => 'Turkish', 'locale' => 'tur', 'localeFallback' => 'tur', 'charset' => 'utf-8', 'direction' => 'ltr') 'tr' => array('language' => 'Turkish', 'locale' => 'tur', 'localeFallback' => 'tur', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('ts')); $result = $l10n->catalog(array('ts'));
$expected = array( $expected = array(
'ts' => array('language' => 'Tsonga', 'locale' => 'tso', 'localeFallback' => 'tso', 'charset' => 'utf-8', 'direction' => 'ltr') 'ts' => array('language' => 'Tsonga', 'locale' => 'tso', 'localeFallback' => 'tso', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('uk')); $result = $l10n->catalog(array('uk'));
$expected = array( $expected = array(
'uk' => array('language' => 'Ukrainian', 'locale' => 'ukr', 'localeFallback' => 'ukr', 'charset' => 'utf-8', 'direction' => 'ltr') 'uk' => array('language' => 'Ukrainian', 'locale' => 'ukr', 'localeFallback' => 'ukr', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('ur')); $result = $l10n->catalog(array('ur'));
$expected = array( $expected = array(
'ur' => array('language' => 'Urdu', 'locale' => 'urd', 'localeFallback' => 'urd', 'charset' => 'utf-8', 'direction' => 'rtl') 'ur' => array('language' => 'Urdu', 'locale' => 'urd', 'localeFallback' => 'urd', 'charset' => 'utf-8', 'direction' => 'rtl')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('ve')); $result = $l10n->catalog(array('ve'));
$expected = array( $expected = array(
've' => array('language' => 'Venda', 'locale' => 'ven', 'localeFallback' => 'ven', 'charset' => 'utf-8', 'direction' => 'ltr') 've' => array('language' => 'Venda', 'locale' => 'ven', 'localeFallback' => 'ven', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('vi')); $result = $l10n->catalog(array('vi'));
$expected = array( $expected = array(
'vi' => array('language' => 'Vietnamese', 'locale' => 'vie', 'localeFallback' => 'vie', 'charset' => 'utf-8', 'direction' => 'ltr') 'vi' => array('language' => 'Vietnamese', 'locale' => 'vie', 'localeFallback' => 'vie', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('cy')); $result = $l10n->catalog(array('cy'));
$expected = array( $expected = array(
'cy' => array('language' => 'Welsh', 'locale' => 'cym', 'localeFallback' => 'cym', 'charset' => 'utf-8', 'cy' => array('language' => 'Welsh', 'locale' => 'cym', 'localeFallback' => 'cym', 'charset' => 'utf-8',
'direction' => 'ltr') 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('xh')); $result = $l10n->catalog(array('xh'));
$expected = array( $expected = array(
'xh' => array('language' => 'Xhosa', 'locale' => 'xho', 'localeFallback' => 'xho', 'charset' => 'utf-8', 'direction' => 'ltr') 'xh' => array('language' => 'Xhosa', 'locale' => 'xho', 'localeFallback' => 'xho', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('yi')); $result = $l10n->catalog(array('yi'));
$expected = array( $expected = array(
'yi' => array('language' => 'Yiddish', 'locale' => 'yid', 'localeFallback' => 'yid', 'charset' => 'utf-8', 'direction' => 'ltr') 'yi' => array('language' => 'Yiddish', 'locale' => 'yid', 'localeFallback' => 'yid', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('zh', 'zh-cn', 'zh-hk', 'zh-sg', 'zh-tw')); $result = $l10n->catalog(array('zh', 'zh-cn', 'zh-hk', 'zh-sg', 'zh-tw'));
$expected = array( $expected = array(
@ -923,13 +923,13 @@ class L10nTest extends CakeTestCase {
'zh-sg' => array('language' => 'Chinese (Singapore)', 'locale' => 'zh_sg', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr'), 'zh-sg' => array('language' => 'Chinese (Singapore)', 'locale' => 'zh_sg', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr'),
'zh-tw' => array('language' => 'Chinese (Taiwan)', 'locale' => 'zh_tw', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr') 'zh-tw' => array('language' => 'Chinese (Taiwan)', 'locale' => 'zh_tw', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('zu')); $result = $l10n->catalog(array('zu'));
$expected = array( $expected = array(
'zu' => array('language' => 'Zulu', 'locale' => 'zul', 'localeFallback' => 'zul', 'charset' => 'utf-8', 'direction' => 'ltr') 'zu' => array('language' => 'Zulu', 'locale' => 'zul', 'localeFallback' => 'zul', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('en-nz', 'es-do', 'sz', 'ar-lb', 'zh-hk', 'pt-br')); $result = $l10n->catalog(array('en-nz', 'es-do', 'sz', 'ar-lb', 'zh-hk', 'pt-br'));
$expected = array( $expected = array(
@ -940,8 +940,8 @@ class L10nTest extends CakeTestCase {
'zh-hk' => array('language' => 'Chinese (Hong Kong)', 'locale' => 'zh_hk', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr'), 'zh-hk' => array('language' => 'Chinese (Hong Kong)', 'locale' => 'zh_hk', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr'),
'pt-br' => array('language' => 'Portuguese (Brazil)', 'locale' => 'pt_br', 'localeFallback' => 'por', 'charset' => 'utf-8', 'direction' => 'ltr') 'pt-br' => array('language' => 'Portuguese (Brazil)', 'locale' => 'pt_br', 'localeFallback' => 'por', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $l10n->catalog(array('eng', 'deu', 'zho', 'rum', 'zul', 'yid')); $result = $l10n->catalog(array('eng', 'deu', 'zho', 'rum', 'zul', 'yid'));
$expected = array( $expected = array(
'eng' => array('language' => 'English', 'locale' => 'eng', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), 'eng' => array('language' => 'English', 'locale' => 'eng', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'),
@ -951,6 +951,6 @@ class L10nTest extends CakeTestCase {
'zul' => array('language' => 'Zulu', 'locale' => 'zul', 'localeFallback' => 'zul', 'charset' => 'utf-8', 'direction' => 'ltr'), 'zul' => array('language' => 'Zulu', 'locale' => 'zul', 'localeFallback' => 'zul', 'charset' => 'utf-8', 'direction' => 'ltr'),
'yid' => array('language' => 'Yiddish', 'locale' => 'yid', 'localeFallback' => 'yid', 'charset' => 'utf-8', 'direction' => 'ltr') 'yid' => array('language' => 'Yiddish', 'locale' => 'yid', 'localeFallback' => 'yid', 'charset' => 'utf-8', 'direction' => 'ltr')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -35,7 +35,7 @@ class ContainableBehaviorTest extends CakeTestCase {
* @access public * @access public
*/ */
public $fixtures = array( public $fixtures = array(
'core.article', 'core.article_featured', 'core.article_featureds_tags', 'core.article', 'core.article_featured', 'core.article_featureds_tags',
'core.articles_tag', 'core.attachment', 'core.category', 'core.articles_tag', 'core.attachment', 'core.category',
'core.comment', 'core.featured', 'core.tag', 'core.user' 'core.comment', 'core.featured', 'core.tag', 'core.user'
); );
@ -131,7 +131,7 @@ class ContainableBehaviorTest extends CakeTestCase {
$result = Set::extract('/Comment/keep', $r); $result = Set::extract('/Comment/keep', $r);
$this->assertEqual(array_shift($result), array('keep' => array('User' => array()))); $this->assertEqual(array_shift($result), array('keep' => array('User' => array())));
$result = Set::extract('/Article/keep', $r); $result = Set::extract('/Article/keep', $r);
$this->assertEqual(array_shift($result), array('keep' => array('Comment' => array()))); $this->assertEqual(array_shift($result), array('keep' => array('Comment' => array())));
@ -273,7 +273,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'
)) ))
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -317,7 +317,7 @@ class ContainableBehaviorTest extends CakeTestCase {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Article->contain('User', 'Comment'); $this->Article->contain('User', 'Comment');
$result = $this->Article->find('all', array('recursive' => 1)); $result = $this->Article->find('all', array('recursive' => 1));
@ -382,7 +382,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'Comment' => array() 'Comment' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -425,7 +425,7 @@ class ContainableBehaviorTest extends CakeTestCase {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Article->find('all', array('contain' => array('User', 'Comment'))); $result = $this->Article->find('all', array('contain' => array('User', 'Comment')));
$expected = array( $expected = array(
@ -489,7 +489,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'Comment' => array() 'Comment' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -574,7 +574,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'Comment' => array() 'Comment' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Article->contain(array('User' => 'ArticleFeatured')); $this->Article->contain(array('User' => 'ArticleFeatured'));
$result = $this->Article->find('all', array('recursive' => 2)); $result = $this->Article->find('all', array('recursive' => 2));
@ -636,7 +636,7 @@ class ContainableBehaviorTest extends CakeTestCase {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Article->contain(array('User' => array('ArticleFeatured', 'Comment'))); $this->Article->contain(array('User' => array('ArticleFeatured', 'Comment')));
$result = $this->Article->find('all', array('recursive' => 2)); $result = $this->Article->find('all', array('recursive' => 2));
@ -727,7 +727,7 @@ class ContainableBehaviorTest extends CakeTestCase {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Article->contain(array('User' => array('ArticleFeatured')), 'Tag', array('Comment' => 'Attachment')); $this->Article->contain(array('User' => array('ArticleFeatured')), 'Tag', array('Comment' => 'Attachment'));
$result = $this->Article->find('all', array('recursive' => 2)); $result = $this->Article->find('all', array('recursive' => 2));
@ -836,7 +836,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'Tag' => array() 'Tag' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -920,7 +920,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'Comment' => array() 'Comment' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Article->find('all', array('contain' => array('User' => 'ArticleFeatured'))); $result = $this->Article->find('all', array('contain' => array('User' => 'ArticleFeatured')));
$expected = array( $expected = array(
@ -981,7 +981,7 @@ class ContainableBehaviorTest extends CakeTestCase {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Article->find('all', array('contain' => array('User' => array('ArticleFeatured', 'Comment')))); $result = $this->Article->find('all', array('contain' => array('User' => array('ArticleFeatured', 'Comment'))));
$expected = array( $expected = array(
@ -1071,7 +1071,7 @@ class ContainableBehaviorTest extends CakeTestCase {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Article->find('all', array('contain' => array('User' => 'ArticleFeatured', 'Tag', 'Comment' => 'Attachment'))); $result = $this->Article->find('all', array('contain' => array('User' => 'ArticleFeatured', 'Tag', 'Comment' => 'Attachment')));
$expected = array( $expected = array(
@ -1179,7 +1179,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'Tag' => array() 'Tag' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -1252,7 +1252,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'ArticleFeatured' => array() 'ArticleFeatured' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->User->contain(array('ArticleFeatured' => array('Featured' => 'Category', 'Comment' => array('Article', 'Attachment')))); $this->User->contain(array('ArticleFeatured' => array('Featured' => 'Category', 'Comment' => array('Article', 'Attachment'))));
$result = $this->User->find('all', array('recursive' => 3)); $result = $this->User->find('all', array('recursive' => 3));
@ -1379,7 +1379,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'ArticleFeatured' => array() 'ArticleFeatured' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->User->contain(array('ArticleFeatured' => array('Featured' => 'Category', 'Comment' => 'Attachment'), 'Article')); $this->User->contain(array('ArticleFeatured' => array('Featured' => 'Category', 'Comment' => 'Attachment'), 'Article'));
$result = $this->User->find('all', array('recursive' => 3)); $result = $this->User->find('all', array('recursive' => 3));
@ -1500,7 +1500,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'ArticleFeatured' => array() 'ArticleFeatured' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -1572,7 +1572,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'ArticleFeatured' => array() 'ArticleFeatured' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->User->find('all', array('contain' => array('ArticleFeatured' => array('Featured' => 'Category', 'Comment' => array('Article', 'Attachment'))))); $result = $this->User->find('all', array('contain' => array('ArticleFeatured' => array('Featured' => 'Category', 'Comment' => array('Article', 'Attachment')))));
$expected = array( $expected = array(
@ -1698,7 +1698,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'ArticleFeatured' => array() 'ArticleFeatured' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->User->find('all', array('contain' => array('ArticleFeatured' => array('Featured' => 'Category', 'Comment' => 'Attachment'), 'Article'))); $result = $this->User->find('all', array('contain' => array('ArticleFeatured' => array('Featured' => 'Category', 'Comment' => 'Attachment'), 'Article')));
$expected = array( $expected = array(
@ -1818,7 +1818,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'ArticleFeatured' => array() 'ArticleFeatured' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -1888,7 +1888,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'ArticleFeatured' => array() 'ArticleFeatured' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$r = $this->User->find('all', array('contain' => array( $r = $this->User->find('all', array('contain' => array(
'ArticleFeatured' => array( 'ArticleFeatured' => array(
@ -1994,7 +1994,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'ArticleFeatured' => array() 'ArticleFeatured' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$orders = array( $orders = array(
'title DESC', 'title DESC, published DESC', 'title DESC', 'title DESC, published DESC',
@ -2064,7 +2064,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'ArticleFeatured' => array() 'ArticleFeatured' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
} }
@ -2138,7 +2138,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'ArticleFeatured' => array() 'ArticleFeatured' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->User->resetBindings(); $this->User->resetBindings();
@ -2267,7 +2267,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'ArticleFeatured' => array() 'ArticleFeatured' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->User->resetBindings(); $this->User->resetBindings();
@ -2390,7 +2390,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'ArticleFeatured' => array() 'ArticleFeatured' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -2462,7 +2462,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'ArticleFeatured' => array() 'ArticleFeatured' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->__assertBindings($this->User, array('hasMany' => array('ArticleFeatured'))); $this->__assertBindings($this->User, array('hasMany' => array('ArticleFeatured')));
$this->__assertBindings($this->User->ArticleFeatured, array('hasOne' => array('Featured'))); $this->__assertBindings($this->User->ArticleFeatured, array('hasOne' => array('Featured')));
@ -2599,7 +2599,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'ArticleFeatured' => array() 'ArticleFeatured' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->__assertBindings($this->User, array('hasMany' => array('ArticleFeatured'))); $this->__assertBindings($this->User, array('hasMany' => array('ArticleFeatured')));
$this->__assertBindings($this->User->ArticleFeatured, array('hasOne' => array('Featured'), 'hasMany' => array('Comment'))); $this->__assertBindings($this->User->ArticleFeatured, array('hasOne' => array('Featured'), 'hasMany' => array('Comment')));
@ -2736,7 +2736,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'ArticleFeatured' => array() 'ArticleFeatured' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->__assertBindings($this->User, array('hasMany' => array('ArticleFeatured'))); $this->__assertBindings($this->User, array('hasMany' => array('ArticleFeatured')));
$this->__assertBindings($this->User->ArticleFeatured, array('hasOne' => array('Featured'), 'hasMany' => array('Comment'))); $this->__assertBindings($this->User->ArticleFeatured, array('hasOne' => array('Featured'), 'hasMany' => array('Comment')));
@ -2867,7 +2867,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'ArticleFeatured' => array() 'ArticleFeatured' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->__assertBindings($this->User, array('hasMany' => array('Article', 'ArticleFeatured'))); $this->__assertBindings($this->User, array('hasMany' => array('Article', 'ArticleFeatured')));
$this->__assertBindings($this->User->Article); $this->__assertBindings($this->User->Article);
@ -2899,7 +2899,7 @@ class ContainableBehaviorTest extends CakeTestCase {
array('Article' => array('title' => 'Second Article'), 'User' => array('user' => 'larry', 'id' => 3)), array('Article' => array('title' => 'Second Article'), 'User' => array('user' => 'larry', 'id' => 3)),
array('Article' => array('title' => 'Third Article'), 'User' => array('user' => 'mariano', 'id' => 1)), array('Article' => array('title' => 'Third Article'), 'User' => array('user' => 'mariano', 'id' => 1)),
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Article->find('all', array( $result = $this->Article->find('all', array(
'contain' => array('User(id, user)'), 'contain' => array('User(id, user)'),
@ -2910,7 +2910,7 @@ class ContainableBehaviorTest extends CakeTestCase {
array('Article' => array('title' => 'Second Article'), 'User' => array('user' => 'larry', 'id' => 3)), array('Article' => array('title' => 'Second Article'), 'User' => array('user' => 'larry', 'id' => 3)),
array('Article' => array('title' => 'Third Article'), 'User' => array('user' => 'mariano', 'id' => 1)), array('Article' => array('title' => 'Third Article'), 'User' => array('user' => 'mariano', 'id' => 1)),
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Article->find('all', array( $result = $this->Article->find('all', array(
'contain' => array( 'contain' => array(
@ -2952,7 +2952,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'Comment' => array() 'Comment' => array()
), ),
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -3019,7 +3019,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'Tag' => array() 'Tag' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Article->contain(array('User(id,user)', 'Tag' => array('fields' => array('tag', 'created')))); $this->Article->contain(array('User(id,user)', 'Tag' => array('fields' => array('tag', 'created'))));
$result = $this->Article->find('all', array('fields' => array('title'))); $result = $this->Article->find('all', array('fields' => array('title')));
@ -3046,7 +3046,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'Tag' => array() 'Tag' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Article->find('all', array( $result = $this->Article->find('all', array(
'fields' => array('title'), 'fields' => array('title'),
@ -3075,7 +3075,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'Tag' => array() 'Tag' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Article->contain(array( $this->Article->contain(array(
'User(id,user)', 'User(id,user)',
@ -3102,7 +3102,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'Tag' => array() 'Tag' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertTrue(empty($this->User->Article->hasAndBelongsToMany['Tag']['conditions'])); $this->assertTrue(empty($this->User->Article->hasAndBelongsToMany['Tag']['conditions']));
@ -3136,15 +3136,15 @@ class ContainableBehaviorTest extends CakeTestCase {
function testOtherFinds() { function testOtherFinds() {
$result = $this->Article->find('count'); $result = $this->Article->find('count');
$expected = 3; $expected = 3;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Article->find('count', array('conditions' => array('Article.id >' => '1'))); $result = $this->Article->find('count', array('conditions' => array('Article.id >' => '1')));
$expected = 2; $expected = 2;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Article->find('count', array('contain' => array())); $result = $this->Article->find('count', array('contain' => array()));
$expected = 3; $expected = 3;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Article->contain(array('User(id,user)', 'Tag' => array('fields' => array('tag', 'created'), 'conditions' => array('created >=' => '2007-03-18 12:24')))); $this->Article->contain(array('User(id,user)', 'Tag' => array('fields' => array('tag', 'created'), 'conditions' => array('created >=' => '2007-03-18 12:24'))));
$result = $this->Article->find('first', array('fields' => array('title'))); $result = $this->Article->find('first', array('fields' => array('title')));
@ -3153,7 +3153,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'User' => array('id' => 1, 'user' => 'mariano'), 'User' => array('id' => 1, 'user' => 'mariano'),
'Tag' => array(array('tag' => 'tag2', 'created' => '2007-03-18 12:24:23')) 'Tag' => array(array('tag' => 'tag2', 'created' => '2007-03-18 12:24:23'))
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Article->contain(array('User(id,user)', 'Tag' => array('fields' => array('tag', 'created')))); $this->Article->contain(array('User(id,user)', 'Tag' => array('fields' => array('tag', 'created'))));
$result = $this->Article->find('first', array('fields' => array('title'))); $result = $this->Article->find('first', array('fields' => array('title')));
@ -3165,7 +3165,7 @@ class ContainableBehaviorTest extends CakeTestCase {
array('tag' => 'tag2', 'created' => '2007-03-18 12:24:23') array('tag' => 'tag2', 'created' => '2007-03-18 12:24:23')
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Article->find('first', array( $result = $this->Article->find('first', array(
'fields' => array('title'), 'fields' => array('title'),
@ -3177,7 +3177,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'User' => array('id' => 1, 'user' => 'mariano'), 'User' => array('id' => 1, 'user' => 'mariano'),
'Tag' => array() 'Tag' => array()
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Article->find('list', array( $result = $this->Article->find('list', array(
'contain' => array('User(id,user)'), 'contain' => array('User(id,user)'),
@ -3188,7 +3188,7 @@ class ContainableBehaviorTest extends CakeTestCase {
2 => 'Second Article', 2 => 'Second Article',
3 => 'Third Article' 3 => 'Third Article'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -3248,7 +3248,7 @@ class ContainableBehaviorTest extends CakeTestCase {
array('comment' => 'Fourth Comment for First Article', 'article_id' => 1) array('comment' => 'Fourth Comment for First Article', 'article_id' => 1)
) )
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Article->find('all', array('fields' => array('title', 'User.id', 'User.user'), 'limit' => 1, 'page' => 2, 'order' => 'Article.id ASC')); $result = $this->Article->find('all', array('fields' => array('title', 'User.id', 'User.user'), 'limit' => 1, 'page' => 2, 'order' => 'Article.id ASC'));
$expected = array(array( $expected = array(array(
@ -3259,7 +3259,7 @@ class ContainableBehaviorTest extends CakeTestCase {
array('comment' => 'Second Comment for Second Article', 'article_id' => 2) array('comment' => 'Second Comment for Second Article', 'article_id' => 2)
) )
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Article->find('all', array('fields' => array('title', 'User.id', 'User.user'), 'limit' => 1, 'page' => 3, 'order' => 'Article.id ASC')); $result = $this->Article->find('all', array('fields' => array('title', 'User.id', 'User.user'), 'limit' => 1, 'page' => 3, 'order' => 'Article.id ASC'));
$expected = array(array( $expected = array(array(
@ -3267,7 +3267,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'User' => array('id' => 1, 'user' => 'mariano'), 'User' => array('id' => 1, 'user' => 'mariano'),
'Comment' => array() 'Comment' => array()
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Article->contain(false, array('User' => array('fields' => 'user'), 'Comment')); $this->Article->contain(false, array('User' => array('fields' => 'user'), 'Comment'));
$result = $this->Article->find('all'); $result = $this->Article->find('all');

View file

@ -107,7 +107,7 @@ class TranslateBehaviorTest extends CakeTestCase {
$result = $TestModel->read(null, 1); $result = $TestModel->read(null, 1);
$expected = array('TranslatedItem' => array('id' => 1, 'slug' => 'first_translated')); $expected = array('TranslatedItem' => array('id' => 1, 'slug' => 'first_translated'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('all', array('fields' => array('slug'))); $result = $TestModel->find('all', array('fields' => array('slug')));
$expected = array( $expected = array(
@ -115,7 +115,7 @@ class TranslateBehaviorTest extends CakeTestCase {
array('TranslatedItem' => array('slug' => 'second_translated')), array('TranslatedItem' => array('slug' => 'second_translated')),
array('TranslatedItem' => array('slug' => 'third_translated')) array('TranslatedItem' => array('slug' => 'third_translated'))
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -147,7 +147,7 @@ class TranslateBehaviorTest extends CakeTestCase {
array('id' => 6, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Obsah #1') array('id' => 6, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Obsah #1')
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->hasMany['Title']['fields'] = $TestModel->hasMany['Content']['fields'] = array('content'); $TestModel->hasMany['Title']['fields'] = $TestModel->hasMany['Content']['fields'] = array('content');
$TestModel->hasMany['Title']['conditions']['locale'] = $TestModel->hasMany['Content']['conditions']['locale'] = 'eng'; $TestModel->hasMany['Title']['conditions']['locale'] = $TestModel->hasMany['Content']['conditions']['locale'] = 'eng';
@ -170,7 +170,7 @@ class TranslateBehaviorTest extends CakeTestCase {
'Content' => array(array('foreign_key' => 3, 'content' => 'Content #3')) 'Content' => array(array('foreign_key' => 3, 'content' => 'Content #3'))
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -195,7 +195,7 @@ class TranslateBehaviorTest extends CakeTestCase {
'content' => 'Content #1' 'content' => 'Content #1'
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('all'); $result = $TestModel->find('all');
$expected = array( $expected = array(
@ -227,7 +227,7 @@ class TranslateBehaviorTest extends CakeTestCase {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -253,7 +253,7 @@ class TranslateBehaviorTest extends CakeTestCase {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('all', array('conditions' => "TranslatedItem.slug = 'first_translated'")); $result = $TestModel->find('all', array('conditions' => "TranslatedItem.slug = 'first_translated'"));
$expected = array( $expected = array(
@ -267,7 +267,7 @@ class TranslateBehaviorTest extends CakeTestCase {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -305,7 +305,7 @@ class TranslateBehaviorTest extends CakeTestCase {
array('id' => 6, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Obsah #1') array('id' => 6, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Obsah #1')
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->hasMany['Title']['fields'] = $TestModel->hasMany['Content']['fields'] = array('content'); $TestModel->hasMany['Title']['fields'] = $TestModel->hasMany['Content']['fields'] = array('content');
$TestModel->hasMany['Title']['conditions']['locale'] = $TestModel->hasMany['Content']['conditions']['locale'] = 'eng'; $TestModel->hasMany['Title']['conditions']['locale'] = $TestModel->hasMany['Content']['conditions']['locale'] = 'eng';
@ -328,7 +328,7 @@ class TranslateBehaviorTest extends CakeTestCase {
'Content' => array(array('foreign_key' => 3, 'content' => 'Content #3')) 'Content' => array(array('foreign_key' => 3, 'content' => 'Content #3'))
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -354,7 +354,7 @@ class TranslateBehaviorTest extends CakeTestCase {
'content' => 'Inhalt #1' 'content' => 'Inhalt #1'
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('all', array('fields' => array('slug', 'title', 'content'))); $result = $TestModel->find('all', array('fields' => array('slug', 'title', 'content')));
$expected = array( $expected = array(
@ -384,7 +384,7 @@ class TranslateBehaviorTest extends CakeTestCase {
) )
); );
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
} }
/** /**
@ -412,7 +412,7 @@ class TranslateBehaviorTest extends CakeTestCase {
'content' => '' 'content' => ''
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -429,7 +429,7 @@ class TranslateBehaviorTest extends CakeTestCase {
$TestModel->displayField = 'title'; $TestModel->displayField = 'title';
$result = $TestModel->find('list', array('recursive' => 1)); $result = $TestModel->find('list', array('recursive' => 1));
$expected = array(1 => 'Titel #1', 2 => 'Titel #2', 3 => 'Titel #3'); $expected = array(1 => 'Titel #1', 2 => 'Titel #2', 3 => 'Titel #3');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
// MSSQL trigger an error and stops the page even if the debug = 0 // MSSQL trigger an error and stops the page even if the debug = 0
if ($this->db instanceof Mssql) { if ($this->db instanceof Mssql) {
@ -446,7 +446,7 @@ class TranslateBehaviorTest extends CakeTestCase {
$result = $TestModel->find('list', array('recursive' => 1, 'callbacks' => 'before')); $result = $TestModel->find('list', array('recursive' => 1, 'callbacks' => 'before'));
$expected = array(1 => null, 2 => null, 3 => null); $expected = array(1 => null, 2 => null, 3 => null);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -466,10 +466,10 @@ class TranslateBehaviorTest extends CakeTestCase {
array('TranslatedItem' => array('slug' => 'second_translated', 'locale' => 'eng', 'content' => 'Content #2')), array('TranslatedItem' => array('slug' => 'second_translated', 'locale' => 'eng', 'content' => 'Content #2')),
array('TranslatedItem' => array('slug' => 'third_translated', 'locale' => 'eng', 'content' => 'Content #3')) array('TranslatedItem' => array('slug' => 'third_translated', 'locale' => 'eng', 'content' => 'Content #3'))
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('all', array('fields' => array('TranslatedItem.slug', 'content'))); $result = $TestModel->find('all', array('fields' => array('TranslatedItem.slug', 'content')));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->locale = array('eng', 'deu', 'cze'); $TestModel->locale = array('eng', 'deu', 'cze');
$delete = array(array('locale' => 'deu'), array('field' => 'content', 'locale' => 'eng')); $delete = array(array('locale' => 'deu'), array('field' => 'content', 'locale' => 'eng'));
@ -482,7 +482,7 @@ class TranslateBehaviorTest extends CakeTestCase {
array('TranslatedItem' => array('locale' => 'eng', 'title' => 'Title #2', 'content' => 'Obsah #2')), array('TranslatedItem' => array('locale' => 'eng', 'title' => 'Title #2', 'content' => 'Obsah #2')),
array('TranslatedItem' => array('locale' => 'eng', 'title' => 'Title #3', 'content' => 'Obsah #3')) array('TranslatedItem' => array('locale' => 'eng', 'title' => 'Title #3', 'content' => 'Obsah #3'))
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -501,7 +501,7 @@ class TranslateBehaviorTest extends CakeTestCase {
$TestModel->save(); $TestModel->save();
$result = $TestModel->read(); $result = $TestModel->read();
$expected = array('TranslatedItem' => array_merge($data, array('id' => $TestModel->id, 'locale' => 'spa'))); $expected = array('TranslatedItem' => array_merge($data, array('id' => $TestModel->id, 'locale' => 'spa')));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -524,7 +524,7 @@ class TranslateBehaviorTest extends CakeTestCase {
$TestModel->save(); $TestModel->save();
$result = $TestModel->read(null, $id); $result = $TestModel->read(null, $id);
$expected = array('TranslatedItem' => array_merge($oldData, $newData, array('locale' => 'spa'))); $expected = array('TranslatedItem' => array_merge($oldData, $newData, array('locale' => 'spa')));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -563,7 +563,7 @@ class TranslateBehaviorTest extends CakeTestCase {
array('id' => 20, 'locale' => 'spa', 'model' => 'TranslatedItem', 'foreign_key' => 4, 'field' => 'content', 'content' => 'Nuevo contenido') array('id' => 20, 'locale' => 'spa', 'model' => 'TranslatedItem', 'foreign_key' => 4, 'field' => 'content', 'content' => 'Nuevo contenido')
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -603,7 +603,7 @@ class TranslateBehaviorTest extends CakeTestCase {
array('id' => 6, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Novy Obsah #1') array('id' => 6, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Novy Obsah #1')
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->unbindTranslation($translations); $TestModel->unbindTranslation($translations);
$TestModel->bindTranslation(array('title', 'content'), false); $TestModel->bindTranslation(array('title', 'content'), false);
@ -648,7 +648,7 @@ class TranslateBehaviorTest extends CakeTestCase {
array('id' => 6, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Upraveny obsah #1') array('id' => 6, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Upraveny obsah #1')
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -701,12 +701,12 @@ class TranslateBehaviorTest extends CakeTestCase {
$result = array_keys($TestModel->hasMany); $result = array_keys($TestModel->hasMany);
$expected = array('Title', 'Content'); $expected = array('Title', 'Content');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->Behaviors->detach('Translate'); $TestModel->Behaviors->detach('Translate');
$result = array_keys($TestModel->hasMany); $result = array_keys($TestModel->hasMany);
$expected = array(); $expected = array();
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = isset($TestModel->Behaviors->Translate); $result = isset($TestModel->Behaviors->Translate);
$this->assertFalse($result); $this->assertFalse($result);
@ -720,7 +720,7 @@ class TranslateBehaviorTest extends CakeTestCase {
$TestModel->Behaviors->attach('Translate', array('title' => 'Title', 'content' => 'Content')); $TestModel->Behaviors->attach('Translate', array('title' => 'Title', 'content' => 'Content'));
$result = array_keys($TestModel->hasMany); $result = array_keys($TestModel->hasMany);
$expected = array('Title', 'Content'); $expected = array('Title', 'Content');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = isset($TestModel->Behaviors->Translate); $result = isset($TestModel->Behaviors->Translate);
$this->assertTrue($result); $this->assertTrue($result);
@ -755,7 +755,7 @@ class TranslateBehaviorTest extends CakeTestCase {
'content' => 'Another Content #1' 'content' => 'Another Content #1'
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -791,7 +791,7 @@ class TranslateBehaviorTest extends CakeTestCase {
'updated' => '2007-03-17 01:18:31' 'updated' => '2007-03-17 01:18:31'
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('all', array('recursive' => -1)); $result = $TestModel->find('all', array('recursive' => -1));
$expected = array( $expected = array(
@ -832,7 +832,7 @@ class TranslateBehaviorTest extends CakeTestCase {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertEqual($TestModel->recursive, $recursive); $this->assertEqual($TestModel->recursive, $recursive);
$TestModel->recursive = -1; $TestModel->recursive = -1;
@ -849,7 +849,7 @@ class TranslateBehaviorTest extends CakeTestCase {
'body' => 'Body (eng) #1' 'body' => 'Body (eng) #1'
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
* testTranslateTableWithPrefix method * testTranslateTableWithPrefix method
@ -870,7 +870,7 @@ class TranslateBehaviorTest extends CakeTestCase {
'content' => 'Content #1', 'content' => 'Content #1',
'title' => 'Title #1' 'title' => 'Title #1'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**

View file

@ -69,7 +69,7 @@ class TreeBehaviorAfterTest extends CakeTestCase {
$expected = array('AfterTree' => array('name' => 'Six and One Half Changed in AfterTree::afterSave() but not in database', 'parent_id' => 6, 'lft' => 11, 'rght' => 12)); $expected = array('AfterTree' => array('name' => 'Six and One Half Changed in AfterTree::afterSave() but not in database', 'parent_id' => 6, 'lft' => 11, 'rght' => 12));
$result = $this->Tree->save(array('AfterTree' => array('name' => 'Six and One Half', 'parent_id' => 6))); $result = $this->Tree->save(array('AfterTree' => array('name' => 'Six and One Half', 'parent_id' => 6)));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$expected = array('AfterTree' => array('name' => 'Six and One Half', 'parent_id' => 6, 'lft' => 11, 'rght' => 12, 'id' => 8)); $expected = array('AfterTree' => array('name' => 'Six and One Half', 'parent_id' => 6, 'lft' => 11, 'rght' => 12, 'id' => 8));
$result = $this->Tree->find('all'); $result = $this->Tree->find('all');

View file

@ -292,7 +292,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->save(array($modelClass => array('name' => 'testAddOrphan', $parentField => null))); $this->Tree->save(array($modelClass => array('name' => 'testAddOrphan', $parentField => null)));
$result = $this->Tree->find('first', array('fields' => array('name', $parentField), 'order' => $modelClass . '.' . $leftField . ' desc')); $result = $this->Tree->find('first', array('fields' => array('name', $parentField), 'order' => $modelClass . '.' . $leftField . ' desc'));
$expected = array($modelClass => array('name' => 'testAddOrphan', $parentField => null)); $expected = array($modelClass => array('name' => 'testAddOrphan', $parentField => null));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$validTree = $this->Tree->verify(); $validTree = $this->Tree->verify();
$this->assertIdentical($validTree, true); $this->assertIdentical($validTree, true);
@ -315,7 +315,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->create(); $this->Tree->create();
$result = $this->Tree->save(array($modelClass => array('name' => 'testAddMiddle', $parentField => $data[$modelClass]['id']))); $result = $this->Tree->save(array($modelClass => array('name' => 'testAddMiddle', $parentField => $data[$modelClass]['id'])));
$expected = array_merge(array($modelClass => array('name' => 'testAddMiddle', $parentField => '2')), $result); $expected = array_merge(array($modelClass => array('name' => 'testAddMiddle', $parentField => '2')), $result);
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$laterCount = $this->Tree->find('count'); $laterCount = $this->Tree->find('count');
@ -371,7 +371,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->save(array('name' => 'testAddNotIndexed', $parentField => null)); $this->Tree->save(array('name' => 'testAddNotIndexed', $parentField => null));
$result = $this->Tree->find('first', array('fields' => array('name', $parentField), 'order' => $modelClass . '.' . $leftField . ' desc')); $result = $this->Tree->find('first', array('fields' => array('name', $parentField), 'order' => $modelClass . '.' . $leftField . ' desc'));
$expected = array($modelClass => array('name' => 'testAddNotIndexed', $parentField => null)); $expected = array($modelClass => array('name' => 'testAddNotIndexed', $parentField => null));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$validTree = $this->Tree->verify(); $validTree = $this->Tree->verify();
$this->assertIdentical($validTree, true); $this->assertIdentical($validTree, true);
@ -428,7 +428,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$expected = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 5)), $expected = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 5)),
array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 6, $rightField => 11)), array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 6, $rightField => 11)),
array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 1, $leftField => 12, $rightField => 13))); array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 1, $leftField => 12, $rightField => 13)));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertTrue($this->Tree->verify()); $this->assertTrue($this->Tree->verify());
} }
@ -616,7 +616,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$result = $this->Tree->children(null, true, array('name')); $result = $this->Tree->children(null, true, array('name'));
$expected = array(array($modelClass => array('name' => '1.2', )), $expected = array(array($modelClass => array('name' => '1.2', )),
array($modelClass => array('name' => '1.1', ))); array($modelClass => array('name' => '1.1', )));
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
} }
/** /**
@ -639,7 +639,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$result = $this->Tree->children(null, true, array('name')); $result = $this->Tree->children(null, true, array('name'));
$expected = array(array($modelClass => array('name' => '1.1', )), $expected = array(array($modelClass => array('name' => '1.1', )),
array($modelClass => array('name' => '1.2', ))); array($modelClass => array('name' => '1.2', )));
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
} }
/** /**
@ -670,7 +670,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
array($modelClass => array('name' => '1.8', )), array($modelClass => array('name' => '1.8', )),
array($modelClass => array('name' => '1.9', )), array($modelClass => array('name' => '1.9', )),
array($modelClass => array('name' => '1.10', ))); array($modelClass => array('name' => '1.10', )));
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
} }
/** /**
@ -701,7 +701,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
array($modelClass => array('name' => '1.8', )), array($modelClass => array('name' => '1.8', )),
array($modelClass => array('name' => '1.9', )), array($modelClass => array('name' => '1.9', )),
array($modelClass => array('name' => '1.10', ))); array($modelClass => array('name' => '1.10', )));
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
} }
/** /**
@ -723,7 +723,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$result = $this->Tree->children(null, true, array('name')); $result = $this->Tree->children(null, true, array('name'));
$expected = array(array($modelClass => array('name' => '1.2', )), $expected = array(array($modelClass => array('name' => '1.2', )),
array($modelClass => array('name' => '1.1', ))); array($modelClass => array('name' => '1.1', )));
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
} }
/** /**
@ -745,7 +745,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$result = $this->Tree->children(null, true, array('name')); $result = $this->Tree->children(null, true, array('name'));
$expected = array(array($modelClass => array('name' => '1.1', )), $expected = array(array($modelClass => array('name' => '1.1', )),
array($modelClass => array('name' => '1.2', ))); array($modelClass => array('name' => '1.2', )));
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
} }
/** /**
@ -776,7 +776,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
array($modelClass => array('name' => '1.9', )), array($modelClass => array('name' => '1.9', )),
array($modelClass => array('name' => '1.10', )), array($modelClass => array('name' => '1.10', )),
array($modelClass => array('name' => '1.5', ))); array($modelClass => array('name' => '1.5', )));
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
} }
/** /**
@ -807,7 +807,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
array($modelClass => array('name' => '1.8', )), array($modelClass => array('name' => '1.8', )),
array($modelClass => array('name' => '1.9', )), array($modelClass => array('name' => '1.9', )),
array($modelClass => array('name' => '1.10', ))); array($modelClass => array('name' => '1.10', )));
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
} }
/** /**
@ -838,7 +838,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
array($modelClass => array('name' => '1.8', )), array($modelClass => array('name' => '1.8', )),
array($modelClass => array('name' => '1.9', )), array($modelClass => array('name' => '1.9', )),
array($modelClass => array('name' => '1.10', ))); array($modelClass => array('name' => '1.10', )));
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
} }
/** /**
@ -863,7 +863,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$result = $this->Tree->find('all', array('fields' => 'name', 'order' => $modelClass . '.' . $leftField . ' ASC')); $result = $this->Tree->find('all', array('fields' => 'name', 'order' => $modelClass . '.' . $leftField . ' ASC'));
$expected = array(array($modelClass => array('name' => '1.1')), $expected = array(array($modelClass => array('name' => '1.1')),
array($modelClass => array('name' => '1. Root'))); array($modelClass => array('name' => '1. Root')));
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
} }
/** /**
@ -1257,7 +1257,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$result = $this->Tree->generateTreeList(); $result = $this->Tree->generateTreeList();
$expected = array(1 => '1. Root', 2 => '_1.1', 3 => '__1.1.1', 4 => '__1.1.2', 5 => '_1.2', 6 => '__1.2.1', 7 => '__1.2.2'); $expected = array(1 => '1. Root', 2 => '_1.1', 3 => '__1.1.1', 4 => '__1.1.2', 5 => '_1.2', 6 => '__1.2.1', 7 => '__1.2.2');
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
} }
/** /**

View file

@ -80,7 +80,7 @@ class TreeBehaviorScopedTest extends CakeTestCase {
array('FlagTree' => array('id' => '4', 'name' => '1.1.2', 'parent_id' => '2', 'lft' => '5', 'rght' => '6', 'flag' => '0')), array('FlagTree' => array('id' => '4', 'name' => '1.1.2', 'parent_id' => '2', 'lft' => '5', 'rght' => '6', 'flag' => '0')),
array('FlagTree' => array('id' => '5', 'name' => '1.1.3', 'parent_id' => '2', 'lft' => '7', 'rght' => '8', 'flag' => '0')) array('FlagTree' => array('id' => '5', 'name' => '1.1.3', 'parent_id' => '2', 'lft' => '7', 'rght' => '8', 'flag' => '0'))
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Tree->Behaviors->attach('Tree', array('scope' => 'FlagTree.flag = 1')); $this->Tree->Behaviors->attach('Tree', array('scope' => 'FlagTree.flag = 1'));
$this->assertEqual($this->Tree->children(), array()); $this->assertEqual($this->Tree->children(), array());
@ -90,7 +90,7 @@ class TreeBehaviorScopedTest extends CakeTestCase {
$result = $this->Tree->children(); $result = $this->Tree->children();
$expected = array(array('FlagTree' => array('id' => '2', 'name' => '1.1', 'parent_id' => '1', 'lft' => '2', 'rght' => '9', 'flag' => '1'))); $expected = array(array('FlagTree' => array('id' => '2', 'name' => '1.1', 'parent_id' => '1', 'lft' => '2', 'rght' => '9', 'flag' => '1')));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertTrue($this->Tree->delete()); $this->assertTrue($this->Tree->delete());
$this->assertEqual($this->Tree->find('count'), 11); $this->assertEqual($this->Tree->find('count'), 11);
@ -117,7 +117,7 @@ class TreeBehaviorScopedTest extends CakeTestCase {
array('FlagTree' => array('id' => '4', 'name' => '1.1.2', 'parent_id' => '2', 'lft' => '5', 'rght' => '6', 'flag' => '0')), array('FlagTree' => array('id' => '4', 'name' => '1.1.2', 'parent_id' => '2', 'lft' => '5', 'rght' => '6', 'flag' => '0')),
array('FlagTree' => array('id' => '5', 'name' => '1.1.3', 'parent_id' => '2', 'lft' => '7', 'rght' => '8', 'flag' => '0')) array('FlagTree' => array('id' => '5', 'name' => '1.1.3', 'parent_id' => '2', 'lft' => '7', 'rght' => '8', 'flag' => '0'))
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Tree->Behaviors->attach('Tree', array('scope' => array('FlagTree.flag' => 1))); $this->Tree->Behaviors->attach('Tree', array('scope' => array('FlagTree.flag' => 1)));
$this->assertEqual($this->Tree->children(), array()); $this->assertEqual($this->Tree->children(), array());
@ -127,7 +127,7 @@ class TreeBehaviorScopedTest extends CakeTestCase {
$result = $this->Tree->children(); $result = $this->Tree->children();
$expected = array(array('FlagTree' => array('id' => '2', 'name' => '1.1', 'parent_id' => '1', 'lft' => '2', 'rght' => '9', 'flag' => '1'))); $expected = array(array('FlagTree' => array('id' => '2', 'name' => '1.1', 'parent_id' => '1', 'lft' => '2', 'rght' => '9', 'flag' => '1')));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertTrue($this->Tree->delete()); $this->assertTrue($this->Tree->delete());
$this->assertEqual($this->Tree->find('count'), 11); $this->assertEqual($this->Tree->find('count'), 11);
@ -197,7 +197,7 @@ class TreeBehaviorScopedTest extends CakeTestCase {
'flag' => 0, 'flag' => 0,
'locale' => 'eng', 'locale' => 'eng',
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
//update existing record, same locale //update existing record, same locale
$this->Tree->create(); $this->Tree->create();
@ -214,7 +214,7 @@ class TreeBehaviorScopedTest extends CakeTestCase {
'flag' => 0, 'flag' => 0,
'locale' => 'eng', 'locale' => 'eng',
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
//update different locale, same record //update different locale, same record
$this->Tree->create(); $this->Tree->create();
@ -239,7 +239,7 @@ class TreeBehaviorScopedTest extends CakeTestCase {
'flag' => 0, 'flag' => 0,
'locale' => 'deu', 'locale' => 'deu',
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
//Save with bindTranslation //Save with bindTranslation
$this->Tree->locale = 'eng'; $this->Tree->locale = 'eng';
@ -263,7 +263,7 @@ class TreeBehaviorScopedTest extends CakeTestCase {
array('id' => 22, 'locale' => 'spa', 'model' => 'FlagTree', 'foreign_key' => 2, 'field' => 'name', 'content' => 'Nuevo leyenda') array('id' => 22, 'locale' => 'spa', 'model' => 'FlagTree', 'foreign_key' => 2, 'field' => 'name', 'content' => 'Nuevo leyenda')
), ),
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -319,6 +319,6 @@ class TreeBehaviorScopedTest extends CakeTestCase {
'lft' => 1, 'lft' => 1,
'rght' => 2 'rght' => 2
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
} }

View file

@ -108,7 +108,7 @@ class TreeBehaviorUuidTest extends CakeTestCase {
$expected = array(array($modelClass => array('name' => '1.1', $leftField => 2, $rightField => 5)), $expected = array(array($modelClass => array('name' => '1.1', $leftField => 2, $rightField => 5)),
array($modelClass => array('name' => '1.2', $leftField => 6, $rightField => 11)), array($modelClass => array('name' => '1.2', $leftField => 6, $rightField => 11)),
array($modelClass => array('name' => '1.1.1', $leftField => 12, $rightField => 13))); array($modelClass => array('name' => '1.1.1', $leftField => 12, $rightField => 13)));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertTrue($this->Tree->verify()); $this->assertTrue($this->Tree->verify());
} }

View file

@ -625,11 +625,11 @@ class BehaviorCollectionTest extends CakeTestCase {
array('Apple' => array('id' => '3', 'name' => 'green blue', 'mytime' => '22:57:17')) array('Apple' => array('id' => '3', 'name' => 'green blue', 'mytime' => '22:57:17'))
); );
$result = $Apple->find('all', array('conditions' => array('Apple.id <' => '4'))); $result = $Apple->find('all', array('conditions' => array('Apple.id <' => '4')));
$this->assertEqual($result, $expected2); $this->assertEqual($expected, $result2);
$Apple->Behaviors->disable('Test'); $Apple->Behaviors->disable('Test');
$result = $Apple->find('all'); $result = $Apple->find('all');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$Apple->Behaviors->attach('Test', array('beforeFind' => 'off', 'afterFind' => 'on')); $Apple->Behaviors->attach('Test', array('beforeFind' => 'off', 'afterFind' => 'on'));
$this->assertIdentical($Apple->find('all'), array()); $this->assertIdentical($Apple->find('all'), array());
@ -697,11 +697,11 @@ class BehaviorCollectionTest extends CakeTestCase {
$Apple->Child->Behaviors->attach('Test', array('before' => 'modify')); $Apple->Child->Behaviors->attach('Test', array('before' => 'modify'));
$result = $Apple->find('all', array('fields' => array('Apple.id'), 'conditions' => array('Apple.id <' => '4'))); $result = $Apple->find('all', array('fields' => array('Apple.id'), 'conditions' => array('Apple.id <' => '4')));
//$this->assertEqual($result, $expected2); //$this->assertEqual($expected, $result2);
$Apple->Child->Behaviors->disable('Test'); $Apple->Child->Behaviors->disable('Test');
$result = $Apple->find('all'); $result = $Apple->find('all');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$Apple->Child->Behaviors->attach('Test', array('before' => 'off', 'after' => 'on')); $Apple->Child->Behaviors->attach('Test', array('before' => 'off', 'after' => 'on'));
//$this->assertIdentical($Apple->find('all'), array()); //$this->assertIdentical($Apple->find('all'), array());
@ -768,11 +768,11 @@ class BehaviorCollectionTest extends CakeTestCase {
'Child' => array()) 'Child' => array())
); );
$result = $Apple->find('all', array('fields' => array('Apple.id'), 'conditions' => array('Apple.id <' => '4'))); $result = $Apple->find('all', array('fields' => array('Apple.id'), 'conditions' => array('Apple.id <' => '4')));
//$this->assertEqual($result, $expected2); //$this->assertEqual($expected, $result2);
$Apple->Sample->Behaviors->disable('Test'); $Apple->Sample->Behaviors->disable('Test');
$result = $Apple->find('all'); $result = $Apple->find('all');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$Apple->Sample->Behaviors->attach('Test', array('before' => 'off', 'after' => 'on')); $Apple->Sample->Behaviors->attach('Test', array('before' => 'off', 'after' => 'on'));
//$this->assertIdentical($Apple->find('all'), array()); //$this->assertIdentical($Apple->find('all'), array());
@ -837,11 +837,11 @@ class BehaviorCollectionTest extends CakeTestCase {
'fields' => array('Apple.id', 'Parent.id', 'Parent.name', 'Parent.mytime'), 'fields' => array('Apple.id', 'Parent.id', 'Parent.name', 'Parent.mytime'),
'conditions' => array('Apple.id <' => '4') 'conditions' => array('Apple.id <' => '4')
)); ));
$this->assertEqual($result, $expected2); $this->assertEqual($expected, $result2);
$Apple->Parent->Behaviors->disable('Test'); $Apple->Parent->Behaviors->disable('Test');
$result = $Apple->find('all'); $result = $Apple->find('all');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$Apple->Parent->Behaviors->attach('Test', array('after' => 'off')); $Apple->Parent->Behaviors->attach('Test', array('after' => 'off'));
$this->assertEqual($Apple->find('all'), $expected); $this->assertEqual($Apple->find('all'), $expected);
@ -1045,11 +1045,11 @@ class BehaviorCollectionTest extends CakeTestCase {
$result = $Apple->{'look for the remote'}('in the couch'); $result = $Apple->{'look for the remote'}('in the couch');
$expected = "Item.name = 'the remote' AND Location.name = 'the couch'"; $expected = "Item.name = 'the remote' AND Location.name = 'the couch'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $Apple->{'look for THE REMOTE'}('in the couch'); $result = $Apple->{'look for THE REMOTE'}('in the couch');
$expected = "Item.name = 'THE REMOTE' AND Location.name = 'the couch'"; $expected = "Item.name = 'THE REMOTE' AND Location.name = 'the couch'";
$this->assertEqual($result, $expected, 'Mapped method was lowercased.'); $this->assertEqual($expected, $result, 'Mapped method was lowercased.');
} }
/** /**

View file

@ -393,19 +393,19 @@ class DboMssqlTest extends CakeTestCase {
$result = $this->db->fields($this->model); $result = $this->db->fields($this->model);
$expected = $fields; $expected = $fields;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->db->clearFieldMappings(); $this->db->clearFieldMappings();
$result = $this->db->fields($this->model, null, 'MssqlTestModel.*'); $result = $this->db->fields($this->model, null, 'MssqlTestModel.*');
$expected = $fields; $expected = $fields;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->db->clearFieldMappings(); $this->db->clearFieldMappings();
$result = $this->db->fields($this->model, null, array('*', 'AnotherModel.id', 'AnotherModel.name')); $result = $this->db->fields($this->model, null, array('*', 'AnotherModel.id', 'AnotherModel.name'));
$expected = array_merge($fields, array( $expected = array_merge($fields, array(
'[AnotherModel].[id] AS [AnotherModel__18]', '[AnotherModel].[id] AS [AnotherModel__18]',
'[AnotherModel].[name] AS [AnotherModel__19]')); '[AnotherModel].[name] AS [AnotherModel__19]'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->db->clearFieldMappings(); $this->db->clearFieldMappings();
$result = $this->db->fields($this->model, null, array('*', 'MssqlClientTestModel.*')); $result = $this->db->fields($this->model, null, array('*', 'MssqlClientTestModel.*'));
@ -415,7 +415,7 @@ class DboMssqlTest extends CakeTestCase {
'[MssqlClientTestModel].[email] AS [MssqlClientTestModel__20]', '[MssqlClientTestModel].[email] AS [MssqlClientTestModel__20]',
'CONVERT(VARCHAR(20), [MssqlClientTestModel].[created], 20) AS [MssqlClientTestModel__21]', 'CONVERT(VARCHAR(20), [MssqlClientTestModel].[created], 20) AS [MssqlClientTestModel__21]',
'CONVERT(VARCHAR(20), [MssqlClientTestModel].[updated], 20) AS [MssqlClientTestModel__22]')); 'CONVERT(VARCHAR(20), [MssqlClientTestModel].[updated], 20) AS [MssqlClientTestModel__22]'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -427,11 +427,11 @@ class DboMssqlTest extends CakeTestCase {
function testDistinctFields() { function testDistinctFields() {
$result = $this->db->fields($this->model, null, array('DISTINCT Car.country_code')); $result = $this->db->fields($this->model, null, array('DISTINCT Car.country_code'));
$expected = array('DISTINCT [Car].[country_code] AS [Car__0]'); $expected = array('DISTINCT [Car].[country_code] AS [Car__0]');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->db->fields($this->model, null, 'DISTINCT Car.country_code'); $result = $this->db->fields($this->model, null, 'DISTINCT Car.country_code');
$expected = array('DISTINCT [Car].[country_code] AS [Car__1]'); $expected = array('DISTINCT [Car].[country_code] AS [Car__1]');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -479,7 +479,7 @@ class DboMssqlTest extends CakeTestCase {
'length' => 4 'length' => 4
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
* testBuildColumn * testBuildColumn
@ -490,53 +490,53 @@ class DboMssqlTest extends CakeTestCase {
$column = array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'); $column = array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary');
$result = $this->db->buildColumn($column); $result = $this->db->buildColumn($column);
$expected = '[id] int IDENTITY (1, 1) NOT NULL'; $expected = '[id] int IDENTITY (1, 1) NOT NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$column = array('name' => 'client_id', 'type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'); $column = array('name' => 'client_id', 'type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11');
$result = $this->db->buildColumn($column); $result = $this->db->buildColumn($column);
$expected = '[client_id] int DEFAULT 0 NOT NULL'; $expected = '[client_id] int DEFAULT 0 NOT NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$column = array('name' => 'client_id', 'type' => 'integer', 'null' => true); $column = array('name' => 'client_id', 'type' => 'integer', 'null' => true);
$result = $this->db->buildColumn($column); $result = $this->db->buildColumn($column);
$expected = '[client_id] int NULL'; $expected = '[client_id] int NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
// 'name' => 'type' format for columns // 'name' => 'type' format for columns
$column = array('type' => 'integer', 'name' => 'client_id'); $column = array('type' => 'integer', 'name' => 'client_id');
$result = $this->db->buildColumn($column); $result = $this->db->buildColumn($column);
$expected = '[client_id] int NULL'; $expected = '[client_id] int NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$column = array('type' => 'string', 'name' => 'name'); $column = array('type' => 'string', 'name' => 'name');
$result = $this->db->buildColumn($column); $result = $this->db->buildColumn($column);
$expected = '[name] varchar(255) NULL'; $expected = '[name] varchar(255) NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$column = array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255'); $column = array('name' => 'name', 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255');
$result = $this->db->buildColumn($column); $result = $this->db->buildColumn($column);
$expected = '[name] varchar(255) DEFAULT \'\' NOT NULL'; $expected = '[name] varchar(255) DEFAULT \'\' NOT NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$column = array('name' => 'name', 'type' => 'string', 'null' => false, 'length' => '255'); $column = array('name' => 'name', 'type' => 'string', 'null' => false, 'length' => '255');
$result = $this->db->buildColumn($column); $result = $this->db->buildColumn($column);
$expected = '[name] varchar(255) NOT NULL'; $expected = '[name] varchar(255) NOT NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$column = array('name' => 'name', 'type' => 'string', 'null' => false, 'default' => null, 'length' => '255'); $column = array('name' => 'name', 'type' => 'string', 'null' => false, 'default' => null, 'length' => '255');
$result = $this->db->buildColumn($column); $result = $this->db->buildColumn($column);
$expected = '[name] varchar(255) NOT NULL'; $expected = '[name] varchar(255) NOT NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => null, 'length' => '255'); $column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => null, 'length' => '255');
$result = $this->db->buildColumn($column); $result = $this->db->buildColumn($column);
$expected = '[name] varchar(255) NULL'; $expected = '[name] varchar(255) NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => '', 'length' => '255'); $column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => '', 'length' => '255');
$result = $this->db->buildColumn($column); $result = $this->db->buildColumn($column);
$expected = '[name] varchar(255) DEFAULT \'\''; $expected = '[name] varchar(255) DEFAULT \'\'';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
* testBuildIndex method * testBuildIndex method
@ -553,7 +553,7 @@ class DboMssqlTest extends CakeTestCase {
'PRIMARY KEY ([id])', 'PRIMARY KEY ([id])',
'ALTER TABLE items ADD CONSTRAINT client_id UNIQUE([client_id]);' 'ALTER TABLE items ADD CONSTRAINT client_id UNIQUE([client_id]);'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$indexes = array('client_id' => array('column' => 'client_id')); $indexes = array('client_id' => array('column' => 'client_id'));
$result = $this->db->buildIndex($indexes, 'items'); $result = $this->db->buildIndex($indexes, 'items');
@ -562,7 +562,7 @@ class DboMssqlTest extends CakeTestCase {
$indexes = array('client_id' => array('column' => array('client_id', 'period_id'), 'unique' => 1)); $indexes = array('client_id' => array('column' => array('client_id', 'period_id'), 'unique' => 1));
$result = $this->db->buildIndex($indexes, 'items'); $result = $this->db->buildIndex($indexes, 'items');
$expected = array('ALTER TABLE items ADD CONSTRAINT client_id UNIQUE([client_id], [period_id]);'); $expected = array('ALTER TABLE items ADD CONSTRAINT client_id UNIQUE([client_id], [period_id]);');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
* testUpdateAllSyntax method * testUpdateAllSyntax method
@ -620,7 +620,7 @@ class DboMssqlTest extends CakeTestCase {
'INSERT INTO [mssql_test_models] ([id], [name], [login]) VALUES (2, \'Renan\', \'renan.saddam\')', 'INSERT INTO [mssql_test_models] ([id], [name], [login]) VALUES (2, \'Renan\', \'renan.saddam\')',
'SET IDENTITY_INSERT [mssql_test_models] OFF' 'SET IDENTITY_INSERT [mssql_test_models] OFF'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$fields = array('name', 'login'); $fields = array('name', 'login');
$values = array('(\'Larry\', \'PhpNut\')', '(\'Renan\', \'renan.saddam\')'); $values = array('(\'Larry\', \'PhpNut\')', '(\'Renan\', \'renan.saddam\')');
@ -631,7 +631,7 @@ class DboMssqlTest extends CakeTestCase {
'INSERT INTO [mssql_test_models] ([name], [login]) VALUES (\'Larry\', \'PhpNut\')', 'INSERT INTO [mssql_test_models] ([name], [login]) VALUES (\'Larry\', \'PhpNut\')',
'INSERT INTO [mssql_test_models] ([name], [login]) VALUES (\'Renan\', \'renan.saddam\')' 'INSERT INTO [mssql_test_models] ([name], [login]) VALUES (\'Renan\', \'renan.saddam\')'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
* testLastError * testLastError

View file

@ -108,7 +108,7 @@ class DboMysqlTest extends CakeTestCase {
'`MysqlTestModel`.`created`', '`MysqlTestModel`.`created`',
'`MysqlTestModel`.`updated`' '`MysqlTestModel`.`updated`'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$expected = 1.2; $expected = 1.2;
$result = $this->Dbo->value(1.2, 'float'); $result = $this->Dbo->value(1.2, 'float');
@ -283,7 +283,7 @@ class DboMysqlTest extends CakeTestCase {
); );
$result = $this->Dbo->buildColumn($data); $result = $this->Dbo->buildColumn($data);
$expected = '`testName` DEFAULT NULL COMMENT \'test\''; $expected = '`testName` DEFAULT NULL COMMENT \'test\'';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
'name' => 'testName', 'name' => 'testName',
@ -296,7 +296,7 @@ class DboMysqlTest extends CakeTestCase {
); );
$result = $this->Dbo->buildColumn($data); $result = $this->Dbo->buildColumn($data);
$expected = '`testName` CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL'; $expected = '`testName` CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Dbo->columns = $restore; $this->Dbo->columns = $restore;
} }
@ -402,7 +402,7 @@ class DboMysqlTest extends CakeTestCase {
'pointless_small_int' => array('column' => 'small_int', 'unique' => 0), 'pointless_small_int' => array('column' => 'small_int', 'unique' => 0),
'one_way' => array('column' => array('bool', 'small_int'), 'unique' => 0), 'one_way' => array('column' => array('bool', 'small_int'), 'unique' => 0),
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -413,43 +413,43 @@ class DboMysqlTest extends CakeTestCase {
public function testColumn() { public function testColumn() {
$result = $this->Dbo->column('varchar(50)'); $result = $this->Dbo->column('varchar(50)');
$expected = 'string'; $expected = 'string';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->column('text'); $result = $this->Dbo->column('text');
$expected = 'text'; $expected = 'text';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->column('int(11)'); $result = $this->Dbo->column('int(11)');
$expected = 'integer'; $expected = 'integer';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->column('int(11) unsigned'); $result = $this->Dbo->column('int(11) unsigned');
$expected = 'integer'; $expected = 'integer';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->column('tinyint(1)'); $result = $this->Dbo->column('tinyint(1)');
$expected = 'boolean'; $expected = 'boolean';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->column('boolean'); $result = $this->Dbo->column('boolean');
$expected = 'boolean'; $expected = 'boolean';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->column('float'); $result = $this->Dbo->column('float');
$expected = 'float'; $expected = 'float';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->column('float unsigned'); $result = $this->Dbo->column('float unsigned');
$expected = 'float'; $expected = 'float';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->column('double unsigned'); $result = $this->Dbo->column('double unsigned');
$expected = 'float'; $expected = 'float';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->column('decimal(14,7) unsigned'); $result = $this->Dbo->column('decimal(14,7) unsigned');
$expected = 'float'; $expected = 'float';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -618,7 +618,7 @@ class DboMysqlTest extends CakeTestCase {
$this->assertEqual($result['Collation'], 'utf8_general_ci'); $this->assertEqual($result['Collation'], 'utf8_general_ci');
$this->assertEqual($result['Engine'], 'InnoDB'); $this->assertEqual($result['Engine'], 'InnoDB');
$this->assertEqual($result['charset'], 'utf8'); $this->assertEqual($result['charset'], 'utf8');
$this->Dbo->rawQuery($this->Dbo->dropSchema($schema1)); $this->Dbo->rawQuery($this->Dbo->dropSchema($schema1));
} }
@ -673,7 +673,7 @@ class DboMysqlTest extends CakeTestCase {
'charset' => 'utf8', 'charset' => 'utf8',
'collate' => 'utf8_unicode_ci', 'collate' => 'utf8_unicode_ci',
'engine' => 'InnoDB'); 'engine' => 'InnoDB');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$table = $this->Dbo->fullTableName($tableName); $table = $this->Dbo->fullTableName($tableName);
$this->Dbo->rawQuery('CREATE TABLE ' . $table . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=MyISAM DEFAULT CHARSET=cp1250 COLLATE=cp1250_general_ci;'); $this->Dbo->rawQuery('CREATE TABLE ' . $table . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=MyISAM DEFAULT CHARSET=cp1250 COLLATE=cp1250_general_ci;');
@ -683,7 +683,7 @@ class DboMysqlTest extends CakeTestCase {
'charset' => 'cp1250', 'charset' => 'cp1250',
'collate' => 'cp1250_general_ci', 'collate' => 'cp1250_general_ci',
'engine' => 'MyISAM'); 'engine' => 'MyISAM');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -703,7 +703,7 @@ class DboMysqlTest extends CakeTestCase {
'DEFAULT CHARSET=utf8', 'DEFAULT CHARSET=utf8',
'COLLATE=utf8_unicode_ci', 'COLLATE=utf8_unicode_ci',
'ENGINE=InnoDB'); 'ENGINE=InnoDB');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -736,7 +736,7 @@ class DboMysqlTest extends CakeTestCase {
$result = $this->Dbo->fields($model, null, array('data', 'other__field')); $result = $this->Dbo->fields($model, null, array('data', 'other__field'));
$expected = array('`BinaryTest`.`data`', '(SUM(id)) AS `BinaryTest_$_other__field`'); $expected = array('`BinaryTest`.`data`', '(SUM(id)) AS `BinaryTest_$_other__field`');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -1765,7 +1765,7 @@ class DboMysqlTest extends CakeTestCase {
$this->Model = new TestModel4(); $this->Model = new TestModel4();
$result = $this->Dbo->fields($this->Model, 'Vendor', "DISTINCT Vendor.id, Vendor.name"); $result = $this->Dbo->fields($this->Model, 'Vendor', "DISTINCT Vendor.id, Vendor.name");
$expected = array('DISTINCT `Vendor`.`id`', '`Vendor`.`name`'); $expected = array('DISTINCT `Vendor`.`id`', '`Vendor`.`name`');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -1777,112 +1777,112 @@ class DboMysqlTest extends CakeTestCase {
function testStringConditionsParsing() { function testStringConditionsParsing() {
$result = $this->Dbo->conditions("ProjectBid.project_id = Project.id"); $result = $this->Dbo->conditions("ProjectBid.project_id = Project.id");
$expected = " WHERE `ProjectBid`.`project_id` = `Project`.`id`"; $expected = " WHERE `ProjectBid`.`project_id` = `Project`.`id`";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions("Candy.name LIKE 'a' AND HardCandy.name LIKE 'c'"); $result = $this->Dbo->conditions("Candy.name LIKE 'a' AND HardCandy.name LIKE 'c'");
$expected = " WHERE `Candy`.`name` LIKE 'a' AND `HardCandy`.`name` LIKE 'c'"; $expected = " WHERE `Candy`.`name` LIKE 'a' AND `HardCandy`.`name` LIKE 'c'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions("HardCandy.name LIKE 'a' AND Candy.name LIKE 'c'"); $result = $this->Dbo->conditions("HardCandy.name LIKE 'a' AND Candy.name LIKE 'c'");
$expected = " WHERE `HardCandy`.`name` LIKE 'a' AND `Candy`.`name` LIKE 'c'"; $expected = " WHERE `HardCandy`.`name` LIKE 'a' AND `Candy`.`name` LIKE 'c'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions("Post.title = '1.1'"); $result = $this->Dbo->conditions("Post.title = '1.1'");
$expected = " WHERE `Post`.`title` = '1.1'"; $expected = " WHERE `Post`.`title` = '1.1'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions("User.id != 0 AND User.user LIKE '%arr%'"); $result = $this->Dbo->conditions("User.id != 0 AND User.user LIKE '%arr%'");
$expected = " WHERE `User`.`id` != 0 AND `User`.`user` LIKE '%arr%'"; $expected = " WHERE `User`.`id` != 0 AND `User`.`user` LIKE '%arr%'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions("SUM(Post.comments_count) > 500"); $result = $this->Dbo->conditions("SUM(Post.comments_count) > 500");
$expected = " WHERE SUM(`Post`.`comments_count`) > 500"; $expected = " WHERE SUM(`Post`.`comments_count`) > 500";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions("(Post.created < '" . date('Y-m-d H:i:s') . "') GROUP BY YEAR(Post.created), MONTH(Post.created)"); $result = $this->Dbo->conditions("(Post.created < '" . date('Y-m-d H:i:s') . "') GROUP BY YEAR(Post.created), MONTH(Post.created)");
$expected = " WHERE (`Post`.`created` < '" . date('Y-m-d H:i:s') . "') GROUP BY YEAR(`Post`.`created`), MONTH(`Post`.`created`)"; $expected = " WHERE (`Post`.`created` < '" . date('Y-m-d H:i:s') . "') GROUP BY YEAR(`Post`.`created`), MONTH(`Post`.`created`)";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions("score BETWEEN 90.1 AND 95.7"); $result = $this->Dbo->conditions("score BETWEEN 90.1 AND 95.7");
$expected = " WHERE score BETWEEN 90.1 AND 95.7"; $expected = " WHERE score BETWEEN 90.1 AND 95.7";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('score' => array(2=>1, 2, 10))); $result = $this->Dbo->conditions(array('score' => array(2=>1, 2, 10)));
$expected = " WHERE score IN (1, 2, 10)"; $expected = " WHERE score IN (1, 2, 10)";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions("Aro.rght = Aro.lft + 1.1"); $result = $this->Dbo->conditions("Aro.rght = Aro.lft + 1.1");
$expected = " WHERE `Aro`.`rght` = `Aro`.`lft` + 1.1"; $expected = " WHERE `Aro`.`rght` = `Aro`.`lft` + 1.1";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions("(Post.created < '" . date('Y-m-d H:i:s') . "') GROUP BY YEAR(Post.created), MONTH(Post.created)"); $result = $this->Dbo->conditions("(Post.created < '" . date('Y-m-d H:i:s') . "') GROUP BY YEAR(Post.created), MONTH(Post.created)");
$expected = " WHERE (`Post`.`created` < '" . date('Y-m-d H:i:s') . "') GROUP BY YEAR(`Post`.`created`), MONTH(`Post`.`created`)"; $expected = " WHERE (`Post`.`created` < '" . date('Y-m-d H:i:s') . "') GROUP BY YEAR(`Post`.`created`), MONTH(`Post`.`created`)";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions('Sportstaette.sportstaette LIKE "%ru%" AND Sportstaette.sportstaettenart_id = 2'); $result = $this->Dbo->conditions('Sportstaette.sportstaette LIKE "%ru%" AND Sportstaette.sportstaettenart_id = 2');
$expected = ' WHERE `Sportstaette`.`sportstaette` LIKE "%ru%" AND `Sportstaette`.`sportstaettenart_id` = 2'; $expected = ' WHERE `Sportstaette`.`sportstaette` LIKE "%ru%" AND `Sportstaette`.`sportstaettenart_id` = 2';
$this->assertPattern('/\s*WHERE\s+`Sportstaette`\.`sportstaette`\s+LIKE\s+"%ru%"\s+AND\s+`Sports/', $result); $this->assertPattern('/\s*WHERE\s+`Sportstaette`\.`sportstaette`\s+LIKE\s+"%ru%"\s+AND\s+`Sports/', $result);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions('Sportstaette.sportstaettenart_id = 2 AND Sportstaette.sportstaette LIKE "%ru%"'); $result = $this->Dbo->conditions('Sportstaette.sportstaettenart_id = 2 AND Sportstaette.sportstaette LIKE "%ru%"');
$expected = ' WHERE `Sportstaette`.`sportstaettenart_id` = 2 AND `Sportstaette`.`sportstaette` LIKE "%ru%"'; $expected = ' WHERE `Sportstaette`.`sportstaettenart_id` = 2 AND `Sportstaette`.`sportstaette` LIKE "%ru%"';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions('SUM(Post.comments_count) > 500 AND NOT Post.title IS NULL AND NOT Post.extended_title IS NULL'); $result = $this->Dbo->conditions('SUM(Post.comments_count) > 500 AND NOT Post.title IS NULL AND NOT Post.extended_title IS NULL');
$expected = ' WHERE SUM(`Post`.`comments_count`) > 500 AND NOT `Post`.`title` IS NULL AND NOT `Post`.`extended_title` IS NULL'; $expected = ' WHERE SUM(`Post`.`comments_count`) > 500 AND NOT `Post`.`title` IS NULL AND NOT `Post`.`extended_title` IS NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions('NOT Post.title IS NULL AND NOT Post.extended_title IS NULL AND SUM(Post.comments_count) > 500'); $result = $this->Dbo->conditions('NOT Post.title IS NULL AND NOT Post.extended_title IS NULL AND SUM(Post.comments_count) > 500');
$expected = ' WHERE NOT `Post`.`title` IS NULL AND NOT `Post`.`extended_title` IS NULL AND SUM(`Post`.`comments_count`) > 500'; $expected = ' WHERE NOT `Post`.`title` IS NULL AND NOT `Post`.`extended_title` IS NULL AND SUM(`Post`.`comments_count`) > 500';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions('NOT Post.extended_title IS NULL AND NOT Post.title IS NULL AND Post.title != "" AND SPOON(SUM(Post.comments_count) + 1.1) > 500'); $result = $this->Dbo->conditions('NOT Post.extended_title IS NULL AND NOT Post.title IS NULL AND Post.title != "" AND SPOON(SUM(Post.comments_count) + 1.1) > 500');
$expected = ' WHERE NOT `Post`.`extended_title` IS NULL AND NOT `Post`.`title` IS NULL AND `Post`.`title` != "" AND SPOON(SUM(`Post`.`comments_count`) + 1.1) > 500'; $expected = ' WHERE NOT `Post`.`extended_title` IS NULL AND NOT `Post`.`title` IS NULL AND `Post`.`title` != "" AND SPOON(SUM(`Post`.`comments_count`) + 1.1) > 500';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions('NOT Post.title_extended IS NULL AND NOT Post.title IS NULL AND Post.title_extended != Post.title'); $result = $this->Dbo->conditions('NOT Post.title_extended IS NULL AND NOT Post.title IS NULL AND Post.title_extended != Post.title');
$expected = ' WHERE NOT `Post`.`title_extended` IS NULL AND NOT `Post`.`title` IS NULL AND `Post`.`title_extended` != `Post`.`title`'; $expected = ' WHERE NOT `Post`.`title_extended` IS NULL AND NOT `Post`.`title` IS NULL AND `Post`.`title_extended` != `Post`.`title`';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions("Comment.id = 'a'"); $result = $this->Dbo->conditions("Comment.id = 'a'");
$expected = " WHERE `Comment`.`id` = 'a'"; $expected = " WHERE `Comment`.`id` = 'a'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions("lower(Article.title) LIKE 'a%'"); $result = $this->Dbo->conditions("lower(Article.title) LIKE 'a%'");
$expected = " WHERE lower(`Article`.`title`) LIKE 'a%'"; $expected = " WHERE lower(`Article`.`title`) LIKE 'a%'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions('((MATCH(Video.title) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 2) + (MATCH(Video.description) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 0.4) + (MATCH(Video.tags) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 1.5))'); $result = $this->Dbo->conditions('((MATCH(Video.title) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 2) + (MATCH(Video.description) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 0.4) + (MATCH(Video.tags) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 1.5))');
$expected = ' WHERE ((MATCH(`Video`.`title`) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 2) + (MATCH(`Video`.`description`) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 0.4) + (MATCH(`Video`.`tags`) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 1.5))'; $expected = ' WHERE ((MATCH(`Video`.`title`) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 2) + (MATCH(`Video`.`description`) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 0.4) + (MATCH(`Video`.`tags`) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 1.5))';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions('DATEDIFF(NOW(),Article.published) < 1 && Article.live=1'); $result = $this->Dbo->conditions('DATEDIFF(NOW(),Article.published) < 1 && Article.live=1');
$expected = " WHERE DATEDIFF(NOW(),`Article`.`published`) < 1 && `Article`.`live`=1"; $expected = " WHERE DATEDIFF(NOW(),`Article`.`published`) < 1 && `Article`.`live`=1";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions('file = "index.html"'); $result = $this->Dbo->conditions('file = "index.html"');
$expected = ' WHERE file = "index.html"'; $expected = ' WHERE file = "index.html"';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions("file = 'index.html'"); $result = $this->Dbo->conditions("file = 'index.html'");
$expected = " WHERE file = 'index.html'"; $expected = " WHERE file = 'index.html'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$letter = $letter = 'd.a'; $letter = $letter = 'd.a';
$conditions = array('Company.name like ' => $letter . '%'); $conditions = array('Company.name like ' => $letter . '%');
$result = $this->Dbo->conditions($conditions); $result = $this->Dbo->conditions($conditions);
$expected = " WHERE `Company`.`name` like 'd.a%'"; $expected = " WHERE `Company`.`name` like 'd.a%'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$conditions = array('Artist.name' => 'JUDY and MARY'); $conditions = array('Artist.name' => 'JUDY and MARY');
$result = $this->Dbo->conditions($conditions); $result = $this->Dbo->conditions($conditions);
$expected = " WHERE `Artist`.`name` = 'JUDY and MARY'"; $expected = " WHERE `Artist`.`name` = 'JUDY and MARY'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$conditions = array('Artist.name' => 'JUDY AND MARY'); $conditions = array('Artist.name' => 'JUDY AND MARY');
$result = $this->Dbo->conditions($conditions); $result = $this->Dbo->conditions($conditions);
$expected = " WHERE `Artist`.`name` = 'JUDY AND MARY'"; $expected = " WHERE `Artist`.`name` = 'JUDY AND MARY'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -1894,20 +1894,20 @@ class DboMysqlTest extends CakeTestCase {
function testQuotesInStringConditions() { function testQuotesInStringConditions() {
$result = $this->Dbo->conditions('Member.email = \'mariano@cricava.com\''); $result = $this->Dbo->conditions('Member.email = \'mariano@cricava.com\'');
$expected = ' WHERE `Member`.`email` = \'mariano@cricava.com\''; $expected = ' WHERE `Member`.`email` = \'mariano@cricava.com\'';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions('Member.email = "mariano@cricava.com"'); $result = $this->Dbo->conditions('Member.email = "mariano@cricava.com"');
$expected = ' WHERE `Member`.`email` = "mariano@cricava.com"'; $expected = ' WHERE `Member`.`email` = "mariano@cricava.com"';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions('Member.email = \'mariano@cricava.com\' AND Member.user LIKE \'mariano.iglesias%\''); $result = $this->Dbo->conditions('Member.email = \'mariano@cricava.com\' AND Member.user LIKE \'mariano.iglesias%\'');
$expected = ' WHERE `Member`.`email` = \'mariano@cricava.com\' AND `Member`.`user` LIKE \'mariano.iglesias%\''; $expected = ' WHERE `Member`.`email` = \'mariano@cricava.com\' AND `Member`.`user` LIKE \'mariano.iglesias%\'';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions('Member.email = "mariano@cricava.com" AND Member.user LIKE "mariano.iglesias%"'); $result = $this->Dbo->conditions('Member.email = "mariano@cricava.com" AND Member.user LIKE "mariano.iglesias%"');
$expected = ' WHERE `Member`.`email` = "mariano@cricava.com" AND `Member`.`user` LIKE "mariano.iglesias%"'; $expected = ' WHERE `Member`.`email` = "mariano@cricava.com" AND `Member`.`user` LIKE "mariano.iglesias%"';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -2026,67 +2026,67 @@ class DboMysqlTest extends CakeTestCase {
$result = $this->Dbo->conditions(array('HardCandy.name LIKE' => 'a', 'Candy.name LIKE' => 'c')); $result = $this->Dbo->conditions(array('HardCandy.name LIKE' => 'a', 'Candy.name LIKE' => 'c'));
$expected = " WHERE `HardCandy`.`name` LIKE 'a' AND `Candy`.`name` LIKE 'c'"; $expected = " WHERE `HardCandy`.`name` LIKE 'a' AND `Candy`.`name` LIKE 'c'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('HardCandy.name LIKE' => 'a%', 'Candy.name LIKE' => '%c%')); $result = $this->Dbo->conditions(array('HardCandy.name LIKE' => 'a%', 'Candy.name LIKE' => '%c%'));
$expected = " WHERE `HardCandy`.`name` LIKE 'a%' AND `Candy`.`name` LIKE '%c%'"; $expected = " WHERE `HardCandy`.`name` LIKE 'a%' AND `Candy`.`name` LIKE '%c%'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('HardCandy.name LIKE' => 'to be or%', 'Candy.name LIKE' => '%not to be%')); $result = $this->Dbo->conditions(array('HardCandy.name LIKE' => 'to be or%', 'Candy.name LIKE' => '%not to be%'));
$expected = " WHERE `HardCandy`.`name` LIKE 'to be or%' AND `Candy`.`name` LIKE '%not to be%'"; $expected = " WHERE `HardCandy`.`name` LIKE 'to be or%' AND `Candy`.`name` LIKE '%not to be%'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('score BETWEEN ? AND ?' => array(90.1, 95.7))); $result = $this->Dbo->conditions(array('score BETWEEN ? AND ?' => array(90.1, 95.7)));
$expected = " WHERE `score` BETWEEN 90.100000 AND 95.700000"; $expected = " WHERE `score` BETWEEN 90.100000 AND 95.700000";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('Post.title' => 1.1)); $result = $this->Dbo->conditions(array('Post.title' => 1.1));
$expected = " WHERE `Post`.`title` = 1.100000"; $expected = " WHERE `Post`.`title` = 1.100000";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('Post.title' => 1.1), true, true, new Post()); $result = $this->Dbo->conditions(array('Post.title' => 1.1), true, true, new Post());
$expected = " WHERE `Post`.`title` = '1.1'"; $expected = " WHERE `Post`.`title` = '1.1'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('SUM(Post.comments_count) >' => '500')); $result = $this->Dbo->conditions(array('SUM(Post.comments_count) >' => '500'));
$expected = " WHERE SUM(`Post`.`comments_count`) > '500'"; $expected = " WHERE SUM(`Post`.`comments_count`) > '500'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('MAX(Post.rating) >' => '50')); $result = $this->Dbo->conditions(array('MAX(Post.rating) >' => '50'));
$expected = " WHERE MAX(`Post`.`rating`) > '50'"; $expected = " WHERE MAX(`Post`.`rating`) > '50'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('title LIKE' => '%hello')); $result = $this->Dbo->conditions(array('title LIKE' => '%hello'));
$expected = " WHERE `title` LIKE '%hello'"; $expected = " WHERE `title` LIKE '%hello'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('Post.name' => 'mad(g)ik')); $result = $this->Dbo->conditions(array('Post.name' => 'mad(g)ik'));
$expected = " WHERE `Post`.`name` = 'mad(g)ik'"; $expected = " WHERE `Post`.`name` = 'mad(g)ik'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('score' => array(1, 2, 10))); $result = $this->Dbo->conditions(array('score' => array(1, 2, 10)));
$expected = " WHERE score IN (1, 2, 10)"; $expected = " WHERE score IN (1, 2, 10)";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('score' => array())); $result = $this->Dbo->conditions(array('score' => array()));
$expected = " WHERE `score` IS NULL"; $expected = " WHERE `score` IS NULL";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('score !=' => array())); $result = $this->Dbo->conditions(array('score !=' => array()));
$expected = " WHERE `score` IS NOT NULL"; $expected = " WHERE `score` IS NOT NULL";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('score !=' => '20')); $result = $this->Dbo->conditions(array('score !=' => '20'));
$expected = " WHERE `score` != '20'"; $expected = " WHERE `score` != '20'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('score >' => '20')); $result = $this->Dbo->conditions(array('score >' => '20'));
$expected = " WHERE `score` > '20'"; $expected = " WHERE `score` > '20'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('client_id >' => '20'), true, true, new TestModel()); $result = $this->Dbo->conditions(array('client_id >' => '20'), true, true, new TestModel());
$expected = " WHERE `client_id` > 20"; $expected = " WHERE `client_id` > 20";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('OR' => array( $result = $this->Dbo->conditions(array('OR' => array(
array('User.user' => 'mariano'), array('User.user' => 'mariano'),
@ -2094,63 +2094,63 @@ class DboMysqlTest extends CakeTestCase {
))); )));
$expected = " WHERE ((`User`.`user` = 'mariano') OR (`User`.`user` = 'nate'))"; $expected = " WHERE ((`User`.`user` = 'mariano') OR (`User`.`user` = 'nate'))";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('or' => array( $result = $this->Dbo->conditions(array('or' => array(
'score BETWEEN ? AND ?' => array('4', '5'), 'rating >' => '20' 'score BETWEEN ? AND ?' => array('4', '5'), 'rating >' => '20'
))); )));
$expected = " WHERE ((`score` BETWEEN '4' AND '5') OR (`rating` > '20'))"; $expected = " WHERE ((`score` BETWEEN '4' AND '5') OR (`rating` > '20'))";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('or' => array( $result = $this->Dbo->conditions(array('or' => array(
'score BETWEEN ? AND ?' => array('4', '5'), array('score >' => '20') 'score BETWEEN ? AND ?' => array('4', '5'), array('score >' => '20')
))); )));
$expected = " WHERE ((`score` BETWEEN '4' AND '5') OR (`score` > '20'))"; $expected = " WHERE ((`score` BETWEEN '4' AND '5') OR (`score` > '20'))";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('and' => array( $result = $this->Dbo->conditions(array('and' => array(
'score BETWEEN ? AND ?' => array('4', '5'), array('score >' => '20') 'score BETWEEN ? AND ?' => array('4', '5'), array('score >' => '20')
))); )));
$expected = " WHERE ((`score` BETWEEN '4' AND '5') AND (`score` > '20'))"; $expected = " WHERE ((`score` BETWEEN '4' AND '5') AND (`score` > '20'))";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array( $result = $this->Dbo->conditions(array(
'published' => 1, 'or' => array('score >' => '2', array('score >' => '20')) 'published' => 1, 'or' => array('score >' => '2', array('score >' => '20'))
)); ));
$expected = " WHERE `published` = 1 AND ((`score` > '2') OR (`score` > '20'))"; $expected = " WHERE `published` = 1 AND ((`score` > '2') OR (`score` > '20'))";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array(array('Project.removed' => false))); $result = $this->Dbo->conditions(array(array('Project.removed' => false)));
$expected = " WHERE `Project`.`removed` = '0'"; $expected = " WHERE `Project`.`removed` = '0'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array(array('Project.removed' => true))); $result = $this->Dbo->conditions(array(array('Project.removed' => true)));
$expected = " WHERE `Project`.`removed` = '1'"; $expected = " WHERE `Project`.`removed` = '1'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array(array('Project.removed' => null))); $result = $this->Dbo->conditions(array(array('Project.removed' => null)));
$expected = " WHERE `Project`.`removed` IS NULL"; $expected = " WHERE `Project`.`removed` IS NULL";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array(array('Project.removed !=' => null))); $result = $this->Dbo->conditions(array(array('Project.removed !=' => null)));
$expected = " WHERE `Project`.`removed` IS NOT NULL"; $expected = " WHERE `Project`.`removed` IS NOT NULL";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('(Usergroup.permissions) & 4' => 4)); $result = $this->Dbo->conditions(array('(Usergroup.permissions) & 4' => 4));
$expected = " WHERE (`Usergroup`.`permissions`) & 4 = 4"; $expected = " WHERE (`Usergroup`.`permissions`) & 4 = 4";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('((Usergroup.permissions) & 4)' => 4)); $result = $this->Dbo->conditions(array('((Usergroup.permissions) & 4)' => 4));
$expected = " WHERE ((`Usergroup`.`permissions`) & 4) = 4"; $expected = " WHERE ((`Usergroup`.`permissions`) & 4) = 4";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('Post.modified >=' => 'DATE_SUB(NOW(), INTERVAL 7 DAY)')); $result = $this->Dbo->conditions(array('Post.modified >=' => 'DATE_SUB(NOW(), INTERVAL 7 DAY)'));
$expected = " WHERE `Post`.`modified` >= 'DATE_SUB(NOW(), INTERVAL 7 DAY)'"; $expected = " WHERE `Post`.`modified` >= 'DATE_SUB(NOW(), INTERVAL 7 DAY)'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('Post.modified >= DATE_SUB(NOW(), INTERVAL 7 DAY)')); $result = $this->Dbo->conditions(array('Post.modified >= DATE_SUB(NOW(), INTERVAL 7 DAY)'));
$expected = " WHERE `Post`.`modified` >= DATE_SUB(NOW(), INTERVAL 7 DAY)"; $expected = " WHERE `Post`.`modified` >= DATE_SUB(NOW(), INTERVAL 7 DAY)";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array( $result = $this->Dbo->conditions(array(
'NOT' => array('Course.id' => null, 'Course.vet' => 'N', 'level_of_education_id' => array(912,999)), 'NOT' => array('Course.id' => null, 'Course.vet' => 'N', 'level_of_education_id' => array(912,999)),
@ -2163,7 +2163,7 @@ class DboMysqlTest extends CakeTestCase {
$result = $this->Dbo->conditions(array('TestModel.field =' => 'gribe$@()lu')); $result = $this->Dbo->conditions(array('TestModel.field =' => 'gribe$@()lu'));
$expected = " WHERE `TestModel`.`field` = 'gribe$@()lu'"; $expected = " WHERE `TestModel`.`field` = 'gribe$@()lu'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$conditions['NOT'] = array('Listing.expiration BETWEEN ? AND ?' => array("1", "100")); $conditions['NOT'] = array('Listing.expiration BETWEEN ? AND ?' => array("1", "100"));
$conditions[0]['OR'] = array( $conditions[0]['OR'] = array(
@ -2178,69 +2178,69 @@ class DboMysqlTest extends CakeTestCase {
$expected = " WHERE NOT (`Listing`.`expiration` BETWEEN '1' AND '100') AND" . $expected = " WHERE NOT (`Listing`.`expiration` BETWEEN '1' AND '100') AND" .
" ((`Listing`.`title` LIKE '%term%') OR (`Listing`.`description` LIKE '%term%')) AND" . " ((`Listing`.`title` LIKE '%term%') OR (`Listing`.`description` LIKE '%term%')) AND" .
" ((`Listing`.`title` LIKE '%term_2%') OR (`Listing`.`description` LIKE '%term_2%'))"; " ((`Listing`.`title` LIKE '%term_2%') OR (`Listing`.`description` LIKE '%term_2%'))";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('MD5(CONCAT(Reg.email,Reg.id))' => 'blah')); $result = $this->Dbo->conditions(array('MD5(CONCAT(Reg.email,Reg.id))' => 'blah'));
$expected = " WHERE MD5(CONCAT(`Reg`.`email`,`Reg`.`id`)) = 'blah'"; $expected = " WHERE MD5(CONCAT(`Reg`.`email`,`Reg`.`id`)) = 'blah'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array( $result = $this->Dbo->conditions(array(
'MD5(CONCAT(Reg.email,Reg.id))' => array('blah', 'blahblah') 'MD5(CONCAT(Reg.email,Reg.id))' => array('blah', 'blahblah')
)); ));
$expected = " WHERE MD5(CONCAT(`Reg`.`email`,`Reg`.`id`)) IN ('blah', 'blahblah')"; $expected = " WHERE MD5(CONCAT(`Reg`.`email`,`Reg`.`id`)) IN ('blah', 'blahblah')";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$conditions = array('id' => array(2, 5, 6, 9, 12, 45, 78, 43, 76)); $conditions = array('id' => array(2, 5, 6, 9, 12, 45, 78, 43, 76));
$result = $this->Dbo->conditions($conditions); $result = $this->Dbo->conditions($conditions);
$expected = " WHERE id IN (2, 5, 6, 9, 12, 45, 78, 43, 76)"; $expected = " WHERE id IN (2, 5, 6, 9, 12, 45, 78, 43, 76)";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$conditions = array('title' => 'user(s)'); $conditions = array('title' => 'user(s)');
$result = $this->Dbo->conditions($conditions); $result = $this->Dbo->conditions($conditions);
$expected = " WHERE `title` = 'user(s)'"; $expected = " WHERE `title` = 'user(s)'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$conditions = array('title' => 'user(s) data'); $conditions = array('title' => 'user(s) data');
$result = $this->Dbo->conditions($conditions); $result = $this->Dbo->conditions($conditions);
$expected = " WHERE `title` = 'user(s) data'"; $expected = " WHERE `title` = 'user(s) data'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$conditions = array('title' => 'user(s,arg) data'); $conditions = array('title' => 'user(s,arg) data');
$result = $this->Dbo->conditions($conditions); $result = $this->Dbo->conditions($conditions);
$expected = " WHERE `title` = 'user(s,arg) data'"; $expected = " WHERE `title` = 'user(s,arg) data'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array("Book.book_name" => 'Java(TM)')); $result = $this->Dbo->conditions(array("Book.book_name" => 'Java(TM)'));
$expected = " WHERE `Book`.`book_name` = 'Java(TM)'"; $expected = " WHERE `Book`.`book_name` = 'Java(TM)'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array("Book.book_name" => 'Java(TM) ')); $result = $this->Dbo->conditions(array("Book.book_name" => 'Java(TM) '));
$expected = " WHERE `Book`.`book_name` = 'Java(TM) '"; $expected = " WHERE `Book`.`book_name` = 'Java(TM) '";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array("Book.id" => 0)); $result = $this->Dbo->conditions(array("Book.id" => 0));
$expected = " WHERE `Book`.`id` = 0"; $expected = " WHERE `Book`.`id` = 0";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array("Book.id" => NULL)); $result = $this->Dbo->conditions(array("Book.id" => NULL));
$expected = " WHERE `Book`.`id` IS NULL"; $expected = " WHERE `Book`.`id` IS NULL";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('Listing.beds >=' => 0)); $result = $this->Dbo->conditions(array('Listing.beds >=' => 0));
$expected = " WHERE `Listing`.`beds` >= 0"; $expected = " WHERE `Listing`.`beds` >= 0";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array( $result = $this->Dbo->conditions(array(
'ASCII(SUBSTRING(keyword, 1, 1)) BETWEEN ? AND ?' => array(65, 90) 'ASCII(SUBSTRING(keyword, 1, 1)) BETWEEN ? AND ?' => array(65, 90)
)); ));
$expected = ' WHERE ASCII(SUBSTRING(keyword, 1, 1)) BETWEEN 65 AND 90'; $expected = ' WHERE ASCII(SUBSTRING(keyword, 1, 1)) BETWEEN 65 AND 90';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('or' => array( $result = $this->Dbo->conditions(array('or' => array(
'? BETWEEN Model.field1 AND Model.field2' => '2009-03-04' '? BETWEEN Model.field1 AND Model.field2' => '2009-03-04'
))); )));
$expected = " WHERE '2009-03-04' BETWEEN Model.field1 AND Model.field2"; $expected = " WHERE '2009-03-04' BETWEEN Model.field1 AND Model.field2";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -2254,19 +2254,19 @@ class DboMysqlTest extends CakeTestCase {
'CAST(Book.created AS DATE)' => '2008-08-02' 'CAST(Book.created AS DATE)' => '2008-08-02'
)); ));
$expected = " WHERE CAST(`Book`.`created` AS DATE) = '2008-08-02'"; $expected = " WHERE CAST(`Book`.`created` AS DATE) = '2008-08-02'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array( $result = $this->Dbo->conditions(array(
'CAST(Book.created AS DATE) <=' => '2008-08-02' 'CAST(Book.created AS DATE) <=' => '2008-08-02'
)); ));
$expected = " WHERE CAST(`Book`.`created` AS DATE) <= '2008-08-02'"; $expected = " WHERE CAST(`Book`.`created` AS DATE) <= '2008-08-02'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array( $result = $this->Dbo->conditions(array(
'(Stats.clicks * 100) / Stats.views >' => 50 '(Stats.clicks * 100) / Stats.views >' => 50
)); ));
$expected = " WHERE (`Stats`.`clicks` * 100) / `Stats`.`views` > 50"; $expected = " WHERE (`Stats`.`clicks` * 100) / `Stats`.`views` > 50";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -2280,7 +2280,7 @@ class DboMysqlTest extends CakeTestCase {
$conditions[] = array('User.last_name' => 'Lastname'); $conditions[] = array('User.last_name' => 'Lastname');
$result = $this->Dbo->conditions($conditions); $result = $this->Dbo->conditions($conditions);
$expected = " WHERE `User`.`first_name` = 'Firstname' AND `User`.`last_name` = 'Lastname'"; $expected = " WHERE `User`.`first_name` = 'Firstname' AND `User`.`last_name` = 'Lastname'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$conditions = array( $conditions = array(
'Thread.project_id' => 5, 'Thread.project_id' => 5,
@ -2316,27 +2316,27 @@ class DboMysqlTest extends CakeTestCase {
$result = $this->Dbo->conditions(array('Article2.viewed >=' => 0), true, true, $this->Model); $result = $this->Dbo->conditions(array('Article2.viewed >=' => 0), true, true, $this->Model);
$expected = " WHERE `Article2`.`viewed` >= 0"; $expected = " WHERE `Article2`.`viewed` >= 0";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('Article2.viewed >=' => '0'), true, true, $this->Model); $result = $this->Dbo->conditions(array('Article2.viewed >=' => '0'), true, true, $this->Model);
$expected = " WHERE `Article2`.`viewed` >= 0"; $expected = " WHERE `Article2`.`viewed` >= 0";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('Article2.viewed >=' => '1'), true, true, $this->Model); $result = $this->Dbo->conditions(array('Article2.viewed >=' => '1'), true, true, $this->Model);
$expected = " WHERE `Article2`.`viewed` >= 1"; $expected = " WHERE `Article2`.`viewed` >= 1";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('Article2.rate_sum BETWEEN ? AND ?' => array(0, 10)), true, true, $this->Model); $result = $this->Dbo->conditions(array('Article2.rate_sum BETWEEN ? AND ?' => array(0, 10)), true, true, $this->Model);
$expected = " WHERE `Article2`.`rate_sum` BETWEEN 0 AND 10"; $expected = " WHERE `Article2`.`rate_sum` BETWEEN 0 AND 10";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('Article2.rate_sum BETWEEN ? AND ?' => array('0', '10')), true, true, $this->Model); $result = $this->Dbo->conditions(array('Article2.rate_sum BETWEEN ? AND ?' => array('0', '10')), true, true, $this->Model);
$expected = " WHERE `Article2`.`rate_sum` BETWEEN 0 AND 10"; $expected = " WHERE `Article2`.`rate_sum` BETWEEN 0 AND 10";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->conditions(array('Article2.rate_sum BETWEEN ? AND ?' => array('1', '10')), true, true, $this->Model); $result = $this->Dbo->conditions(array('Article2.rate_sum BETWEEN ? AND ?' => array('1', '10')), true, true, $this->Model);
$expected = " WHERE `Article2`.`rate_sum` BETWEEN 1 AND 10"; $expected = " WHERE `Article2`.`rate_sum` BETWEEN 1 AND 10";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -2349,15 +2349,15 @@ class DboMysqlTest extends CakeTestCase {
$this->Model = new TestModel(); $this->Model = new TestModel();
$result = $this->Dbo->fields($this->Model, 'Vendor', "Vendor.id, COUNT(Model.vendor_id) AS `Vendor`.`count`"); $result = $this->Dbo->fields($this->Model, 'Vendor', "Vendor.id, COUNT(Model.vendor_id) AS `Vendor`.`count`");
$expected = array('`Vendor`.`id`', 'COUNT(`Model`.`vendor_id`) AS `Vendor`.`count`'); $expected = array('`Vendor`.`id`', 'COUNT(`Model`.`vendor_id`) AS `Vendor`.`count`');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($this->Model, 'Vendor', "`Vendor`.`id`, COUNT(`Model`.`vendor_id`) AS `Vendor`.`count`"); $result = $this->Dbo->fields($this->Model, 'Vendor', "`Vendor`.`id`, COUNT(`Model`.`vendor_id`) AS `Vendor`.`count`");
$expected = array('`Vendor`.`id`', 'COUNT(`Model`.`vendor_id`) AS `Vendor`.`count`'); $expected = array('`Vendor`.`id`', 'COUNT(`Model`.`vendor_id`) AS `Vendor`.`count`');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($this->Model, 'Post', "CONCAT(REPEAT(' ', COUNT(Parent.name) - 1), Node.name) AS name, Node.created"); $result = $this->Dbo->fields($this->Model, 'Post', "CONCAT(REPEAT(' ', COUNT(Parent.name) - 1), Node.name) AS name, Node.created");
$expected = array("CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name", "`Node`.`created`"); $expected = array("CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name", "`Node`.`created`");
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($this->Model, null, 'round( (3.55441 * fooField), 3 ) AS test'); $result = $this->Dbo->fields($this->Model, null, 'round( (3.55441 * fooField), 3 ) AS test');
$this->assertEqual($result, array('round( (3.55441 * fooField), 3 ) AS test')); $this->assertEqual($result, array('round( (3.55441 * fooField), 3 ) AS test'));
@ -2370,18 +2370,18 @@ class DboMysqlTest extends CakeTestCase {
$result = $this->Dbo->fields($this->Model, 'Post', "Node.created, CONCAT(REPEAT(' ', COUNT(Parent.name) - 1), Node.name) AS name"); $result = $this->Dbo->fields($this->Model, 'Post', "Node.created, CONCAT(REPEAT(' ', COUNT(Parent.name) - 1), Node.name) AS name");
$expected = array("`Node`.`created`", "CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name"); $expected = array("`Node`.`created`", "CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name");
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($this->Model, 'Post', "2.2,COUNT(*), SUM(Something.else) as sum, Node.created, CONCAT(REPEAT(' ', COUNT(Parent.name) - 1), Node.name) AS name,Post.title,Post.1,1.1"); $result = $this->Dbo->fields($this->Model, 'Post', "2.2,COUNT(*), SUM(Something.else) as sum, Node.created, CONCAT(REPEAT(' ', COUNT(Parent.name) - 1), Node.name) AS name,Post.title,Post.1,1.1");
$expected = array( $expected = array(
'2.2', 'COUNT(*)', 'SUM(`Something`.`else`) as sum', '`Node`.`created`', '2.2', 'COUNT(*)', 'SUM(`Something`.`else`) as sum', '`Node`.`created`',
"CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name", '`Post`.`title`', '`Post`.`1`', '1.1' "CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name", '`Post`.`title`', '`Post`.`1`', '1.1'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($this->Model, null, "(`Provider`.`star_total` / `Provider`.`total_ratings`) as `rating`"); $result = $this->Dbo->fields($this->Model, null, "(`Provider`.`star_total` / `Provider`.`total_ratings`) as `rating`");
$expected = array("(`Provider`.`star_total` / `Provider`.`total_ratings`) as `rating`"); $expected = array("(`Provider`.`star_total` / `Provider`.`total_ratings`) as `rating`");
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($this->Model, 'Post'); $result = $this->Dbo->fields($this->Model, 'Post');
$expected = array( $expected = array(
@ -2391,7 +2391,7 @@ class DboMysqlTest extends CakeTestCase {
'`Post`.`url`', '`Post`.`email`', '`Post`.`comments`', '`Post`.`last_login`', '`Post`.`url`', '`Post`.`email`', '`Post`.`comments`', '`Post`.`last_login`',
'`Post`.`created`', '`Post`.`updated`' '`Post`.`created`', '`Post`.`updated`'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($this->Model, 'Other'); $result = $this->Dbo->fields($this->Model, 'Other');
$expected = array( $expected = array(
@ -2401,27 +2401,27 @@ class DboMysqlTest extends CakeTestCase {
'`Other`.`url`', '`Other`.`email`', '`Other`.`comments`', '`Other`.`last_login`', '`Other`.`url`', '`Other`.`email`', '`Other`.`comments`', '`Other`.`last_login`',
'`Other`.`created`', '`Other`.`updated`' '`Other`.`created`', '`Other`.`updated`'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($this->Model, null, array(), false); $result = $this->Dbo->fields($this->Model, null, array(), false);
$expected = array('id', 'client_id', 'name', 'login', 'passwd', 'addr_1', 'addr_2', 'zip_code', 'city', 'country', 'phone', 'fax', 'url', 'email', 'comments', 'last_login', 'created', 'updated'); $expected = array('id', 'client_id', 'name', 'login', 'passwd', 'addr_1', 'addr_2', 'zip_code', 'city', 'country', 'phone', 'fax', 'url', 'email', 'comments', 'last_login', 'created', 'updated');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($this->Model, null, 'COUNT(*)'); $result = $this->Dbo->fields($this->Model, null, 'COUNT(*)');
$expected = array('COUNT(*)'); $expected = array('COUNT(*)');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($this->Model, null, 'SUM(Thread.unread_buyer) AS ' . $this->Dbo->name('sum_unread_buyer')); $result = $this->Dbo->fields($this->Model, null, 'SUM(Thread.unread_buyer) AS ' . $this->Dbo->name('sum_unread_buyer'));
$expected = array('SUM(`Thread`.`unread_buyer`) AS `sum_unread_buyer`'); $expected = array('SUM(`Thread`.`unread_buyer`) AS `sum_unread_buyer`');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($this->Model, null, 'name, count(*)'); $result = $this->Dbo->fields($this->Model, null, 'name, count(*)');
$expected = array('`TestModel`.`name`', 'count(*)'); $expected = array('`TestModel`.`name`', 'count(*)');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($this->Model, null, 'count(*), name'); $result = $this->Dbo->fields($this->Model, null, 'count(*), name');
$expected = array('count(*)', '`TestModel`.`name`'); $expected = array('count(*)', '`TestModel`.`name`');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields( $result = $this->Dbo->fields(
$this->Model, null, 'field1, field2, field3, count(*), name' $this->Model, null, 'field1, field2, field3, count(*), name'
@ -2430,29 +2430,29 @@ class DboMysqlTest extends CakeTestCase {
'`TestModel`.`field1`', '`TestModel`.`field2`', '`TestModel`.`field1`', '`TestModel`.`field2`',
'`TestModel`.`field3`', 'count(*)', '`TestModel`.`name`' '`TestModel`.`field3`', 'count(*)', '`TestModel`.`name`'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($this->Model, null, array('dayofyear(now())')); $result = $this->Dbo->fields($this->Model, null, array('dayofyear(now())'));
$expected = array('dayofyear(now())'); $expected = array('dayofyear(now())');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($this->Model, null, array('MAX(Model.field) As Max')); $result = $this->Dbo->fields($this->Model, null, array('MAX(Model.field) As Max'));
$expected = array('MAX(`Model`.`field`) As Max'); $expected = array('MAX(`Model`.`field`) As Max');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($this->Model, null, array('Model.field AS AnotherName')); $result = $this->Dbo->fields($this->Model, null, array('Model.field AS AnotherName'));
$expected = array('`Model`.`field` AS `AnotherName`'); $expected = array('`Model`.`field` AS `AnotherName`');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($this->Model, null, array('field AS AnotherName')); $result = $this->Dbo->fields($this->Model, null, array('field AS AnotherName'));
$expected = array('`field` AS `AnotherName`'); $expected = array('`field` AS `AnotherName`');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($this->Model, null, array( $result = $this->Dbo->fields($this->Model, null, array(
'TestModel.field AS AnotherName' 'TestModel.field AS AnotherName'
)); ));
$expected = array('`TestModel`.`field` AS `AnotherName`'); $expected = array('`TestModel`.`field` AS `AnotherName`');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($this->Model, 'Foo', array( $result = $this->Dbo->fields($this->Model, 'Foo', array(
'id', 'title', '(user_count + discussion_count + post_count) AS score' 'id', 'title', '(user_count + discussion_count + post_count) AS score'
@ -2462,7 +2462,7 @@ class DboMysqlTest extends CakeTestCase {
'`Foo`.`title`', '`Foo`.`title`',
'(user_count + discussion_count + post_count) AS score' '(user_count + discussion_count + post_count) AS score'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -2478,7 +2478,7 @@ class DboMysqlTest extends CakeTestCase {
'`TestModel`.`id`', '`TestModel`.`id`',
"CASE Sample.id WHEN 1 THEN 'Id One' ELSE 'Other Id' END AS case_col" "CASE Sample.id WHEN 1 THEN 'Id One' ELSE 'Other Id' END AS case_col"
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -2537,7 +2537,7 @@ class DboMysqlTest extends CakeTestCase {
function testOrderParsing() { function testOrderParsing() {
$result = $this->Dbo->order("ADDTIME(Event.time_begin, '-06:00:00') ASC"); $result = $this->Dbo->order("ADDTIME(Event.time_begin, '-06:00:00') ASC");
$expected = " ORDER BY ADDTIME(`Event`.`time_begin`, '-06:00:00') ASC"; $expected = " ORDER BY ADDTIME(`Event`.`time_begin`, '-06:00:00') ASC";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->order("title, id"); $result = $this->Dbo->order("title, id");
$this->assertPattern('/^\s*ORDER BY\s+`title`\s+ASC,\s+`id`\s+ASC\s*$/', $result); $this->assertPattern('/^\s*ORDER BY\s+`title`\s+ASC,\s+`id`\s+ASC\s*$/', $result);
@ -2568,7 +2568,7 @@ class DboMysqlTest extends CakeTestCase {
$result = $this->Dbo->order("Dealer.id = 7 desc, Dealer.id = 3 desc, Dealer.title asc"); $result = $this->Dbo->order("Dealer.id = 7 desc, Dealer.id = 3 desc, Dealer.title asc");
$expected = " ORDER BY `Dealer`.`id` = 7 desc, `Dealer`.`id` = 3 desc, `Dealer`.`title` asc"; $expected = " ORDER BY `Dealer`.`id` = 7 desc, `Dealer`.`id` = 3 desc, `Dealer`.`title` asc";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->order(array("Page.name" => "='test' DESC")); $result = $this->Dbo->order(array("Page.name" => "='test' DESC"));
$this->assertPattern("/^\s*ORDER BY\s+`Page`\.`name`\s*='test'\s+DESC\s*$/", $result); $this->assertPattern("/^\s*ORDER BY\s+`Page`\.`name`\s*='test'\s+DESC\s*$/", $result);
@ -2593,15 +2593,15 @@ class DboMysqlTest extends CakeTestCase {
$result = $this->Dbo->order("Anuncio.destaque & 2 DESC"); $result = $this->Dbo->order("Anuncio.destaque & 2 DESC");
$expected = ' ORDER BY `Anuncio`.`destaque` & 2 DESC'; $expected = ' ORDER BY `Anuncio`.`destaque` & 2 DESC';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->order("3963.191 * id"); $result = $this->Dbo->order("3963.191 * id");
$expected = ' ORDER BY 3963.191 * id ASC'; $expected = ' ORDER BY 3963.191 * id ASC';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->order(array('Property.sale_price IS NULL')); $result = $this->Dbo->order(array('Property.sale_price IS NULL'));
$expected = ' ORDER BY `Property`.`sale_price` IS NULL ASC'; $expected = ' ORDER BY `Property`.`sale_price` IS NULL ASC';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -2666,27 +2666,27 @@ class DboMysqlTest extends CakeTestCase {
function testLength() { function testLength() {
$result = $this->Dbo->length('varchar(255)'); $result = $this->Dbo->length('varchar(255)');
$expected = 255; $expected = 255;
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$result = $this->Dbo->length('int(11)'); $result = $this->Dbo->length('int(11)');
$expected = 11; $expected = 11;
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$result = $this->Dbo->length('float(5,3)'); $result = $this->Dbo->length('float(5,3)');
$expected = '5,3'; $expected = '5,3';
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$result = $this->Dbo->length('decimal(5,2)'); $result = $this->Dbo->length('decimal(5,2)');
$expected = '5,2'; $expected = '5,2';
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$result = $this->Dbo->length("enum('test','me','now')"); $result = $this->Dbo->length("enum('test','me','now')");
$expected = 4; $expected = 4;
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$result = $this->Dbo->length("set('a','b','cd')"); $result = $this->Dbo->length("set('a','b','cd')");
$expected = 2; $expected = 2;
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$this->expectError(); $this->expectError();
$result = $this->Dbo->length(false); $result = $this->Dbo->length(false);
@ -2694,11 +2694,11 @@ class DboMysqlTest extends CakeTestCase {
$result = $this->Dbo->length('datetime'); $result = $this->Dbo->length('datetime');
$expected = null; $expected = null;
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$result = $this->Dbo->length('text'); $result = $this->Dbo->length('text');
$expected = null; $expected = null;
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
} }
/** /**
@ -2713,21 +2713,21 @@ class DboMysqlTest extends CakeTestCase {
); );
$result = $this->Dbo->buildIndex($data); $result = $this->Dbo->buildIndex($data);
$expected = array('PRIMARY KEY (`id`)'); $expected = array('PRIMARY KEY (`id`)');
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$data = array( $data = array(
'MyIndex' => array('column' => 'id', 'unique' => true) 'MyIndex' => array('column' => 'id', 'unique' => true)
); );
$result = $this->Dbo->buildIndex($data); $result = $this->Dbo->buildIndex($data);
$expected = array('UNIQUE KEY `MyIndex` (`id`)'); $expected = array('UNIQUE KEY `MyIndex` (`id`)');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
'MyIndex' => array('column' => array('id', 'name'), 'unique' => true) 'MyIndex' => array('column' => array('id', 'name'), 'unique' => true)
); );
$result = $this->Dbo->buildIndex($data); $result = $this->Dbo->buildIndex($data);
$expected = array('UNIQUE KEY `MyIndex` (`id`, `name`)'); $expected = array('UNIQUE KEY `MyIndex` (`id`, `name`)');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -2757,7 +2757,7 @@ class DboMysqlTest extends CakeTestCase {
); );
$result = $this->Dbo->buildColumn($data); $result = $this->Dbo->buildColumn($data);
$expected = '`testName` varchar(255) DEFAULT NULL'; $expected = '`testName` varchar(255) DEFAULT NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
'name' => 'int_field', 'name' => 'int_field',
@ -2770,7 +2770,7 @@ class DboMysqlTest extends CakeTestCase {
$this->Dbo->columns = array('integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'), ); $this->Dbo->columns = array('integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'), );
$result = $this->Dbo->buildColumn($data); $result = $this->Dbo->buildColumn($data);
$expected = '`int_field` int(11) NOT NULL'; $expected = '`int_field` int(11) NOT NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Dbo->fieldParameters['param'] = array( $this->Dbo->fieldParameters['param'] = array(
'value' => 'COLLATE', 'value' => 'COLLATE',
@ -2789,7 +2789,7 @@ class DboMysqlTest extends CakeTestCase {
); );
$result = $this->Dbo->buildColumn($data); $result = $this->Dbo->buildColumn($data);
$expected = '`int_field` int(11) NOT NULL'; $expected = '`int_field` int(11) NOT NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
'name' => 'int_field', 'name' => 'int_field',
@ -2800,7 +2800,7 @@ class DboMysqlTest extends CakeTestCase {
); );
$result = $this->Dbo->buildColumn($data); $result = $this->Dbo->buildColumn($data);
$expected = '`int_field` int(11) COLLATE GOOD NOT NULL'; $expected = '`int_field` int(11) COLLATE GOOD NOT NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Dbo->columns = $restore; $this->Dbo->columns = $restore;
@ -2812,7 +2812,7 @@ class DboMysqlTest extends CakeTestCase {
); );
$result = $this->Dbo->buildColumn($data); $result = $this->Dbo->buildColumn($data);
$expected = '`created` timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL'; $expected = '`created` timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
'name' => 'created', 'name' => 'created',
@ -2822,7 +2822,7 @@ class DboMysqlTest extends CakeTestCase {
); );
$result = $this->Dbo->buildColumn($data); $result = $this->Dbo->buildColumn($data);
$expected = '`created` timestamp DEFAULT CURRENT_TIMESTAMP'; $expected = '`created` timestamp DEFAULT CURRENT_TIMESTAMP';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
'name' => 'modified', 'name' => 'modified',
@ -2831,7 +2831,7 @@ class DboMysqlTest extends CakeTestCase {
); );
$result = $this->Dbo->buildColumn($data); $result = $this->Dbo->buildColumn($data);
$expected = '`modified` timestamp NULL'; $expected = '`modified` timestamp NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
'name' => 'modified', 'name' => 'modified',
@ -2841,7 +2841,7 @@ class DboMysqlTest extends CakeTestCase {
); );
$result = $this->Dbo->buildColumn($data); $result = $this->Dbo->buildColumn($data);
$expected = '`modified` timestamp NULL'; $expected = '`modified` timestamp NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -2867,7 +2867,7 @@ class DboMysqlTest extends CakeTestCase {
$this->Dbo->hasAny($this->Model, array('TestModel.name' => 'harry')); $this->Dbo->hasAny($this->Model, array('TestModel.name' => 'harry'));
$this->Dbo->hasAny($this->Model, array()); $this->Dbo->hasAny($this->Model, array());
} }
/** /**
@ -3143,7 +3143,7 @@ class DboMysqlTest extends CakeTestCase {
$commentTable = $this->Dbo->fullTableName('comments'); $commentTable = $this->Dbo->fullTableName('comments');
$Article = ClassRegistry::init('Article'); $Article = ClassRegistry::init('Article');
$Article->virtualFields = array( $Article->virtualFields = array(
'comment_count' => 'SELECT COUNT(*) FROM ' . $commentTable . 'comment_count' => 'SELECT COUNT(*) FROM ' . $commentTable .
' AS Comment WHERE Article.id = Comment.article_id' ' AS Comment WHERE Article.id = Comment.article_id'
); );
$result = $Article->find('all'); $result = $Article->find('all');
@ -3345,7 +3345,7 @@ class DboMysqlTest extends CakeTestCase {
'color' => 'Red 1', 'color' => 'Red 1',
'name' => 'Red Apple 1' 'name' => 'Red Apple 1'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fetchAll('SELECT name FROM ' . $this->Dbo->fullTableName('apples') . ' ORDER BY id'); $result = $this->Dbo->fetchAll('SELECT name FROM ' . $this->Dbo->fullTableName('apples') . ' ORDER BY id');
$expected = array( $expected = array(
@ -3357,14 +3357,14 @@ class DboMysqlTest extends CakeTestCase {
array($this->Dbo->fullTableName('apples', false) => array('name' => 'My new apple')), array($this->Dbo->fullTableName('apples', false) => array('name' => 'My new apple')),
array($this->Dbo->fullTableName('apples', false) => array('name' => 'Some odd color')) array($this->Dbo->fullTableName('apples', false) => array('name' => 'Some odd color'))
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->field($this->Dbo->fullTableName('apples', false), 'SELECT color, name FROM ' . $this->Dbo->fullTableName('apples') . ' ORDER BY id'); $result = $this->Dbo->field($this->Dbo->fullTableName('apples', false), 'SELECT color, name FROM ' . $this->Dbo->fullTableName('apples') . ' ORDER BY id');
$expected = array( $expected = array(
'color' => 'Red 1', 'color' => 'Red 1',
'name' => 'Red Apple 1' 'name' => 'Red Apple 1'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$Apple->unbindModel(array(), false); $Apple->unbindModel(array(), false);
$result = $this->Dbo->read($Apple, array( $result = $this->Dbo->read($Apple, array(
@ -3381,7 +3381,7 @@ class DboMysqlTest extends CakeTestCase {
array('Apple' => array('name' => 'My new apple')), array('Apple' => array('name' => 'My new apple')),
array('Apple' => array('name' => 'Some odd color')) array('Apple' => array('name' => 'Some odd color'))
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->read($Article, array( $result = $this->Dbo->read($Article, array(
'fields' => array('id', 'user_id', 'title'), 'fields' => array('id', 'user_id', 'title'),

View file

@ -285,17 +285,17 @@ class DboPostgresTest extends CakeTestCase {
$result = $this->Dbo->fields($this->model); $result = $this->Dbo->fields($this->model);
$expected = $fields; $expected = $fields;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($this->model, null, 'PostgresTestModel.*'); $result = $this->Dbo->fields($this->model, null, 'PostgresTestModel.*');
$expected = $fields; $expected = $fields;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($this->model, null, array('*', 'AnotherModel.id', 'AnotherModel.name')); $result = $this->Dbo->fields($this->model, null, array('*', 'AnotherModel.id', 'AnotherModel.name'));
$expected = array_merge($fields, array( $expected = array_merge($fields, array(
'"AnotherModel"."id" AS "AnotherModel__id"', '"AnotherModel"."id" AS "AnotherModel__id"',
'"AnotherModel"."name" AS "AnotherModel__name"')); '"AnotherModel"."name" AS "AnotherModel__name"'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($this->model, null, array('*', 'PostgresClientTestModel.*')); $result = $this->Dbo->fields($this->model, null, array('*', 'PostgresClientTestModel.*'));
$expected = array_merge($fields, array( $expected = array_merge($fields, array(
@ -304,7 +304,7 @@ class DboPostgresTest extends CakeTestCase {
'"PostgresClientTestModel"."email" AS "PostgresClientTestModel__email"', '"PostgresClientTestModel"."email" AS "PostgresClientTestModel__email"',
'"PostgresClientTestModel"."created" AS "PostgresClientTestModel__created"', '"PostgresClientTestModel"."created" AS "PostgresClientTestModel__created"',
'"PostgresClientTestModel"."updated" AS "PostgresClientTestModel__updated"')); '"PostgresClientTestModel"."updated" AS "PostgresClientTestModel__updated"'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -792,7 +792,7 @@ class DboPostgresTest extends CakeTestCase {
function testOrderAdditionalParams() { function testOrderAdditionalParams() {
$result = $this->Dbo->order(array('title' => 'DESC NULLS FIRST', 'body' => 'DESC')); $result = $this->Dbo->order(array('title' => 'DESC NULLS FIRST', 'body' => 'DESC'));
$expected = ' ORDER BY "title" DESC NULLS FIRST, "body" DESC'; $expected = ' ORDER BY "title" DESC NULLS FIRST, "body" DESC';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -803,15 +803,15 @@ class DboPostgresTest extends CakeTestCase {
$Article = new Article; $Article = new Article;
$result = $this->Dbo->fields($Article, null, array('COUNT(DISTINCT Article.id)')); $result = $this->Dbo->fields($Article, null, array('COUNT(DISTINCT Article.id)'));
$expected = array('COUNT(DISTINCT "Article"."id")'); $expected = array('COUNT(DISTINCT "Article"."id")');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($Article, null, array('COUNT(DISTINCT id)')); $result = $this->Dbo->fields($Article, null, array('COUNT(DISTINCT id)'));
$expected = array('COUNT(DISTINCT "id")'); $expected = array('COUNT(DISTINCT "id")');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Dbo->fields($Article, null, array('COUNT(DISTINCT FUNC(id))')); $result = $this->Dbo->fields($Article, null, array('COUNT(DISTINCT FUNC(id))'));
$expected = array('COUNT(DISTINCT FUNC("id"))'); $expected = array('COUNT(DISTINCT FUNC("id"))');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**

View file

@ -198,7 +198,7 @@ class DboSqliteTest extends CakeTestCase {
); );
$result = $this->Dbo->buildColumn($data); $result = $this->Dbo->buildColumn($data);
$expected = '"int_field" integer NOT NULL'; $expected = '"int_field" integer NOT NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
'name' => 'name', 'name' => 'name',
@ -208,7 +208,7 @@ class DboSqliteTest extends CakeTestCase {
); );
$result = $this->Dbo->buildColumn($data); $result = $this->Dbo->buildColumn($data);
$expected = '"name" varchar(20) NOT NULL'; $expected = '"name" varchar(20) NOT NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
'name' => 'testName', 'name' => 'testName',
@ -220,7 +220,7 @@ class DboSqliteTest extends CakeTestCase {
); );
$result = $this->Dbo->buildColumn($data); $result = $this->Dbo->buildColumn($data);
$expected = '"testName" varchar(20) DEFAULT NULL COLLATE NOCASE'; $expected = '"testName" varchar(20) DEFAULT NULL COLLATE NOCASE';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
'name' => 'testName', 'name' => 'testName',
@ -231,7 +231,7 @@ class DboSqliteTest extends CakeTestCase {
); );
$result = $this->Dbo->buildColumn($data); $result = $this->Dbo->buildColumn($data);
$expected = '"testName" varchar(20) DEFAULT \'test-value\' NOT NULL'; $expected = '"testName" varchar(20) DEFAULT \'test-value\' NOT NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
'name' => 'testName', 'name' => 'testName',
@ -242,8 +242,8 @@ class DboSqliteTest extends CakeTestCase {
); );
$result = $this->Dbo->buildColumn($data); $result = $this->Dbo->buildColumn($data);
$expected = '"testName" integer(10) DEFAULT 10 NOT NULL'; $expected = '"testName" integer(10) DEFAULT 10 NOT NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
'name' => 'testName', 'name' => 'testName',
'type' => 'integer', 'type' => 'integer',
@ -254,7 +254,7 @@ class DboSqliteTest extends CakeTestCase {
); );
$result = $this->Dbo->buildColumn($data); $result = $this->Dbo->buildColumn($data);
$expected = '"testName" integer(10) DEFAULT 10 NOT NULL'; $expected = '"testName" integer(10) DEFAULT 10 NOT NULL';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -299,7 +299,7 @@ class DboSqliteTest extends CakeTestCase {
'length' => null, 'length' => null,
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**

View file

@ -24,7 +24,7 @@ App::uses('DboSource', 'Model/Datasource');
require_once dirname(dirname(__FILE__)) . DS . 'models.php'; require_once dirname(dirname(__FILE__)) . DS . 'models.php';
class MockDataSource extends DataSource { class MockDataSource extends DataSource {
} }
/** /**
@ -155,7 +155,7 @@ class DboSourceTest extends CakeTestCase {
$expression = $this->testDb->expression("CASE Sample.id WHEN 1 THEN 'Id One' ELSE 'Other Id' END AS case_col"); $expression = $this->testDb->expression("CASE Sample.id WHEN 1 THEN 'Id One' ELSE 'Other Id' END AS case_col");
$result = $this->testDb->order($expression); $result = $this->testDb->order($expression);
$expected = " ORDER BY CASE Sample.id WHEN 1 THEN 'Id One' ELSE 'Other Id' END AS case_col"; $expected = " ORDER BY CASE Sample.id WHEN 1 THEN 'Id One' ELSE 'Other Id' END AS case_col";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -445,14 +445,14 @@ class DboSourceTest extends CakeTestCase {
'conditions' => array('TestModel.field_name' => 'value'), 'conditions' => array('TestModel.field_name' => 'value'),
'fields' => null, 'order' => null, 'recursive' => null 'fields' => null, 'order' => null, 'recursive' => null
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->testDb->query('findByFindBy', array('value'), $this->Model); $result = $this->testDb->query('findByFindBy', array('value'), $this->Model);
$expected = array('first', array( $expected = array('first', array(
'conditions' => array('TestModel.find_by' => 'value'), 'conditions' => array('TestModel.find_by' => 'value'),
'fields' => null, 'order' => null, 'recursive' => null 'fields' => null, 'order' => null, 'recursive' => null
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->testDb->query('findAllByFieldName', array('value'), $this->Model); $result = $this->testDb->query('findAllByFieldName', array('value'), $this->Model);
$expected = array('all', array( $expected = array('all', array(
@ -460,7 +460,7 @@ class DboSourceTest extends CakeTestCase {
'fields' => null, 'order' => null, 'limit' => null, 'fields' => null, 'order' => null, 'limit' => null,
'page' => null, 'recursive' => null 'page' => null, 'recursive' => null
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->testDb->query('findAllById', array('a'), $this->Model); $result = $this->testDb->query('findAllById', array('a'), $this->Model);
$expected = array('all', array( $expected = array('all', array(
@ -468,32 +468,32 @@ class DboSourceTest extends CakeTestCase {
'fields' => null, 'order' => null, 'limit' => null, 'fields' => null, 'order' => null, 'limit' => null,
'page' => null, 'recursive' => null 'page' => null, 'recursive' => null
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->testDb->query('findByFieldName', array(array('value1', 'value2', 'value3')), $this->Model); $result = $this->testDb->query('findByFieldName', array(array('value1', 'value2', 'value3')), $this->Model);
$expected = array('first', array( $expected = array('first', array(
'conditions' => array('TestModel.field_name' => array('value1', 'value2', 'value3')), 'conditions' => array('TestModel.field_name' => array('value1', 'value2', 'value3')),
'fields' => null, 'order' => null, 'recursive' => null 'fields' => null, 'order' => null, 'recursive' => null
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->testDb->query('findByFieldName', array(null), $this->Model); $result = $this->testDb->query('findByFieldName', array(null), $this->Model);
$expected = array('first', array( $expected = array('first', array(
'conditions' => array('TestModel.field_name' => null), 'conditions' => array('TestModel.field_name' => null),
'fields' => null, 'order' => null, 'recursive' => null 'fields' => null, 'order' => null, 'recursive' => null
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->testDb->query('findByFieldName', array('= a'), $this->Model); $result = $this->testDb->query('findByFieldName', array('= a'), $this->Model);
$expected = array('first', array( $expected = array('first', array(
'conditions' => array('TestModel.field_name' => '= a'), 'conditions' => array('TestModel.field_name' => '= a'),
'fields' => null, 'order' => null, 'recursive' => null 'fields' => null, 'order' => null, 'recursive' => null
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->testDb->query('findByFieldName', array(), $this->Model); $result = $this->testDb->query('findByFieldName', array(), $this->Model);
$expected = false; $expected = false;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->testDb->query('directCall', array(), $this->Model); $result = $this->testDb->query('directCall', array(), $this->Model);
$this->assertFalse($result); $this->assertFalse($result);
@ -518,7 +518,7 @@ class DboSourceTest extends CakeTestCase {
$result = $this->testDb->value(array('first', 2, 'third')); $result = $this->testDb->value(array('first', 2, 'third'));
$expected = array('\'first\'', 2, '\'third\''); $expected = array('\'first\'', 2, '\'third\'');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -542,55 +542,55 @@ class DboSourceTest extends CakeTestCase {
function testName() { function testName() {
$result = $this->testDb->name('name'); $result = $this->testDb->name('name');
$expected = '`name`'; $expected = '`name`';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->testDb->name(array('name', 'Model.*')); $result = $this->testDb->name(array('name', 'Model.*'));
$expected = array('`name`', '`Model`.*'); $expected = array('`name`', '`Model`.*');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->testDb->name('MTD()'); $result = $this->testDb->name('MTD()');
$expected = 'MTD()'; $expected = 'MTD()';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->testDb->name('(sm)'); $result = $this->testDb->name('(sm)');
$expected = '(sm)'; $expected = '(sm)';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->testDb->name('name AS x'); $result = $this->testDb->name('name AS x');
$expected = '`name` AS `x`'; $expected = '`name` AS `x`';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->testDb->name('Model.name AS x'); $result = $this->testDb->name('Model.name AS x');
$expected = '`Model`.`name` AS `x`'; $expected = '`Model`.`name` AS `x`';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->testDb->name('Function(Something.foo)'); $result = $this->testDb->name('Function(Something.foo)');
$expected = 'Function(`Something`.`foo`)'; $expected = 'Function(`Something`.`foo`)';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->testDb->name('Function(SubFunction(Something.foo))'); $result = $this->testDb->name('Function(SubFunction(Something.foo))');
$expected = 'Function(SubFunction(`Something`.`foo`))'; $expected = 'Function(SubFunction(`Something`.`foo`))';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->testDb->name('Function(Something.foo) AS x'); $result = $this->testDb->name('Function(Something.foo) AS x');
$expected = 'Function(`Something`.`foo`) AS `x`'; $expected = 'Function(`Something`.`foo`) AS `x`';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->testDb->name('name-with-minus'); $result = $this->testDb->name('name-with-minus');
$expected = '`name-with-minus`'; $expected = '`name-with-minus`';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->testDb->name(array('my-name', 'Foo-Model.*')); $result = $this->testDb->name(array('my-name', 'Foo-Model.*'));
$expected = array('`my-name`', '`Foo-Model`.*'); $expected = array('`my-name`', '`Foo-Model`.*');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->testDb->name(array('Team.P%', 'Team.G/G')); $result = $this->testDb->name(array('Team.P%', 'Team.G/G'));
$expected = array('`Team`.`P%`', '`Team`.`G/G`'); $expected = array('`Team`.`P%`', '`Team`.`G/G`');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->testDb->name('Model.name as y'); $result = $this->testDb->name('Model.name as y');
$expected = '`Model`.`name` AS `y`'; $expected = '`Model`.`name` AS `y`';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -633,7 +633,7 @@ class DboSourceTest extends CakeTestCase {
$log = $this->testDb->getLog(false, false); $log = $this->testDb->getLog(false, false);
$result = Set::extract($log['log'], '/query'); $result = Set::extract($log['log'], '/query');
$expected = array('Query 1', 'Query 2'); $expected = array('Query 1', 'Query 2');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$oldError = $this->testDb->error; $oldError = $this->testDb->error;
$this->testDb->error = true; $this->testDb->error = true;
@ -644,7 +644,7 @@ class DboSourceTest extends CakeTestCase {
$log = $this->testDb->getLog(false, false); $log = $this->testDb->getLog(false, false);
$result = Set::combine($log['log'], '/query', '/error'); $result = Set::combine($log['log'], '/query', '/error');
$expected = array('Query 1' => false, 'Query 2' => false, 'Error 1' => true); $expected = array('Query 1' => false, 'Query 2' => false, 'Error 1' => true);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
Configure::write('debug', 2); Configure::write('debug', 2);
ob_start(); ob_start();
@ -775,7 +775,7 @@ class DboSourceTest extends CakeTestCase {
$Article->tablePrefix = 'tbl_'; $Article->tablePrefix = 'tbl_';
$result = $this->testDb->fullTableName($Article, false); $result = $this->testDb->fullTableName($Article, false);
$this->assertEqual($result, 'tbl_articles'); $this->assertEqual($result, 'tbl_articles');
$Article->useTable = $Article->table = 'with spaces'; $Article->useTable = $Article->table = 'with spaces';
$Article->tablePrefix = ''; $Article->tablePrefix = '';
$result = $this->testDb->fullTableName($Article); $result = $this->testDb->fullTableName($Article);

View file

@ -276,27 +276,27 @@ class AclNodeTest extends CakeTestCase {
$Aco = new DbAcoTest(); $Aco = new DbAcoTest();
$result = Set::extract($Aco->node('Controller1'), '{n}.DbAcoTest.id'); $result = Set::extract($Aco->node('Controller1'), '{n}.DbAcoTest.id');
$expected = array(2, 1); $expected = array(2, 1);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::extract($Aco->node('Controller1/action1'), '{n}.DbAcoTest.id'); $result = Set::extract($Aco->node('Controller1/action1'), '{n}.DbAcoTest.id');
$expected = array(3, 2, 1); $expected = array(3, 2, 1);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::extract($Aco->node('Controller2/action1'), '{n}.DbAcoTest.id'); $result = Set::extract($Aco->node('Controller2/action1'), '{n}.DbAcoTest.id');
$expected = array(7, 6, 1); $expected = array(7, 6, 1);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::extract($Aco->node('Controller1/action2'), '{n}.DbAcoTest.id'); $result = Set::extract($Aco->node('Controller1/action2'), '{n}.DbAcoTest.id');
$expected = array(5, 2, 1); $expected = array(5, 2, 1);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::extract($Aco->node('Controller1/action1/record1'), '{n}.DbAcoTest.id'); $result = Set::extract($Aco->node('Controller1/action1/record1'), '{n}.DbAcoTest.id');
$expected = array(4, 3, 2, 1); $expected = array(4, 3, 2, 1);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::extract($Aco->node('Controller2/action1/record1'), '{n}.DbAcoTest.id'); $result = Set::extract($Aco->node('Controller2/action1/record1'), '{n}.DbAcoTest.id');
$expected = array(8, 7, 6, 1); $expected = array(8, 7, 6, 1);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::extract($Aco->node('Controller2/action3'), '{n}.DbAcoTest.id'); $result = Set::extract($Aco->node('Controller2/action3'), '{n}.DbAcoTest.id');
$this->assertFalse($result); $this->assertFalse($result);
@ -330,12 +330,12 @@ class AclNodeTest extends CakeTestCase {
Configure::write('DbAclbindMode', 'string'); Configure::write('DbAclbindMode', 'string');
$result = Set::extract($Aro->node(array('DbAroUserTest' => array('id' => '1', 'foreign_key' => '1'))), '{n}.DbAroTest.id'); $result = Set::extract($Aro->node(array('DbAroUserTest' => array('id' => '1', 'foreign_key' => '1'))), '{n}.DbAroTest.id');
$expected = array(3, 2, 1); $expected = array(3, 2, 1);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
Configure::write('DbAclbindMode', 'array'); Configure::write('DbAclbindMode', 'array');
$result = Set::extract($Aro->node(array('DbAroUserTest' => array('id' => 4, 'foreign_key' => 2))), '{n}.DbAroTest.id'); $result = Set::extract($Aro->node(array('DbAroUserTest' => array('id' => 4, 'foreign_key' => 2))), '{n}.DbAroTest.id');
$expected = array(4); $expected = array(4);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
* testNodeObjectFind method * testNodeObjectFind method
@ -349,12 +349,12 @@ class AclNodeTest extends CakeTestCase {
$Model->id = 1; $Model->id = 1;
$result = Set::extract($Aro->node($Model), '{n}.DbAroTest.id'); $result = Set::extract($Aro->node($Model), '{n}.DbAroTest.id');
$expected = array(3, 2, 1); $expected = array(3, 2, 1);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$Model->id = 2; $Model->id = 2;
$result = Set::extract($Aro->node($Model), '{n}.DbAroTest.id'); $result = Set::extract($Aro->node($Model), '{n}.DbAroTest.id');
$expected = array(4, 2, 1); $expected = array(4, 2, 1);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
@ -380,6 +380,6 @@ class AclNodeTest extends CakeTestCase {
array('DbAcoTest' => array('id' => '1', 'parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'Application', 'lft' => '1', 'rght' => '4'), 'DbAroTest' => array()), array('DbAcoTest' => array('id' => '1', 'parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'Application', 'lft' => '1', 'rght' => '4'), 'DbAroTest' => array()),
array('DbAcoTest' => array('id' => '2', 'parent_id' => '1', 'model' => null, 'foreign_key' => null, 'alias' => 'Pages', 'lft' => '2', 'rght' => '3', ), 'DbAroTest' => array()) array('DbAcoTest' => array('id' => '2', 'parent_id' => '1', 'model' => null, 'foreign_key' => null, 'alias' => 'Pages', 'lft' => '2', 'rght' => '3', ), 'DbAroTest' => array())
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
} }

View file

@ -101,7 +101,7 @@ class ModelDeleteTest extends BaseModelTest {
'item_id' => 5, 'item_id' => 5,
'portfolio_id' => 1 'portfolio_id' => 1
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$Portfolio->delete(1); $Portfolio->delete(1);
@ -133,7 +133,7 @@ class ModelDeleteTest extends BaseModelTest {
array('ArticlesTag' => array('article_id' => '2', 'tag_id' => '1')), array('ArticlesTag' => array('article_id' => '2', 'tag_id' => '1')),
array('ArticlesTag' => array('article_id' => '2', 'tag_id' => '3')) array('ArticlesTag' => array('article_id' => '2', 'tag_id' => '3'))
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->delete(1); $TestModel->delete(1);
$result = $TestModel->ArticlesTag->find('all'); $result = $TestModel->ArticlesTag->find('all');
@ -142,7 +142,7 @@ class ModelDeleteTest extends BaseModelTest {
array('ArticlesTag' => array('article_id' => '2', 'tag_id' => '1')), array('ArticlesTag' => array('article_id' => '2', 'tag_id' => '1')),
array('ArticlesTag' => array('article_id' => '2', 'tag_id' => '3')) array('ArticlesTag' => array('article_id' => '2', 'tag_id' => '3'))
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -172,7 +172,7 @@ class ModelDeleteTest extends BaseModelTest {
))); )));
$this->assertTrue(is_array($result)); $this->assertTrue(is_array($result));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$Book->delete(1); $Book->delete(1);
@ -182,7 +182,7 @@ class ModelDeleteTest extends BaseModelTest {
$expected = array(); $expected = array();
$this->assertTrue(is_array($result)); $this->assertTrue(is_array($result));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -214,7 +214,7 @@ class ModelDeleteTest extends BaseModelTest {
'id' => 3, 'id' => 3,
'title' => 'Third Article' 'title' => 'Third Article'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->delete(3); $result = $TestModel->delete(3);
$this->assertTrue($result); $this->assertTrue($result);
@ -232,7 +232,7 @@ class ModelDeleteTest extends BaseModelTest {
'title' => 'First Article' 'title' => 'First Article'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
// make sure deleting a non-existent record doesn't break save() // make sure deleting a non-existent record doesn't break save()
// ticket #6293 // ticket #6293
@ -261,10 +261,10 @@ class ModelDeleteTest extends BaseModelTest {
'id' => '8208C7FE-E89C-47C5-B378-DED6C271F9B8')), 'id' => '8208C7FE-E89C-47C5-B378-DED6C271F9B8')),
array('Uuid' => array( array('Uuid' => array(
'id' => 'B607DAB9-88A2-46CF-B57C-842CA9E3B3B3'))); 'id' => 'B607DAB9-88A2-46CF-B57C-842CA9E3B3B3')));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
* test that delete() updates the correct records counterCache() records. * test that delete() updates the correct records counterCache() records.
* *
@ -361,7 +361,7 @@ class ModelDeleteTest extends BaseModelTest {
'published' => 'N' 'published' => 'N'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->deleteAll(array('Article.published' => 'N')); $result = $TestModel->deleteAll(array('Article.published' => 'N'));
$this->assertTrue($result); $this->assertTrue($result);
@ -395,7 +395,7 @@ class ModelDeleteTest extends BaseModelTest {
'title' => 'Fifth Article', 'title' => 'Fifth Article',
'published' => 'Y' 'published' => 'Y'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array('Article.user_id' => array(2, 3)); $data = array('Article.user_id' => array(2, 3));
$result = $TestModel->deleteAll($data, true, true); $result = $TestModel->deleteAll($data, true, true);
@ -418,7 +418,7 @@ class ModelDeleteTest extends BaseModelTest {
'title' => 'Third Article', 'title' => 'Third Article',
'published' => 'Y' 'published' => 'Y'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->deleteAll(array('Article.user_id' => 999)); $result = $TestModel->deleteAll(array('Article.user_id' => 999));
$this->assertTrue($result, 'deleteAll returned false when all no records matched conditions. %s'); $this->assertTrue($result, 'deleteAll returned false when all no records matched conditions. %s');
@ -513,7 +513,7 @@ class ModelDeleteTest extends BaseModelTest {
'article_id' => '2', 'article_id' => '2',
'tag_id' => '3' 'tag_id' => '3'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->delete(1); $TestModel->delete(1);
$result = $TestModel->ArticlesTag->find('all'); $result = $TestModel->ArticlesTag->find('all');
@ -527,7 +527,7 @@ class ModelDeleteTest extends BaseModelTest {
'article_id' => '2', 'article_id' => '2',
'tag_id' => '3' 'tag_id' => '3'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->deleteAll(array('Article.user_id' => 999)); $result = $TestModel->deleteAll(array('Article.user_id' => 999));
$this->assertTrue($result, 'deleteAll returned false when all no records matched conditions. %s'); $this->assertTrue($result, 'deleteAll returned false when all no records matched conditions. %s');

View file

@ -411,7 +411,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->recursive = 0; $TestModel->recursive = 0;
$result = $TestModel->find('all'); $result = $TestModel->find('all');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
foreach ($expected as $key => $value) { foreach ($expected as $key => $value) {
unset($value['Comment'], $value['Tag']); unset($value['Comment'], $value['Tag']);
@ -420,7 +420,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel->recursive = 0; $TestModel->recursive = 0;
$result = $TestModel->find('all'); $result = $TestModel->find('all');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::extract($TestModel->User->find('all'), '{n}.User.id'); $result = Set::extract($TestModel->User->find('all'), '{n}.User.id');
$this->assertEqual($result, array('1', '2', '3', '4')); $this->assertEqual($result, array('1', '2', '3', '4'));
@ -1141,7 +1141,7 @@ class ModelIntegrationTest extends BaseModelTest {
'TestPluginComment' => array() 'TestPluginComment' => array()
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -1185,7 +1185,7 @@ class ModelIntegrationTest extends BaseModelTest {
'counterQuery' => '', 'counterQuery' => '',
'association' => 'hasMany', 'association' => 'hasMany',
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -1210,7 +1210,7 @@ class ModelIntegrationTest extends BaseModelTest {
'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '',
'finderQuery' => '', 'deleteQuery' => '', 'insertQuery' => '' 'finderQuery' => '', 'deleteQuery' => '', 'insertQuery' => ''
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel = new ArticleFeatured(); $TestModel = new ArticleFeatured();
$TestFakeModel = new ArticleFeatured(array('table' => false)); $TestFakeModel = new ArticleFeatured(array('table' => false));
@ -1375,17 +1375,17 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel = new Test(); $TestModel = new Test();
$result = $TestModel->alias; $result = $TestModel->alias;
$expected = 'Test'; $expected = 'Test';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel = new TestAlias(); $TestModel = new TestAlias();
$result = $TestModel->alias; $result = $TestModel->alias;
$expected = 'TestAlias'; $expected = 'TestAlias';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel = new Test(array('alias' => 'AnotherTest')); $TestModel = new Test(array('alias' => 'AnotherTest'));
$result = $TestModel->alias; $result = $TestModel->alias;
$expected = 'AnotherTest'; $expected = 'AnotherTest';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -1475,7 +1475,7 @@ class ModelIntegrationTest extends BaseModelTest {
'created' => '2007-03-18 10:41:23', 'created' => '2007-03-18 10:41:23',
'updated' => '2007-03-18 10:43:31' 'updated' => '2007-03-18 10:43:31'
))))); )))));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('all'); $result = $TestModel->find('all');
$expected = array( $expected = array(
@ -1545,7 +1545,7 @@ class ModelIntegrationTest extends BaseModelTest {
'something_id' => '3', 'something_id' => '3',
'something_else_id' => '1' 'something_else_id' => '1'
))))); )))));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->findById(1); $result = $TestModel->findById(1);
$expected = array( $expected = array(
@ -1570,13 +1570,13 @@ class ModelIntegrationTest extends BaseModelTest {
'something_id' => '1', 'something_id' => '1',
'something_else_id' => '2' 'something_else_id' => '2'
)))); ))));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$expected = $TestModel->findById(1); $expected = $TestModel->findById(1);
$TestModel->set($expected); $TestModel->set($expected);
$TestModel->save(); $TestModel->save();
$result = $TestModel->findById(1); $result = $TestModel->findById(1);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->hasAndBelongsToMany['SomethingElse']['unique'] = false; $TestModel->hasAndBelongsToMany['SomethingElse']['unique'] = false;
$TestModel->create(array( $TestModel->create(array(
@ -1637,7 +1637,7 @@ class ModelIntegrationTest extends BaseModelTest {
'something_else_id' => '3' 'something_else_id' => '3'
)))); ))));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -1694,7 +1694,7 @@ class ModelIntegrationTest extends BaseModelTest {
'father_id' => 0 'father_id' => 0
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->recursive = 3; $TestModel->recursive = 3;
$result = $TestModel->read(null, 1); $result = $TestModel->read(null, 1);
@ -1747,7 +1747,7 @@ class ModelIntegrationTest extends BaseModelTest {
'Father' => array() 'Father' => array()
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -1855,7 +1855,7 @@ class ModelIntegrationTest extends BaseModelTest {
'updated' => '2007-03-18 10:57:31' 'updated' => '2007-03-18 10:57:31'
)))); ))));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -1869,7 +1869,7 @@ class ModelIntegrationTest extends BaseModelTest {
$TestModel = new Test(); $TestModel = new Test();
$result = $TestModel->create(); $result = $TestModel->create();
$expected = array('Test' => array('notes' => 'write some notes here')); $expected = array('Test' => array('notes' => 'write some notes here'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel = new User(); $TestModel = new User();
$result = $TestModel->schema(); $result = $TestModel->schema();
@ -1919,12 +1919,12 @@ class ModelIntegrationTest extends BaseModelTest {
'length' => null 'length' => null
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel = new Article(); $TestModel = new Article();
$result = $TestModel->create(); $result = $TestModel->create();
$expected = array('Article' => array('published' => 'N')); $expected = array('Article' => array('published' => 'N'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$FeaturedModel = new Featured(); $FeaturedModel = new Featured();
$data = array( $data = array(
@ -1990,15 +1990,15 @@ class ModelIntegrationTest extends BaseModelTest {
$result = $TestModel->escapeField('test_field'); $result = $TestModel->escapeField('test_field');
$expected = $db->name('Test.test_field'); $expected = $db->name('Test.test_field');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->escapeField('TestField'); $result = $TestModel->escapeField('TestField');
$expected = $db->name('Test.TestField'); $expected = $db->name('Test.TestField');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->escapeField('DomainHandle', 'Domain'); $result = $TestModel->escapeField('DomainHandle', 'Domain');
$expected = $db->name('Domain.DomainHandle'); $expected = $db->name('Domain.DomainHandle');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
ConnectionManager::create('mock', array('datasource' => 'DboMock')); ConnectionManager::create('mock', array('datasource' => 'DboMock'));
$TestModel->setDataSource('mock'); $TestModel->setDataSource('mock');
@ -2006,7 +2006,7 @@ class ModelIntegrationTest extends BaseModelTest {
$result = $TestModel->escapeField('DomainHandle', 'Domain'); $result = $TestModel->escapeField('DomainHandle', 'Domain');
$expected = $db->name('Domain.DomainHandle'); $expected = $db->name('Domain.DomainHandle');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**

View file

@ -79,7 +79,7 @@ class ModelReadTest extends BaseModelTest {
*/ */
function testGroupBy() { function testGroupBy() {
$db = ConnectionManager::getDataSource('test'); $db = ConnectionManager::getDataSource('test');
$isStrictGroupBy = $this->db instanceof Postgres || $this->db instanceof Sqlite || $this->db instanceof Oracle; $isStrictGroupBy = $this->db instanceof Postgres || $this->db instanceof Sqlite || $this->db instanceof Oracle;
$message = 'Postgres and Oracle have strict GROUP BY and are incompatible with this test.'; $message = 'Postgres and Oracle have strict GROUP BY and are incompatible with this test.';
if ($this->skipIf($isStrictGroupBy, $message )) { if ($this->skipIf($isStrictGroupBy, $message )) {
@ -128,7 +128,7 @@ class ModelReadTest extends BaseModelTest {
'thread_id' => 3, 'thread_id' => 3,
'name' => 'Thread 3, Message 1' 'name' => 'Thread 3, Message 1'
)))); ))));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$rows = $Thread->find('all', array( $rows = $Thread->find('all', array(
'group' => 'Thread.project_id', 'group' => 'Thread.project_id',
@ -142,7 +142,7 @@ class ModelReadTest extends BaseModelTest {
1 => 2, 1 => 2,
2 => 1 2 => 1
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$rows = $Thread->find('all', array( $rows = $Thread->find('all', array(
'group' => 'Thread.project_id', 'group' => 'Thread.project_id',
@ -157,7 +157,7 @@ class ModelReadTest extends BaseModelTest {
1 => 2, 1 => 2,
2 => 1 2 => 1
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $Thread->find('all', array( $result = $Thread->find('all', array(
'conditions' => array('Thread.project_id' => 1), 'conditions' => array('Thread.project_id' => 1),
@ -180,37 +180,37 @@ class ModelReadTest extends BaseModelTest {
'thread_id' => 1, 'thread_id' => 1,
'name' => 'Thread 1, Message 1' 'name' => 'Thread 1, Message 1'
)))); ))));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $Thread->find('all', array( $result = $Thread->find('all', array(
'conditions' => array('Thread.project_id' => 1), 'conditions' => array('Thread.project_id' => 1),
'group' => 'Thread.project_id, Project.id' 'group' => 'Thread.project_id, Project.id'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $Thread->find('all', array( $result = $Thread->find('all', array(
'conditions' => array('Thread.project_id' => 1), 'conditions' => array('Thread.project_id' => 1),
'group' => 'project_id' 'group' => 'project_id'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $Thread->find('all', array( $result = $Thread->find('all', array(
'conditions' => array('Thread.project_id' => 1), 'conditions' => array('Thread.project_id' => 1),
'group' => array('project_id') 'group' => array('project_id')
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $Thread->find('all', array( $result = $Thread->find('all', array(
'conditions' => array('Thread.project_id' => 1), 'conditions' => array('Thread.project_id' => 1),
'group' => array('project_id', 'Project.id') 'group' => array('project_id', 'Project.id')
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $Thread->find('all', array( $result = $Thread->find('all', array(
'conditions' => array('Thread.project_id' => 1), 'conditions' => array('Thread.project_id' => 1),
'group' => array('Thread.project_id', 'Project.id') 'group' => array('Thread.project_id', 'Project.id')
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$expected = array( $expected = array(
array('Product' => array('type' => 'Clothing'), array('price' => 32)), array('Product' => array('type' => 'Clothing'), array('price' => 32)),
@ -223,13 +223,13 @@ class ModelReadTest extends BaseModelTest {
'group'=> 'Product.type', 'group'=> 'Product.type',
'order' => 'Product.type ASC' 'order' => 'Product.type ASC'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $Product->find('all', array( $result = $Product->find('all', array(
'fields'=>array('Product.type', 'MIN(Product.price) as price'), 'fields'=>array('Product.type', 'MIN(Product.price) as price'),
'group'=> array('Product.type'), 'group'=> array('Product.type'),
'order' => 'Product.type ASC')); 'order' => 'Product.type ASC'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -297,7 +297,7 @@ class ModelReadTest extends BaseModelTest {
unset($expected[0][$this->db->fullTableName('articles', false)]); unset($expected[0][$this->db->fullTableName('articles', false)]);
} }
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->db->getQueryCache($query, $params); $result = $this->db->getQueryCache($query, $params);
$this->assertFalse(empty($result)); $this->assertFalse(empty($result));
@ -1083,7 +1083,7 @@ class ModelReadTest extends BaseModelTest {
'name' => '' 'name' => ''
), ),
'Child' => array())); 'Child' => array()));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->Parent->unbindModel(array('hasOne' => array('Sample'))); $result = $TestModel->Parent->unbindModel(array('hasOne' => array('Sample')));
$this->assertTrue($result); $this->assertTrue($result);
@ -1749,7 +1749,7 @@ class ModelReadTest extends BaseModelTest {
'Child' => array() 'Child' => array()
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->Parent->unbindModel(array('hasOne' => array('Sample'))); $result = $TestModel->Parent->unbindModel(array('hasOne' => array('Sample')));
$this->assertTrue($result); $this->assertTrue($result);
@ -2178,7 +2178,7 @@ class ModelReadTest extends BaseModelTest {
'name' => '' 'name' => ''
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->unbindModel(array('hasMany' => array('Child'))); $result = $TestModel->unbindModel(array('hasMany' => array('Child')));
$this->assertTrue($result); $this->assertTrue($result);
@ -2597,7 +2597,7 @@ class ModelReadTest extends BaseModelTest {
'apple_id' => '', 'apple_id' => '',
'name' => '' 'name' => ''
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->Parent->unbindModel(array('belongsTo' => array('Parent'))); $result = $TestModel->Parent->unbindModel(array('belongsTo' => array('Parent')));
$this->assertTrue($result); $this->assertTrue($result);
@ -2982,7 +2982,7 @@ class ModelReadTest extends BaseModelTest {
'apple_id' => '', 'apple_id' => '',
'name' => '' 'name' => ''
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -3102,7 +3102,7 @@ class ModelReadTest extends BaseModelTest {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('threaded', array( $result = $TestModel->find('threaded', array(
'conditions' => array('Category.name LIKE' => 'Category 1%') 'conditions' => array('Category.name LIKE' => 'Category 1%')
@ -3155,7 +3155,7 @@ class ModelReadTest extends BaseModelTest {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('threaded', array( $result = $TestModel->find('threaded', array(
'fields' => 'id, parent_id, name' 'fields' => 'id, parent_id, name'
@ -3223,7 +3223,7 @@ class ModelReadTest extends BaseModelTest {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('threaded', array('order' => 'id DESC')); $result = $TestModel->find('threaded', array('order' => 'id DESC'));
@ -3305,7 +3305,7 @@ class ModelReadTest extends BaseModelTest {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('threaded', array( $result = $TestModel->find('threaded', array(
'conditions' => array('Category.name LIKE' => 'Category 3%') 'conditions' => array('Category.name LIKE' => 'Category 3%')
@ -3333,7 +3333,7 @@ class ModelReadTest extends BaseModelTest {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('threaded', array( $result = $TestModel->find('threaded', array(
'conditions' => array('Category.name LIKE' => 'Category 1.1%') 'conditions' => array('Category.name LIKE' => 'Category 1.1%')
@ -3361,7 +3361,7 @@ class ModelReadTest extends BaseModelTest {
'created' => '2007-03-18 15:30:23', 'created' => '2007-03-18 15:30:23',
'updated' => '2007-03-18 15:32:31'), 'updated' => '2007-03-18 15:32:31'),
'children' => array())))); 'children' => array()))));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('threaded', array( $result = $TestModel->find('threaded', array(
'fields' => 'id, parent_id, name', 'fields' => 'id, parent_id, name',
@ -3411,7 +3411,7 @@ class ModelReadTest extends BaseModelTest {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('all', array( $result = $TestModel->find('all', array(
'fields' => 'id, name, parent_id', 'fields' => 'id, name, parent_id',
@ -3453,7 +3453,7 @@ class ModelReadTest extends BaseModelTest {
'name' => 'Category 1.1.2', 'name' => 'Category 1.1.2',
'parent_id' => '2' 'parent_id' => '2'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('threaded', array( $result = $TestModel->find('threaded', array(
'fields' => 'id, parent_id, name', 'fields' => 'id, parent_id, name',
@ -3487,7 +3487,7 @@ class ModelReadTest extends BaseModelTest {
'children' => array() 'children' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -3522,7 +3522,7 @@ class ModelReadTest extends BaseModelTest {
'Article' => array( 'Article' => array(
'id' => 3 'id' => 3
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->id = 3; $TestModel->id = 3;
$TestModel->recursive = 1; $TestModel->recursive = 1;
@ -3549,7 +3549,7 @@ class ModelReadTest extends BaseModelTest {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->id = 2; $TestModel->id = 2;
$result = $TestModel->find('neighbors', array('recursive' => -1)); $result = $TestModel->find('neighbors', array('recursive' => -1));
@ -3577,7 +3577,7 @@ class ModelReadTest extends BaseModelTest {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->id = 3; $TestModel->id = 3;
$result = $TestModel->find('neighbors', array('recursive' => -1)); $result = $TestModel->find('neighbors', array('recursive' => -1));
@ -3595,7 +3595,7 @@ class ModelReadTest extends BaseModelTest {
), ),
'next' => null 'next' => null
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->recursive = 0; $TestModel->recursive = 0;
$TestModel->id = 1; $TestModel->id = 1;
@ -3608,17 +3608,17 @@ class ModelReadTest extends BaseModelTest {
$TestModel->id = 1; $TestModel->id = 1;
$result = $TestModel->find('neighbors'); $result = $TestModel->find('neighbors');
$expected = array('prev' => null, 'next' => $two); $expected = array('prev' => null, 'next' => $two);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->id = 2; $TestModel->id = 2;
$result = $TestModel->find('neighbors'); $result = $TestModel->find('neighbors');
$expected = array('prev' => $one, 'next' => $three); $expected = array('prev' => $one, 'next' => $three);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->id = 3; $TestModel->id = 3;
$result = $TestModel->find('neighbors'); $result = $TestModel->find('neighbors');
$expected = array('prev' => $two, 'next' => null); $expected = array('prev' => $two, 'next' => null);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->recursive = 2; $TestModel->recursive = 2;
$TestModel->id = 1; $TestModel->id = 1;
@ -3631,17 +3631,17 @@ class ModelReadTest extends BaseModelTest {
$TestModel->id = 1; $TestModel->id = 1;
$result = $TestModel->find('neighbors', array('recursive' => 2)); $result = $TestModel->find('neighbors', array('recursive' => 2));
$expected = array('prev' => null, 'next' => $two); $expected = array('prev' => null, 'next' => $two);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->id = 2; $TestModel->id = 2;
$result = $TestModel->find('neighbors', array('recursive' => 2)); $result = $TestModel->find('neighbors', array('recursive' => 2));
$expected = array('prev' => $one, 'next' => $three); $expected = array('prev' => $one, 'next' => $three);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->id = 3; $TestModel->id = 3;
$result = $TestModel->find('neighbors', array('recursive' => 2)); $result = $TestModel->find('neighbors', array('recursive' => 2));
$expected = array('prev' => $two, 'next' => null); $expected = array('prev' => $two, 'next' => null);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -3918,7 +3918,7 @@ class ModelReadTest extends BaseModelTest {
), ),
'Child' => array() 'Child' => array()
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -3977,7 +3977,7 @@ class ModelReadTest extends BaseModelTest {
) )
), ),
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -4017,7 +4017,7 @@ class ModelReadTest extends BaseModelTest {
$recursive = -1; $recursive = -1;
$order = 'Article.id ASC'; $order = 'Article.id ASC';
$result = $TestModel->find('all', compact('conditions', 'recursive', 'order')); $result = $TestModel->find('all', compact('conditions', 'recursive', 'order'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
if ($this->skipIf($this->db instanceof Postgres, 'The rest of testFindAllWithConditionsHavingMixedDataTypes test is not compatible with Postgres')) { if ($this->skipIf($this->db instanceof Postgres, 'The rest of testFindAllWithConditionsHavingMixedDataTypes test is not compatible with Postgres')) {
return; return;
@ -4060,7 +4060,7 @@ class ModelReadTest extends BaseModelTest {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -4085,7 +4085,7 @@ class ModelReadTest extends BaseModelTest {
$result = $TestModel->hasMany; $result = $TestModel->hasMany;
$expected = array(); $expected = array();
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->bindModel(array('hasMany' => array('Comment'))); $result = $TestModel->bindModel(array('hasMany' => array('Comment')));
$this->assertTrue($result); $this->assertTrue($result);
@ -4174,7 +4174,7 @@ class ModelReadTest extends BaseModelTest {
'updated' => '2007-03-18 10:49:31' 'updated' => '2007-03-18 10:49:31'
)))); ))));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->resetAssociations(); $TestModel->resetAssociations();
$result = $TestModel->hasMany; $result = $TestModel->hasMany;
@ -4268,7 +4268,7 @@ class ModelReadTest extends BaseModelTest {
'updated' => '2007-03-18 10:49:31' 'updated' => '2007-03-18 10:49:31'
)))); ))));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->hasMany; $result = $TestModel->hasMany;
$expected = array( $expected = array(
@ -4285,14 +4285,14 @@ class ModelReadTest extends BaseModelTest {
'finderQuery' => null, 'finderQuery' => null,
'counterQuery' => null 'counterQuery' => null
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->unbindModel(array('hasMany' => array('Comment'))); $result = $TestModel->unbindModel(array('hasMany' => array('Comment')));
$this->assertTrue($result); $this->assertTrue($result);
$result = $TestModel->hasMany; $result = $TestModel->hasMany;
$expected = array(); $expected = array();
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('all', array( $result = $TestModel->find('all', array(
'fields' => 'User.id, User.user' 'fields' => 'User.id, User.user'
@ -4302,7 +4302,7 @@ class ModelReadTest extends BaseModelTest {
array('User' => array('id' => '2', 'user' => 'nate')), array('User' => array('id' => '2', 'user' => 'nate')),
array('User' => array('id' => '3', 'user' => 'larry')), array('User' => array('id' => '3', 'user' => 'larry')),
array('User' => array('id' => '4', 'user' => 'garrett'))); array('User' => array('id' => '4', 'user' => 'garrett')));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('all', array( $result = $TestModel->find('all', array(
'fields' => 'User.id, User.user' 'fields' => 'User.id, User.user'
@ -4388,7 +4388,7 @@ class ModelReadTest extends BaseModelTest {
'created' => '2007-03-18 10:47:23', 'created' => '2007-03-18 10:47:23',
'updated' => '2007-03-18 10:49:31' 'updated' => '2007-03-18 10:49:31'
)))); ))));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->unbindModel(array('hasMany' => array('Comment')), false); $result = $TestModel->unbindModel(array('hasMany' => array('Comment')), false);
$this->assertTrue($result); $this->assertTrue($result);
@ -4399,11 +4399,11 @@ class ModelReadTest extends BaseModelTest {
array('User' => array('id' => '2', 'user' => 'nate')), array('User' => array('id' => '2', 'user' => 'nate')),
array('User' => array('id' => '3', 'user' => 'larry')), array('User' => array('id' => '3', 'user' => 'larry')),
array('User' => array('id' => '4', 'user' => 'garrett'))); array('User' => array('id' => '4', 'user' => 'garrett')));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->hasMany; $result = $TestModel->hasMany;
$expected = array(); $expected = array();
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->bindModel(array('hasMany' => array( $result = $TestModel->bindModel(array('hasMany' => array(
'Comment' => array('className' => 'Comment', 'conditions' => 'Comment.published = \'Y\'') 'Comment' => array('className' => 'Comment', 'conditions' => 'Comment.published = \'Y\'')
@ -4483,7 +4483,7 @@ class ModelReadTest extends BaseModelTest {
'updated' => '2007-03-18 10:49:31' 'updated' => '2007-03-18 10:49:31'
)))); ))));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel2 = new DeviceType(); $TestModel2 = new DeviceType();
@ -4559,7 +4559,7 @@ class ModelReadTest extends BaseModelTest {
$result = $TestModel->hasMany; $result = $TestModel->hasMany;
$expected = array(); $expected = array();
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->bindModel(array( $result = $TestModel->bindModel(array(
'hasMany' => array( 'hasMany' => array(
@ -4651,7 +4651,7 @@ class ModelReadTest extends BaseModelTest {
'created' => '2007-03-18 10:47:23', 'created' => '2007-03-18 10:47:23',
'updated' => '2007-03-18 10:49:31' 'updated' => '2007-03-18 10:49:31'
)))); ))));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->bindModel(array( $result = $TestModel->bindModel(array(
'hasMany' => array( 'hasMany' => array(
@ -4717,7 +4717,7 @@ class ModelReadTest extends BaseModelTest {
'Items' => array() 'Items' => array()
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -4748,7 +4748,7 @@ class ModelReadTest extends BaseModelTest {
$result = $TestModel->hasMany; $result = $TestModel->hasMany;
$expected = array(); $expected = array();
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->bindModel(array( $result = $TestModel->bindModel(array(
'hasMany' => array('Comment') 'hasMany' => array('Comment')
@ -4762,13 +4762,13 @@ class ModelReadTest extends BaseModelTest {
$result = array_keys($TestModel->hasMany); $result = array_keys($TestModel->hasMany);
$expected = array('Comment', 'Article'); $expected = array('Comment', 'Article');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->resetAssociations(); $TestModel->resetAssociations();
$result = array_keys($TestModel->hasMany); $result = array_keys($TestModel->hasMany);
$expected = array('Article'); $expected = array('Article');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -4819,7 +4819,7 @@ class ModelReadTest extends BaseModelTest {
$result = array_keys($TestModel->belongsTo); $result = array_keys($TestModel->belongsTo);
$expected = array('Article', 'User'); $expected = array('Article', 'User');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->unbindModel(array( $result = $TestModel->unbindModel(array(
'belongsTo' => array('User') 'belongsTo' => array('User')
@ -4833,13 +4833,13 @@ class ModelReadTest extends BaseModelTest {
$result = array_keys($TestModel->belongsTo); $result = array_keys($TestModel->belongsTo);
$expected = array(); $expected = array();
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->resetAssociations(); $TestModel->resetAssociations();
$result = array_keys($TestModel->belongsTo); $result = array_keys($TestModel->belongsTo);
$expected = array('User'); $expected = array('User');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -4907,7 +4907,7 @@ class ModelReadTest extends BaseModelTest {
'updated' => '2007-03-17 01:18:31', 'updated' => '2007-03-17 01:18:31',
'test' => 'working' 'test' => 'working'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
unset($TestModel); unset($TestModel);
$Author = new Author(); $Author = new Author();
@ -4947,19 +4947,19 @@ class ModelReadTest extends BaseModelTest {
$result = Set::extract($TestModel->find('all'), '/Author/user'); $result = Set::extract($TestModel->find('all'), '/Author/user');
$expected = array('mariano (CakePHP)', 'nate (CakePHP)', 'larry (CakePHP)', 'garrett (CakePHP)'); $expected = array('mariano (CakePHP)', 'nate (CakePHP)', 'larry (CakePHP)', 'garrett (CakePHP)');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::extract($TestModel->find('all', array('callbacks' => 'after')), '/Author/user'); $result = Set::extract($TestModel->find('all', array('callbacks' => 'after')), '/Author/user');
$expected = array('mariano (CakePHP)', 'nate (CakePHP)', 'larry (CakePHP)', 'garrett (CakePHP)'); $expected = array('mariano (CakePHP)', 'nate (CakePHP)', 'larry (CakePHP)', 'garrett (CakePHP)');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::extract($TestModel->find('all', array('callbacks' => 'before')), '/Author/user'); $result = Set::extract($TestModel->find('all', array('callbacks' => 'before')), '/Author/user');
$expected = array('mariano', 'nate', 'larry', 'garrett'); $expected = array('mariano', 'nate', 'larry', 'garrett');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::extract($TestModel->find('all', array('callbacks' => false)), '/Author/user'); $result = Set::extract($TestModel->find('all', array('callbacks' => false)), '/Author/user');
$expected = array('mariano', 'nate', 'larry', 'garrett'); $expected = array('mariano', 'nate', 'larry', 'garrett');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -5133,7 +5133,7 @@ class ModelReadTest extends BaseModelTest {
'Image' => array() 'Image' => array()
)))); ))));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -5234,7 +5234,7 @@ class ModelReadTest extends BaseModelTest {
), ),
'Tag' => array() 'Tag' => array()
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -5348,13 +5348,13 @@ class ModelReadTest extends BaseModelTest {
'updated' => '2007-03-18 12:28:31' 'updated' => '2007-03-18 12:28:31'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->hasAndBelongsToMany['Tag']['limit'] = 1; $TestModel->hasAndBelongsToMany['Tag']['limit'] = 1;
$result = $TestModel->read(null, 2); $result = $TestModel->read(null, 2);
unset($expected['Tag'][1]); unset($expected['Tag'][1]);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -5469,7 +5469,7 @@ class ModelReadTest extends BaseModelTest {
'Thread' => array() 'Thread' => array()
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -5576,7 +5576,7 @@ class ModelReadTest extends BaseModelTest {
'updated' => '2007-03-18 10:43:31' 'updated' => '2007-03-18 10:43:31'
))))); )))));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -5644,7 +5644,7 @@ class ModelReadTest extends BaseModelTest {
'name' => 'computer' 'name' => 'computer'
)))))); ))))));
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
} }
/** /**
@ -5709,7 +5709,7 @@ class ModelReadTest extends BaseModelTest {
))))))); )))))));
$this->db->fullDebug = $fullDebug; $this->db->fullDebug = $fullDebug;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -5774,7 +5774,7 @@ class ModelReadTest extends BaseModelTest {
))))))); )))))));
$this->db->fullDebug = $fullDebug; $this->db->fullDebug = $fullDebug;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -5995,7 +5995,7 @@ class ModelReadTest extends BaseModelTest {
)))))))); ))))))));
$this->db->fullDebug = $fullDebug; $this->db->fullDebug = $fullDebug;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -6061,7 +6061,7 @@ class ModelReadTest extends BaseModelTest {
'created' => '2007-03-17 01:22:23', 'created' => '2007-03-17 01:22:23',
'updated' => '2007-03-17 01:24:31' 'updated' => '2007-03-17 01:24:31'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('all', array('conditions' => 'User.id > 2')); $result = $TestModel->find('all', array('conditions' => 'User.id > 2'));
$expected = array( $expected = array(
@ -6081,7 +6081,7 @@ class ModelReadTest extends BaseModelTest {
'created' => '2007-03-17 01:22:23', 'created' => '2007-03-17 01:22:23',
'updated' => '2007-03-17 01:24:31' 'updated' => '2007-03-17 01:24:31'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('all', array( $result = $TestModel->find('all', array(
'conditions' => array('User.id !=' => '0', 'User.user LIKE' => '%arr%') 'conditions' => array('User.id !=' => '0', 'User.user LIKE' => '%arr%')
@ -6103,11 +6103,11 @@ class ModelReadTest extends BaseModelTest {
'created' => '2007-03-17 01:22:23', 'created' => '2007-03-17 01:22:23',
'updated' => '2007-03-17 01:24:31' 'updated' => '2007-03-17 01:24:31'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('all', array('conditions' => array('User.id' => '0'))); $result = $TestModel->find('all', array('conditions' => array('User.id' => '0')));
$expected = array(); $expected = array();
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('all', array( $result = $TestModel->find('all', array(
'conditions' => array('or' => array('User.id' => '0', 'User.user LIKE' => '%a%') 'conditions' => array('or' => array('User.id' => '0', 'User.user LIKE' => '%a%')
@ -6146,7 +6146,7 @@ class ModelReadTest extends BaseModelTest {
'created' => '2007-03-17 01:22:23', 'created' => '2007-03-17 01:22:23',
'updated' => '2007-03-17 01:24:31' 'updated' => '2007-03-17 01:24:31'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('all', array('fields' => 'User.id, User.user')); $result = $TestModel->find('all', array('fields' => 'User.id, User.user'));
$expected = array( $expected = array(
@ -6154,7 +6154,7 @@ class ModelReadTest extends BaseModelTest {
array('User' => array('id' => '2', 'user' => 'nate')), array('User' => array('id' => '2', 'user' => 'nate')),
array('User' => array('id' => '3', 'user' => 'larry')), array('User' => array('id' => '3', 'user' => 'larry')),
array('User' => array('id' => '4', 'user' => 'garrett'))); array('User' => array('id' => '4', 'user' => 'garrett')));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('all', array('fields' => 'User.user', 'order' => 'User.user ASC')); $result = $TestModel->find('all', array('fields' => 'User.user', 'order' => 'User.user ASC'));
$expected = array( $expected = array(
@ -6162,7 +6162,7 @@ class ModelReadTest extends BaseModelTest {
array('User' => array('user' => 'larry')), array('User' => array('user' => 'larry')),
array('User' => array('user' => 'mariano')), array('User' => array('user' => 'mariano')),
array('User' => array('user' => 'nate'))); array('User' => array('user' => 'nate')));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('all', array('fields' => 'User.user', 'order' => 'User.user DESC')); $result = $TestModel->find('all', array('fields' => 'User.user', 'order' => 'User.user DESC'));
$expected = array( $expected = array(
@ -6170,7 +6170,7 @@ class ModelReadTest extends BaseModelTest {
array('User' => array('user' => 'mariano')), array('User' => array('user' => 'mariano')),
array('User' => array('user' => 'larry')), array('User' => array('user' => 'larry')),
array('User' => array('user' => 'garrett'))); array('User' => array('user' => 'garrett')));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('all', array('limit' => 3, 'page' => 1)); $result = $TestModel->find('all', array('limit' => 3, 'page' => 1));
@ -6199,7 +6199,7 @@ class ModelReadTest extends BaseModelTest {
'created' => '2007-03-17 01:20:23', 'created' => '2007-03-17 01:20:23',
'updated' => '2007-03-17 01:22:31' 'updated' => '2007-03-17 01:22:31'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$ids = array(4 => 1, 5 => 3); $ids = array(4 => 1, 5 => 3);
$result = $TestModel->find('all', array( $result = $TestModel->find('all', array(
@ -6223,7 +6223,7 @@ class ModelReadTest extends BaseModelTest {
'created' => '2007-03-17 01:20:23', 'created' => '2007-03-17 01:20:23',
'updated' => '2007-03-17 01:22:31' 'updated' => '2007-03-17 01:22:31'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
// These tests are expected to fail on SQL Server since the LIMIT/OFFSET // These tests are expected to fail on SQL Server since the LIMIT/OFFSET
// hack can't handle small record counts. // hack can't handle small record counts.
@ -6238,11 +6238,11 @@ class ModelReadTest extends BaseModelTest {
'created' => '2007-03-17 01:22:23', 'created' => '2007-03-17 01:22:23',
'updated' => '2007-03-17 01:24:31' 'updated' => '2007-03-17 01:24:31'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('all', array('limit' => 3, 'page' => 3)); $result = $TestModel->find('all', array('limit' => 3, 'page' => 3));
$expected = array(); $expected = array();
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
} }
@ -6267,7 +6267,7 @@ class ModelReadTest extends BaseModelTest {
2 => 'Second Article', 2 => 'Second Article',
3 => 'Third Article' 3 => 'Third Article'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$db = ConnectionManager::getDataSource('test'); $db = ConnectionManager::getDataSource('test');
if ($db instanceof Mysql) { if ($db instanceof Mysql) {
@ -6279,7 +6279,7 @@ class ModelReadTest extends BaseModelTest {
3 => 'Third Article', 3 => 'Third Article',
2 => 'Second Article' 2 => 'Second Article'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
$result = Set::combine( $result = Set::combine(
@ -6294,7 +6294,7 @@ class ModelReadTest extends BaseModelTest {
2 => 'Second Article', 2 => 'Second Article',
3 => 'Third Article' 3 => 'Third Article'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::combine( $result = Set::combine(
$TestModel->find('all', array( $TestModel->find('all', array(
@ -6331,7 +6331,7 @@ class ModelReadTest extends BaseModelTest {
'updated' => '2007-03-18 10:45:31' 'updated' => '2007-03-18 10:45:31'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::combine( $result = Set::combine(
$TestModel->find('all', array( $TestModel->find('all', array(
@ -6370,7 +6370,7 @@ class ModelReadTest extends BaseModelTest {
'updated' => '2007-03-18 10:43:31' 'updated' => '2007-03-18 10:43:31'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::combine( $result = Set::combine(
$TestModel->find('all', array( $TestModel->find('all', array(
@ -6388,7 +6388,7 @@ class ModelReadTest extends BaseModelTest {
3 => array( 3 => array(
2 => 'Second Article' 2 => 'Second Article'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel = new Apple(); $TestModel = new Apple();
$expected = array( $expected = array(
@ -6413,7 +6413,7 @@ class ModelReadTest extends BaseModelTest {
2 => 'Second Post', 2 => 'Second Post',
3 => 'Third Post' 3 => 'Third Post'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('list', array( $result = $TestModel->find('list', array(
'fields' => 'title' 'fields' => 'title'
@ -6423,7 +6423,7 @@ class ModelReadTest extends BaseModelTest {
2 => 'Second Post', 2 => 'Second Post',
3 => 'Third Post' 3 => 'Third Post'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('list', array( $result = $TestModel->find('list', array(
'fields' => array('title', 'id') 'fields' => array('title', 'id')
@ -6433,7 +6433,7 @@ class ModelReadTest extends BaseModelTest {
'Second Post' => '2', 'Second Post' => '2',
'Third Post' => '3' 'Third Post' => '3'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('list', array( $result = $TestModel->find('list', array(
'fields' => array('title', 'id', 'created') 'fields' => array('title', 'id', 'created')
@ -6449,7 +6449,7 @@ class ModelReadTest extends BaseModelTest {
'Third Post' => '3' 'Third Post' => '3'
), ),
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('list', array( $result = $TestModel->find('list', array(
'fields' => array('Post.body') 'fields' => array('Post.body')
@ -6459,7 +6459,7 @@ class ModelReadTest extends BaseModelTest {
2 => 'Second Post Body', 2 => 'Second Post Body',
3 => 'Third Post Body' 3 => 'Third Post Body'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('list', array( $result = $TestModel->find('list', array(
'fields' => array('Post.title', 'Post.body') 'fields' => array('Post.title', 'Post.body')
@ -6469,7 +6469,7 @@ class ModelReadTest extends BaseModelTest {
'Second Post' => 'Second Post Body', 'Second Post' => 'Second Post Body',
'Third Post' => 'Third Post Body' 'Third Post' => 'Third Post Body'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('list', array( $result = $TestModel->find('list', array(
'fields' => array('Post.id', 'Post.title', 'Author.user'), 'fields' => array('Post.id', 'Post.title', 'Author.user'),
@ -6483,7 +6483,7 @@ class ModelReadTest extends BaseModelTest {
'larry' => array( 'larry' => array(
2 => 'Second Post' 2 => 'Second Post'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel = new User(); $TestModel = new User();
$result = $TestModel->find('list', array( $result = $TestModel->find('list', array(
@ -6495,7 +6495,7 @@ class ModelReadTest extends BaseModelTest {
'larry' => '5f4dcc3b5aa765d61d8327deb882cf99', 'larry' => '5f4dcc3b5aa765d61d8327deb882cf99',
'garrett' => '5f4dcc3b5aa765d61d8327deb882cf99' 'garrett' => '5f4dcc3b5aa765d61d8327deb882cf99'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel = new ModifiedAuthor(); $TestModel = new ModifiedAuthor();
$result = $TestModel->find('list', array( $result = $TestModel->find('list', array(
@ -6507,7 +6507,7 @@ class ModelReadTest extends BaseModelTest {
3 => 'larry (CakePHP)', 3 => 'larry (CakePHP)',
4 => 'garrett (CakePHP)' 4 => 'garrett (CakePHP)'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel = new Article(); $TestModel = new Article();
$TestModel->displayField = 'title'; $TestModel->displayField = 'title';
@ -6519,7 +6519,7 @@ class ModelReadTest extends BaseModelTest {
1 => 'First Article', 1 => 'First Article',
3 => 'Third Article' 3 => 'Third Article'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -6682,7 +6682,7 @@ class ModelReadTest extends BaseModelTest {
'created' => '2007-03-17 01:16:23', 'created' => '2007-03-17 01:16:23',
'updated' => '2007-03-17 01:18:31' 'updated' => '2007-03-17 01:18:31'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->findByPassword('5f4dcc3b5aa765d61d8327deb882cf99'); $result = $TestModel->findByPassword('5f4dcc3b5aa765d61d8327deb882cf99');
$expected = array('User' => array( $expected = array('User' => array(
@ -6692,7 +6692,7 @@ class ModelReadTest extends BaseModelTest {
'created' => '2007-03-17 01:16:23', 'created' => '2007-03-17 01:16:23',
'updated' => '2007-03-17 01:18:31' 'updated' => '2007-03-17 01:18:31'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -6718,7 +6718,7 @@ class ModelReadTest extends BaseModelTest {
'created' => '2007-03-17 01:18:23', 'created' => '2007-03-17 01:18:23',
'updated' => '2007-03-17 01:20:31' 'updated' => '2007-03-17 01:20:31'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->read(null, 2); $result = $TestModel->read(null, 2);
$expected = array( $expected = array(
@ -6729,12 +6729,12 @@ class ModelReadTest extends BaseModelTest {
'created' => '2007-03-17 01:18:23', 'created' => '2007-03-17 01:18:23',
'updated' => '2007-03-17 01:20:31' 'updated' => '2007-03-17 01:20:31'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->id = 2; $TestModel->id = 2;
$result = $TestModel->read(array('id', 'user')); $result = $TestModel->read(array('id', 'user'));
$expected = array('User' => array('id' => '2', 'user' => 'nate')); $expected = array('User' => array('id' => '2', 'user' => 'nate'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->read('id, user', 2); $result = $TestModel->read('id, user', 2);
$expected = array( $expected = array(
@ -6742,7 +6742,7 @@ class ModelReadTest extends BaseModelTest {
'id' => '2', 'id' => '2',
'user' => 'nate' 'user' => 'nate'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->bindModel(array('hasMany' => array('Article'))); $result = $TestModel->bindModel(array('hasMany' => array('Article')));
$this->assertTrue($result); $this->assertTrue($result);
@ -6773,7 +6773,7 @@ class ModelReadTest extends BaseModelTest {
'created' => '2007-03-18 10:43:23', 'created' => '2007-03-18 10:43:23',
'updated' => '2007-03-18 10:45:31' 'updated' => '2007-03-18 10:45:31'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -6802,7 +6802,7 @@ class ModelReadTest extends BaseModelTest {
$expected = array( $expected = array(
'User' => array('id' => '1', 'user' => 'mariano'), 'User' => array('id' => '1', 'user' => 'mariano'),
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->recursive = 1; $TestModel->recursive = 1;
$result = $TestModel->read('id, user', 1); $result = $TestModel->read('id, user', 1);
@ -6830,7 +6830,7 @@ class ModelReadTest extends BaseModelTest {
'created' => '2007-03-18 10:43:23', 'created' => '2007-03-18 10:43:23',
'updated' => '2007-03-18 10:45:31' 'updated' => '2007-03-18 10:45:31'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->recursive = 2; $TestModel->recursive = 2;
$result = $TestModel->read('id, user', 3); $result = $TestModel->read('id, user', 3);
@ -6887,7 +6887,7 @@ class ModelReadTest extends BaseModelTest {
'created' => '2007-03-18 12:26:23', 'created' => '2007-03-18 12:26:23',
'updated' => '2007-03-18 12:28:31' 'updated' => '2007-03-18 12:28:31'
))))); )))));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
function testRecursiveFindAll() { function testRecursiveFindAll() {
@ -6996,7 +6996,7 @@ class ModelReadTest extends BaseModelTest {
'Tag' => array() 'Tag' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->find('all', array( $result = $TestModel->find('all', array(
'conditions' => array('Article.user_id' => 3), 'conditions' => array('Article.user_id' => 3),
@ -7096,7 +7096,7 @@ class ModelReadTest extends BaseModelTest {
'updated' => '2007-03-18 12:28:31' 'updated' => '2007-03-18 12:28:31'
)))); ))));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$Featured = new Featured(); $Featured = new Featured();
@ -7199,7 +7199,7 @@ class ModelReadTest extends BaseModelTest {
'created' => '2007-03-18 15:30:23', 'created' => '2007-03-18 15:30:23',
'updated' => '2007-03-18 15:32:31' 'updated' => '2007-03-18 15:32:31'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -7289,7 +7289,7 @@ class ModelReadTest extends BaseModelTest {
'Tag' => array() 'Tag' => array()
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->hasMany['Comment']['limit'] = 1; $TestModel->hasMany['Comment']['limit'] = 1;
@ -7366,7 +7366,7 @@ class ModelReadTest extends BaseModelTest {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
* Testing availability of $this->findQueryType in Model callbacks * Testing availability of $this->findQueryType in Model callbacks

View file

@ -520,7 +520,7 @@ class ModelValidationTest extends BaseModelTest {
$expected = array( $expected = array(
'title' => array('tooShort') 'title' => array('tooShort')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->validate = array( $TestModel->validate = array(
'title' => array( 'title' => array(
@ -541,7 +541,7 @@ class ModelValidationTest extends BaseModelTest {
$expected = array( $expected = array(
'title' => array('tooShort', 'onlyLetters') 'title' => array('tooShort', 'onlyLetters')
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**

View file

@ -44,7 +44,7 @@ class ModelWriteTest extends BaseModelTest {
'created' => '2008-01-03 10:56:33', 'created' => '2008-01-03 10:56:33',
'updated' => '2008-01-03 10:56:33' 'updated' => '2008-01-03 10:56:33'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->JoinAsJoinB->create(); $TestModel->JoinAsJoinB->create();
$data = array( $data = array(
@ -69,7 +69,7 @@ class ModelWriteTest extends BaseModelTest {
'created' => '2008-01-03 10:56:33', 'created' => '2008-01-03 10:56:33',
'updated' => '2008-01-03 10:56:33' 'updated' => '2008-01-03 10:56:33'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$updatedValue = 'UPDATED Data for Join A 1 Join B 2'; $updatedValue = 'UPDATED Data for Join A 1 Join B 2';
$TestModel->JoinAsJoinB->id = 1; $TestModel->JoinAsJoinB->id = 1;
@ -324,7 +324,7 @@ class ModelWriteTest extends BaseModelTest {
$result = $user[$User->alias]['post_count']; $result = $user[$User->alias]['post_count'];
$expected = 3; $expected = 3;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -346,7 +346,7 @@ class ModelWriteTest extends BaseModelTest {
$result = $user[$User->alias]['post_count']; $result = $user[$User->alias]['post_count'];
$expected = 1; $expected = 1;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -425,7 +425,7 @@ class ModelWriteTest extends BaseModelTest {
$Category->updateCounterCache(array('parent_id' => 5)); $Category->updateCounterCache(array('parent_id' => 5));
$result = Set::extract($Category->find('all', array('conditions' => array('CategoryThread.id' => 5))), '{n}.CategoryThread.child_count'); $result = Set::extract($Category->find('all', array('conditions' => array('CategoryThread.id' => 5))), '{n}.CategoryThread.child_count');
$expected = array_fill(0, 1, 1); $expected = array_fill(0, 1, 1);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -528,7 +528,7 @@ class ModelWriteTest extends BaseModelTest {
'title' => 'New First Article', 'title' => 'New First Article',
'body' => 'First Article Body' 'body' => 'First Article Body'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->id = 1; $TestModel->id = 1;
$result = $TestModel->saveField('title', ''); $result = $TestModel->saveField('title', '');
@ -543,7 +543,7 @@ class ModelWriteTest extends BaseModelTest {
'body' => 'First Article Body' 'body' => 'First Article Body'
)); ));
$result['Article']['title'] = trim($result['Article']['title']); $result['Article']['title'] = trim($result['Article']['title']);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->id = 1; $TestModel->id = 1;
$TestModel->set('body', 'Messed up data'); $TestModel->set('body', 'Messed up data');
@ -556,7 +556,7 @@ class ModelWriteTest extends BaseModelTest {
'title' => 'First Article', 'title' => 'First Article',
'body' => 'First Article Body' 'body' => 'First Article Body'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->recursive = -1; $TestModel->recursive = -1;
$result = $TestModel->read(array('id', 'user_id', 'title', 'body'), 1); $result = $TestModel->read(array('id', 'user_id', 'title', 'body'), 1);
@ -638,7 +638,7 @@ class ModelWriteTest extends BaseModelTest {
'body' => 'First Article Body', 'body' => 'First Article Body',
'published' => 'N' 'published' => 'N'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array('Article' => array( $data = array('Article' => array(
'id' => 1, 'id' => 1,
@ -659,7 +659,7 @@ class ModelWriteTest extends BaseModelTest {
'body' => 'First Article Body', 'body' => 'First Article Body',
'published' => 'Y' 'published' => 'Y'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
'Article' => array( 'Article' => array(
@ -708,7 +708,7 @@ class ModelWriteTest extends BaseModelTest {
'created' => '2007-03-18 12:26:23', 'created' => '2007-03-18 12:26:23',
'updated' => '2007-03-18 12:28:31' 'updated' => '2007-03-18 12:28:31'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array('Comment' => array( $data = array('Comment' => array(
'article_id' => '4', 'article_id' => '4',
@ -795,7 +795,7 @@ class ModelWriteTest extends BaseModelTest {
'updated' => '2007-03-18 12:28:31' 'updated' => '2007-03-18 12:28:31'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -857,7 +857,7 @@ class ModelWriteTest extends BaseModelTest {
'body' => 'Fourth Article Body', 'body' => 'Fourth Article Body',
'published' => 'Y' 'published' => 'Y'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
// Create new record just to overlap Model->id on previously created record // Create new record just to overlap Model->id on previously created record
@ -879,7 +879,7 @@ class ModelWriteTest extends BaseModelTest {
'body' => 'Fifth Article Body', 'body' => 'Fifth Article Body',
'published' => 'Y' 'published' => 'Y'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
// Go back and edit the first article we created, starting by checking it's still there // Go back and edit the first article we created, starting by checking it's still there
@ -892,7 +892,7 @@ class ModelWriteTest extends BaseModelTest {
'body' => 'Fourth Article Body', 'body' => 'Fourth Article Body',
'published' => 'Y' 'published' => 'Y'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
// And now do the update with set() // And now do the update with set()
@ -913,7 +913,7 @@ class ModelWriteTest extends BaseModelTest {
'body' => 'Fourth Article Body', 'body' => 'Fourth Article Body',
'published' => 'N' 'published' => 'N'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->recursive = -1; $TestModel->recursive = -1;
$result = $TestModel->read(array('id', 'user_id', 'title', 'body', 'published'), 5); $result = $TestModel->read(array('id', 'user_id', 'title', 'body', 'published'), 5);
@ -924,7 +924,7 @@ class ModelWriteTest extends BaseModelTest {
'body' => 'Fifth Article Body', 'body' => 'Fifth Article Body',
'published' => 'Y' 'published' => 'Y'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array('Article' => array('id' => '5', 'title' => 'Fifth Article - New Title 5')); $data = array('Article' => array('id' => '5', 'title' => 'Fifth Article - New Title 5'));
$result = ($TestModel->set($data) && $TestModel->save()); $result = ($TestModel->set($data) && $TestModel->save());
@ -939,7 +939,7 @@ class ModelWriteTest extends BaseModelTest {
'body' => 'Fifth Article Body', 'body' => 'Fifth Article Body',
'published' => 'Y' 'published' => 'Y'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->recursive = -1; $TestModel->recursive = -1;
$result = $TestModel->find('all', array('fields' => array('id', 'title'))); $result = $TestModel->find('all', array('fields' => array('id', 'title')));
@ -950,7 +950,7 @@ class ModelWriteTest extends BaseModelTest {
array('Article' => array('id' => 4, 'title' => 'Fourth Article - New Title' )), array('Article' => array('id' => 4, 'title' => 'Fourth Article - New Title' )),
array('Article' => array('id' => 5, 'title' => 'Fifth Article - New Title 5' )) array('Article' => array('id' => 5, 'title' => 'Fifth Article - New Title 5' ))
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -982,7 +982,7 @@ class ModelWriteTest extends BaseModelTest {
'published' => 'N' 'published' => 'N'
)); ));
$result = $TestModel->read(array('id', 'user_id', 'title', 'body', 'published'), 4); $result = $TestModel->read(array('id', 'user_id', 'title', 'body', 'published'), 4);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
'user_id' => '1', 'user_id' => '1',
@ -1002,7 +1002,7 @@ class ModelWriteTest extends BaseModelTest {
'published' => 'N' 'published' => 'N'
)); ));
$result = $TestModel->read(array('id', 'user_id', 'title', 'body', 'published'), 5); $result = $TestModel->read(array('id', 'user_id', 'title', 'body', 'published'), 5);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -1095,7 +1095,7 @@ class ModelWriteTest extends BaseModelTest {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
'Article' => array( 'Article' => array(
@ -1132,7 +1132,7 @@ class ModelWriteTest extends BaseModelTest {
'created' => '2007-03-18 12:24:23', 'created' => '2007-03-18 12:24:23',
'updated' => '2007-03-18 12:26:31' 'updated' => '2007-03-18 12:26:31'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array('Article' => array('id' => '2'), 'Tag' => array('Tag' => array(2, 3))); $data = array('Article' => array('id' => '2'), 'Tag' => array('Tag' => array(2, 3)));
$result = $TestModel->set($data); $result = $TestModel->set($data);
@ -1166,7 +1166,7 @@ class ModelWriteTest extends BaseModelTest {
'created' => '2007-03-18 12:26:23', 'created' => '2007-03-18 12:26:23',
'updated' => '2007-03-18 12:28:31' 'updated' => '2007-03-18 12:28:31'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array('Tag' => array('Tag' => array(1, 2, 3))); $data = array('Tag' => array('Tag' => array(1, 2, 3)));
@ -1207,7 +1207,7 @@ class ModelWriteTest extends BaseModelTest {
'created' => '2007-03-18 12:26:23', 'created' => '2007-03-18 12:26:23',
'updated' => '2007-03-18 12:28:31' 'updated' => '2007-03-18 12:28:31'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array('Tag' => array('Tag' => array())); $data = array('Tag' => array('Tag' => array()));
$result = $TestModel->set($data); $result = $TestModel->set($data);
@ -1237,7 +1237,7 @@ class ModelWriteTest extends BaseModelTest {
), ),
'Tag' => array() 'Tag' => array()
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array('Tag' => array('Tag' => array(2, 3))); $data = array('Tag' => array('Tag' => array(2, 3)));
$result = $TestModel->set($data); $result = $TestModel->set($data);
@ -1271,7 +1271,7 @@ class ModelWriteTest extends BaseModelTest {
'created' => '2007-03-18 12:26:23', 'created' => '2007-03-18 12:26:23',
'updated' => '2007-03-18 12:28:31' 'updated' => '2007-03-18 12:28:31'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
'Tag' => array( 'Tag' => array(
@ -1311,7 +1311,7 @@ class ModelWriteTest extends BaseModelTest {
'created' => '2007-03-18 12:24:23', 'created' => '2007-03-18 12:24:23',
'updated' => '2007-03-18 12:26:31' 'updated' => '2007-03-18 12:26:31'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
'Tag' => array( 'Tag' => array(
@ -1353,7 +1353,7 @@ class ModelWriteTest extends BaseModelTest {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
'Tag' => array( 'Tag' => array(
@ -1395,7 +1395,7 @@ class ModelWriteTest extends BaseModelTest {
) )
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
'Tag' => array( 'Tag' => array(
@ -1435,7 +1435,7 @@ class ModelWriteTest extends BaseModelTest {
'created' => '2007-03-18 12:26:23', 'created' => '2007-03-18 12:26:23',
'updated' => '2007-03-18 12:28:31' 'updated' => '2007-03-18 12:28:31'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
'Article' => array( 'Article' => array(
@ -1484,7 +1484,7 @@ class ModelWriteTest extends BaseModelTest {
'created' => '2007-03-18 12:26:23', 'created' => '2007-03-18 12:26:23',
'updated' => '2007-03-18 12:28:31' 'updated' => '2007-03-18 12:28:31'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->loadFixtures('JoinA', 'JoinC', 'JoinAC', 'JoinB', 'JoinAB'); $this->loadFixtures('JoinA', 'JoinC', 'JoinAC', 'JoinB', 'JoinAB');
@ -1559,7 +1559,7 @@ class ModelWriteTest extends BaseModelTest {
), ),
'Tag' => array() 'Tag' => array()
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -1745,7 +1745,7 @@ class ModelWriteTest extends BaseModelTest {
'body' => 'Some text' 'body' => 'Some text'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertEqual($TestModel->id, 5); $this->assertEqual($TestModel->id, 5);
$result = $TestModel->create($data, true); $result = $TestModel->create($data, true);
@ -1758,7 +1758,7 @@ class ModelWriteTest extends BaseModelTest {
'body' => 'Some text' 'body' => 'Some text'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertFalse($TestModel->id); $this->assertFalse($TestModel->id);
$result = $TestModel->create(array('Article' => $data), true); $result = $TestModel->create(array('Article' => $data), true);
@ -1771,7 +1771,7 @@ class ModelWriteTest extends BaseModelTest {
'body' => 'Some text' 'body' => 'Some text'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertFalse($TestModel->id); $this->assertFalse($TestModel->id);
$data = array( $data = array(
@ -1796,7 +1796,7 @@ class ModelWriteTest extends BaseModelTest {
'updated' => '1970-01-01 12:00:00', 'updated' => '1970-01-01 12:00:00',
'modified' => '1970-01-01 12:00:00' 'modified' => '1970-01-01 12:00:00'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertEqual($TestModel->id, 6); $this->assertEqual($TestModel->id, 6);
$result = $TestModel->create(array( $result = $TestModel->create(array(
@ -1813,7 +1813,7 @@ class ModelWriteTest extends BaseModelTest {
'title' => 'My article', 'title' => 'My article',
'body' => 'Some text' 'body' => 'Some text'
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertFalse($TestModel->id); $this->assertFalse($TestModel->id);
} }
@ -2195,12 +2195,12 @@ class ModelWriteTest extends BaseModelTest {
$TestModel = new Comment(); $TestModel = new Comment();
$result = Set::extract($TestModel->find('all'), '{n}.Comment.user_id'); $result = Set::extract($TestModel->find('all'), '{n}.Comment.user_id');
$expected = array('2', '4', '1', '1', '1', '2'); $expected = array('2', '4', '1', '1', '1', '2');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->updateAll(array('Comment.user_id' => 5), array('Comment.user_id' => 2)); $TestModel->updateAll(array('Comment.user_id' => 5), array('Comment.user_id' => 2));
$result = Set::combine($TestModel->find('all'), '{n}.Comment.id', '{n}.Comment.user_id'); $result = Set::combine($TestModel->find('all'), '{n}.Comment.id', '{n}.Comment.user_id');
$expected = array(1 => 5, 2 => 4, 3 => 1, 4 => 1, 5 => 1, 6 => 5); $expected = array(1 => 5, 2 => 4, 3 => 1, 4 => 1, 5 => 1, 6 => 5);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $TestModel->updateAll( $result = $TestModel->updateAll(
array('Comment.comment' => "'Updated today'"), array('Comment.comment' => "'Updated today'"),
@ -2215,7 +2215,7 @@ class ModelWriteTest extends BaseModelTest {
'{n}.Comment.comment' '{n}.Comment.comment'
); );
$expected = array_fill(0, 2, 'Updated today'); $expected = array_fill(0, 2, 'Updated today');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -2355,7 +2355,7 @@ class ModelWriteTest extends BaseModelTest {
'updated' => '2008-01-03 10:57:22' 'updated' => '2008-01-03 10:57:22'
)))); ))));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$ts = date('Y-m-d H:i:s'); $ts = date('Y-m-d H:i:s');
$TestModel->id = 1; $TestModel->id = 1;
@ -2423,7 +2423,7 @@ class ModelWriteTest extends BaseModelTest {
'updated' => $ts 'updated' => $ts
)))); ))));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -2517,7 +2517,7 @@ class ModelWriteTest extends BaseModelTest {
'created' => $ts, 'created' => $ts,
'updated' => $ts 'updated' => $ts
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel = new Comment(); $TestModel = new Comment();
$ts = date('Y-m-d H:i:s'); $ts = date('Y-m-d H:i:s');
@ -2679,7 +2679,7 @@ class ModelWriteTest extends BaseModelTest {
'comment_id' => '1', 'comment_id' => '1',
'attachment' => 'some_file.zip' 'attachment' => 'some_file.zip'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$model->Attachment->bindModel(array('belongsTo' => array('Comment')), false); $model->Attachment->bindModel(array('belongsTo' => array('Comment')), false);
@ -2732,7 +2732,7 @@ class ModelWriteTest extends BaseModelTest {
'id' => '1', 'id' => '1',
'title' => 'Model Associations 101' 'title' => 'Model Associations 101'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -2953,7 +2953,7 @@ class ModelWriteTest extends BaseModelTest {
) )
), array('validate' => true)); ), array('validate' => true));
$expected = array('Comment' => array(false)); $expected = array('Comment' => array(false));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$expected = array('Comment' => array( $expected = array('Comment' => array(
array('comment' => array('This field cannot be left blank')) array('comment' => array('This field cannot be left blank'))
@ -3142,12 +3142,12 @@ class ModelWriteTest extends BaseModelTest {
'updated' => $ts 'updated' => $ts
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
// Skip the rest of the transactional tests // Skip the rest of the transactional tests
return; return;
} }
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
array('author_id' => 1, 'title' => 'New Fourth Post'), array('author_id' => 1, 'title' => 'New Fourth Post'),
@ -3211,7 +3211,7 @@ class ModelWriteTest extends BaseModelTest {
'updated' => $ts 'updated' => $ts
)); ));
} }
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->validate = array('title' => 'notEmpty'); $TestModel->validate = array('title' => 'notEmpty');
$data = array( $data = array(
@ -3263,7 +3263,7 @@ class ModelWriteTest extends BaseModelTest {
'body' => '', 'body' => '',
'published' => 'N' 'published' => 'N'
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -3337,7 +3337,7 @@ class ModelWriteTest extends BaseModelTest {
'created' => $ts, 'created' => $ts,
'updated' => $ts 'updated' => $ts
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$TestModel->validate = array('title' => 'notEmpty', 'author_id' => 'numeric'); $TestModel->validate = array('title' => 'notEmpty', 'author_id' => 'numeric');
$data = array( $data = array(
@ -3424,7 +3424,7 @@ class ModelWriteTest extends BaseModelTest {
'created' => $ts, 'created' => $ts,
'updated' => $ts 'updated' => $ts
))); )));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertEqual($TestModel->validationErrors, $errors); $this->assertEqual($TestModel->validationErrors, $errors);
$data = array( $data = array(
@ -3442,7 +3442,7 @@ class ModelWriteTest extends BaseModelTest {
$this->assertFalse($TestModel->saveAll($data, array('validate' => 'first'))); $this->assertFalse($TestModel->saveAll($data, array('validate' => 'first')));
$result = $TestModel->find('all', array('recursive' => -1, 'order' => 'Post.id ASC')); $result = $TestModel->find('all', array('recursive' => -1, 'order' => 'Post.id ASC'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertEqual($TestModel->validationErrors, $errors); $this->assertEqual($TestModel->validationErrors, $errors);
$data = array( $data = array(
@ -3628,7 +3628,7 @@ class ModelWriteTest extends BaseModelTest {
'validate' => 'first', 'validate' => 'first',
)); ));
$expected = array(true, false); $expected = array(true, false);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$Something = new Something(); $Something = new Something();
$validData = array( $validData = array(
@ -3649,7 +3649,7 @@ class ModelWriteTest extends BaseModelTest {
'validate' => 'first', 'validate' => 'first',
)); ));
$expected = array(true, true); $expected = array(true, true);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -3744,7 +3744,7 @@ class ModelWriteTest extends BaseModelTest {
'Article' => true, 'Article' => true,
'Comment' => array(false, true, false) 'Comment' => array(false, true, false)
); );
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$expected = array('Comment' => array( $expected = array('Comment' => array(
0 => array('comment' => array('This field cannot be left blank')), 0 => array('comment' => array('This field cannot be left blank')),

View file

@ -25,7 +25,7 @@ class CakeResponseTestCase extends CakeTestCase {
$this->assertEquals($response->body(), 'This is the body'); $this->assertEquals($response->body(), 'This is the body');
$this->assertEquals($response->charset(), 'my-custom-charset'); $this->assertEquals($response->charset(), 'my-custom-charset');
$this->assertEquals($response->type(), 'audio/mpeg'); $this->assertEquals($response->type(), 'audio/mpeg');
$this->assertEquals($response->statusCode(), 203); $this->assertEquals($response->statusCode(), 203);
} }
/** /**
@ -300,7 +300,7 @@ class CakeResponseTestCase extends CakeTestCase {
$result = $response->httpCodes(100); $result = $response->httpCodes(100);
$expected = array(100 => 'Continue'); $expected = array(100 => 'Continue');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$codes = array( $codes = array(
1337 => 'Undefined Unicorn', 1337 => 'Undefined Unicorn',
@ -313,7 +313,7 @@ class CakeResponseTestCase extends CakeTestCase {
$result = $response->httpCodes(1337); $result = $response->httpCodes(1337);
$expected = array(1337 => 'Undefined Unicorn'); $expected = array(1337 => 'Undefined Unicorn');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$codes = array(404 => 'Sorry Bro'); $codes = array(404 => 'Sorry Bro');
$result = $response->httpCodes($codes); $result = $response->httpCodes($codes);
@ -322,7 +322,7 @@ class CakeResponseTestCase extends CakeTestCase {
$result = $response->httpCodes(404); $result = $response->httpCodes(404);
$expected = array(404 => 'Sorry Bro'); $expected = array(404 => 'Sorry Bro');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -353,4 +353,4 @@ class CakeResponseTestCase extends CakeTestCase {
$result = $response->mapType(array('application/json', 'application/xhtml+xml', 'text/css')); $result = $response->mapType(array('application/json', 'application/xhtml+xml', 'text/css'));
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
} }

View file

@ -278,19 +278,19 @@ class CakeEmailTest extends CakeTestCase {
public function testFormatAddress() { public function testFormatAddress() {
$result = $this->CakeEmail->formatAddress(array('cake@cakephp.org' => 'cake@cakephp.org')); $result = $this->CakeEmail->formatAddress(array('cake@cakephp.org' => 'cake@cakephp.org'));
$expected = array('cake@cakephp.org'); $expected = array('cake@cakephp.org');
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$result = $this->CakeEmail->formatAddress(array('cake@cakephp.org' => 'cake@cakephp.org', 'php@cakephp.org' => 'php@cakephp.org')); $result = $this->CakeEmail->formatAddress(array('cake@cakephp.org' => 'cake@cakephp.org', 'php@cakephp.org' => 'php@cakephp.org'));
$expected = array('cake@cakephp.org', 'php@cakephp.org'); $expected = array('cake@cakephp.org', 'php@cakephp.org');
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$result = $this->CakeEmail->formatAddress(array('cake@cakephp.org' => 'CakePHP', 'php@cakephp.org' => 'Cake')); $result = $this->CakeEmail->formatAddress(array('cake@cakephp.org' => 'CakePHP', 'php@cakephp.org' => 'Cake'));
$expected = array('CakePHP <cake@cakephp.org>', 'Cake <php@cakephp.org>'); $expected = array('CakePHP <cake@cakephp.org>', 'Cake <php@cakephp.org>');
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$result = $this->CakeEmail->formatAddress(array('cake@cakephp.org' => 'ÄÖÜTest')); $result = $this->CakeEmail->formatAddress(array('cake@cakephp.org' => 'ÄÖÜTest'));
$expected = array('=?UTF-8?B?w4TDlsOcVGVzdA==?= <cake@cakephp.org>'); $expected = array('=?UTF-8?B?w4TDlsOcVGVzdA==?= <cake@cakephp.org>');
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
} }
/** /**
@ -771,7 +771,7 @@ class CakeEmailTest extends CakeTestCase {
'non commodo odio. Morbi nibh nisi, vehicula pellentesque accumsan amet.', 'non commodo odio. Morbi nibh nisi, vehicula pellentesque accumsan amet.',
'' ''
); );
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$text = 'Lorem ipsum dolor sit amet, consectetur < adipiscing elit. Donec ac turpis orci, non commodo odio. Morbi nibh nisi, vehicula > pellentesque accumsan amet.'; $text = 'Lorem ipsum dolor sit amet, consectetur < adipiscing elit. Donec ac turpis orci, non commodo odio. Morbi nibh nisi, vehicula > pellentesque accumsan amet.';
$result = $this->CakeEmail->wrap($text); $result = $this->CakeEmail->wrap($text);
@ -781,7 +781,7 @@ class CakeEmailTest extends CakeTestCase {
'amet.', 'amet.',
'' ''
); );
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$text = '<p>Lorem ipsum dolor sit amet,<br> consectetur adipiscing elit.<br> Donec ac turpis orci, non <b>commodo</b> odio. <br /> Morbi nibh nisi, vehicula pellentesque accumsan amet.<hr></p>'; $text = '<p>Lorem ipsum dolor sit amet,<br> consectetur adipiscing elit.<br> Donec ac turpis orci, non <b>commodo</b> odio. <br /> Morbi nibh nisi, vehicula pellentesque accumsan amet.<hr></p>';
$result = $this->CakeEmail->wrap($text); $result = $this->CakeEmail->wrap($text);
@ -791,7 +791,7 @@ class CakeEmailTest extends CakeTestCase {
'pellentesque accumsan amet.<hr></p>', 'pellentesque accumsan amet.<hr></p>',
'' ''
); );
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac <a href="http://cakephp.org">turpis</a> orci, non commodo odio. Morbi nibh nisi, vehicula pellentesque accumsan amet.'; $text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac <a href="http://cakephp.org">turpis</a> orci, non commodo odio. Morbi nibh nisi, vehicula pellentesque accumsan amet.';
$result = $this->CakeEmail->wrap($text); $result = $this->CakeEmail->wrap($text);
@ -801,7 +801,7 @@ class CakeEmailTest extends CakeTestCase {
'nisi, vehicula pellentesque accumsan amet.', 'nisi, vehicula pellentesque accumsan amet.',
'' ''
); );
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$text = 'Lorem ipsum <a href="http://www.cakephp.org/controller/action/param1/param2" class="nice cool fine amazing awesome">ok</a>'; $text = 'Lorem ipsum <a href="http://www.cakephp.org/controller/action/param1/param2" class="nice cool fine amazing awesome">ok</a>';
$result = $this->CakeEmail->wrap($text); $result = $this->CakeEmail->wrap($text);
@ -811,7 +811,7 @@ class CakeEmailTest extends CakeTestCase {
'ok</a>', 'ok</a>',
'' ''
); );
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$text = 'Lorem ipsum withonewordverybigMorethanthelineshouldsizeofrfcspecificationbyieeeavailableonieeesite ok.'; $text = 'Lorem ipsum withonewordverybigMorethanthelineshouldsizeofrfcspecificationbyieeeavailableonieeesite ok.';
$result = $this->CakeEmail->wrap($text); $result = $this->CakeEmail->wrap($text);
@ -821,7 +821,7 @@ class CakeEmailTest extends CakeTestCase {
'ok.', 'ok.',
'' ''
); );
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
} }
} }

View file

@ -1263,7 +1263,7 @@ class DispatcherTest extends CakeTestCase {
$Dispatcher->asset('test_plugin/root.js'); $Dispatcher->asset('test_plugin/root.js');
$result = ob_get_clean(); $result = ob_get_clean();
$expected = file_get_contents(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'webroot' . DS . 'root.js'); $expected = file_get_contents(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'webroot' . DS . 'root.js');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
ob_start(); ob_start();
$Dispatcher->dispatch(new CakeRequest('test_plugin/flash/plugin_test.swf')); $Dispatcher->dispatch(new CakeRequest('test_plugin/flash/plugin_test.swf'));
@ -1304,13 +1304,13 @@ class DispatcherTest extends CakeTestCase {
$Dispatcher->asset('plugin_js/js/plugin_js.js'); $Dispatcher->asset('plugin_js/js/plugin_js.js');
$result = ob_get_clean(); $result = ob_get_clean();
$expected = "alert('win sauce');"; $expected = "alert('win sauce');";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
ob_start(); ob_start();
$Dispatcher->asset('plugin_js/js/one/plugin_one.js'); $Dispatcher->asset('plugin_js/js/one/plugin_one.js');
$result = ob_get_clean(); $result = ob_get_clean();
$expected = "alert('plugin one nested js file');"; $expected = "alert('plugin one nested js file');";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
ob_start(); ob_start();
$Dispatcher->asset('test_plugin/css/unknown.extension'); $Dispatcher->asset('test_plugin/css/unknown.extension');
@ -1406,7 +1406,7 @@ class DispatcherTest extends CakeTestCase {
$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached); $cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $cached); $expected = str_replace(array("\t", "\r\n", "\n"), "", $cached);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$filename = $this->__cachePath($request->here); $filename = $this->__cachePath($request->here);
unlink($filename); unlink($filename);
@ -1428,7 +1428,7 @@ class DispatcherTest extends CakeTestCase {
$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached); $cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $cached); $expected = str_replace(array("\t", "\r\n", "\n"), "", $cached);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$filename = $this->__cachePath($request->here); $filename = $this->__cachePath($request->here);
unlink($filename); unlink($filename);
@ -1446,7 +1446,7 @@ class DispatcherTest extends CakeTestCase {
$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached); $cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $cached); $expected = str_replace(array("\t", "\r\n", "\n"), "", $cached);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$filename = $this->__cachePath($request->here); $filename = $this->__cachePath($request->here);
unlink($filename); unlink($filename);
@ -1464,7 +1464,7 @@ class DispatcherTest extends CakeTestCase {
$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached); $cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $cached); $expected = str_replace(array("\t", "\r\n", "\n"), "", $cached);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$filename = $this->__cachePath($request->here); $filename = $this->__cachePath($request->here);
unlink($filename); unlink($filename);
@ -1482,7 +1482,7 @@ class DispatcherTest extends CakeTestCase {
$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached); $cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $cached); $expected = str_replace(array("\t", "\r\n", "\n"), "", $cached);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$filename = $this->__cachePath($request->here); $filename = $this->__cachePath($request->here);
unlink($filename); unlink($filename);
@ -1500,7 +1500,7 @@ class DispatcherTest extends CakeTestCase {
$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached); $cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $cached); $expected = str_replace(array("\t", "\r\n", "\n"), "", $cached);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$filename = $this->__cachePath($request->here); $filename = $this->__cachePath($request->here);
$this->assertTrue(file_exists($filename)); $this->assertTrue(file_exists($filename));

View file

@ -43,7 +43,7 @@ class CakeRouteTestCase extends CakeTestCase {
$route = new CakeRoute('/', array('controller' => 'pages', 'action' => 'display', 'home')); $route = new CakeRoute('/', array('controller' => 'pages', 'action' => 'display', 'home'));
$result = $route->compile(); $result = $route->compile();
$expected = '#^/*$#'; $expected = '#^/*$#';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertEqual($route->keys, array()); $this->assertEqual($route->keys, array());
$route = new CakeRoute('/:controller/:action', array('controller' => 'posts')); $route = new CakeRoute('/:controller/:action', array('controller' => 'posts'));
@ -178,7 +178,7 @@ class CakeRouteTestCase extends CakeTestCase {
$this->assertEqual($result['month'], '08'); $this->assertEqual($result['month'], '08');
$this->assertEqual($result['day'], '01'); $this->assertEqual($result['day'], '01');
$this->assertEquals($result['pass'][0], 'title-of-post'); $this->assertEquals($result['pass'][0], 'title-of-post');
$route = new CakeRoute( $route = new CakeRoute(
"/:extra/page/:slug/*", "/:extra/page/:slug/*",
@ -287,7 +287,7 @@ class CakeRouteTestCase extends CakeTestCase {
$url = array('controller' => 'subscribe', 'admin' => true, 'action' => 'edit', 1); $url = array('controller' => 'subscribe', 'admin' => true, 'action' => 'edit', 1);
$result = $route->match($url); $result = $route->match($url);
$expected = '/admin/subscriptions/edit/1'; $expected = '/admin/subscriptions/edit/1';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -486,8 +486,8 @@ class CakeRouteTestCase extends CakeTestCase {
*/ */
function testPatternOnAction() { function testPatternOnAction() {
$route = new CakeRoute( $route = new CakeRoute(
'/blog/:action/*', '/blog/:action/*',
array('controller' => 'blog_posts'), array('controller' => 'blog_posts'),
array('action' => 'other|actions') array('action' => 'other|actions')
); );
$result = $route->match(array('controller' => 'blog_posts', 'action' => 'foo')); $result = $route->match(array('controller' => 'blog_posts', 'action' => 'foo'));
@ -646,7 +646,7 @@ class CakeRouteTestCase extends CakeTestCase {
), ),
'pass' => array(), 'pass' => array(),
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $route->parse('/tests/action/theanswer[is]:42/var[]:val2/var[]:val3'); $result = $route->parse('/tests/action/theanswer[is]:42/var[]:val2/var[]:val3');
$expected = array( $expected = array(
@ -663,7 +663,7 @@ class CakeRouteTestCase extends CakeTestCase {
), ),
'pass' => array(), 'pass' => array(),
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $route->parse('/tests/action/theanswer[is][not]:42/theanswer[]:5/theanswer[is]:6'); $result = $route->parse('/tests/action/theanswer[is][not]:42/theanswer[]:5/theanswer[is]:6');
$expected = array( $expected = array(
@ -680,7 +680,7 @@ class CakeRouteTestCase extends CakeTestCase {
), ),
'pass' => array(), 'pass' => array(),
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -702,4 +702,4 @@ class CakeRouteTestCase extends CakeTestCase {
); );
$this->assertEquals($expected, $result, 'Slug should have moved'); $this->assertEquals($expected, $result, 'Slug should have moved');
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -279,7 +279,7 @@ class ControllerTestCaseTest extends CakeTestCase {
$result = $this->Case->testAction('/tests_apps/index.json', array('return' => 'view')); $result = $this->Case->testAction('/tests_apps/index.json', array('return' => 'view'));
$result = json_decode($result, true); $result = json_decode($result, true);
$expected = array('cakephp' => 'cool'); $expected = array('cakephp' => 'cool');
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
include CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'routes.php'; include CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'routes.php';
$result = $this->Case->testAction('/some_alias'); $result = $this->Case->testAction('/some_alias');

View file

@ -250,7 +250,7 @@ class DebuggerTest extends CakeTestCase {
$result = str_replace(array("\t", "\r\n", "\n"), "", $result); $result = str_replace(array("\t", "\r\n", "\n"), "", $result);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $expected); $expected = str_replace(array("\t", "\r\n", "\n"), "", $expected);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**

View file

@ -41,11 +41,11 @@ class FolderTest extends CakeTestCase {
$result = Folder::addPathElement($path, 'test'); $result = Folder::addPathElement($path, 'test');
$expected = $path . DS . 'test'; $expected = $path . DS . 'test';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $Folder->cd(ROOT); $result = $Folder->cd(ROOT);
$expected = ROOT; $expected = ROOT;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $Folder->cd(ROOT . DS . 'non-existent'); $result = $Folder->cd(ROOT . DS . 'non-existent');
$this->assertFalse($result); $this->assertFalse($result);
@ -303,7 +303,7 @@ class FolderTest extends CakeTestCase {
$Folder->path = TMP . DS . 'non-existent'; $Folder->path = TMP . DS . 'non-existent';
$expected = array(array(), array()); $expected = array(array(), array());
$result = $Folder->read(true, true); $result = $Folder->read(true, true);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -348,11 +348,11 @@ class FolderTest extends CakeTestCase {
$result = $Folder->tree(CAKE . 'Config', false, 'dir'); $result = $Folder->tree(CAKE . 'Config', false, 'dir');
$this->assertIdentical(array_diff($expected[0], $result), array()); $this->assertIdentical(array_diff($expected[0], $result), array());
$this->assertIdentical(array_diff($result, $expected[0]), array()); $this->assertIdentical(array_diff($expected, $result[0]), array());
$result = $Folder->tree(CAKE . 'Config', false, 'files'); $result = $Folder->tree(CAKE . 'Config', false, 'files');
$this->assertIdentical(array_diff($expected[1], $result), array()); $this->assertIdentical(array_diff($expected[1], $result), array());
$this->assertIdentical(array_diff($result, $expected[1]), array()); $this->assertIdentical(array_diff($expected, $result[1]), array());
} }
/** /**
@ -490,28 +490,28 @@ class FolderTest extends CakeTestCase {
$result = $Folder->find(); $result = $Folder->find();
$expected = array('config.php'); $expected = array('config.php');
$this->assertIdentical(array_diff($expected, $result), array()); $this->assertIdentical(array_diff($expected, $result), array());
$this->assertIdentical(array_diff($result, $expected), array()); $this->assertIdentical(array_diff($expected, $result), array());
$result = $Folder->find('.*', true); $result = $Folder->find('.*', true);
$expected = array('config.php'); $expected = array('config.php');
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$result = $Folder->find('.*\.php'); $result = $Folder->find('.*\.php');
$expected = array('config.php'); $expected = array('config.php');
$this->assertIdentical(array_diff($expected, $result), array()); $this->assertIdentical(array_diff($expected, $result), array());
$this->assertIdentical(array_diff($result, $expected), array()); $this->assertIdentical(array_diff($expected, $result), array());
$result = $Folder->find('.*\.php', true); $result = $Folder->find('.*\.php', true);
$expected = array('config.php'); $expected = array('config.php');
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$result = $Folder->find('.*ig\.php'); $result = $Folder->find('.*ig\.php');
$expected = array('config.php'); $expected = array('config.php');
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$result = $Folder->find('config\.php'); $result = $Folder->find('config\.php');
$expected = array('config.php'); $expected = array('config.php');
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$Folder->cd(TMP); $Folder->cd(TMP);
$file = new File($Folder->pwd() . DS . 'paths.php', true); $file = new File($Folder->pwd() . DS . 'paths.php', true);
@ -519,12 +519,12 @@ class FolderTest extends CakeTestCase {
$Folder->cd('testme'); $Folder->cd('testme');
$result = $Folder->find('paths\.php'); $result = $Folder->find('paths\.php');
$expected = array(); $expected = array();
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$Folder->cd($Folder->pwd() . '/..'); $Folder->cd($Folder->pwd() . '/..');
$result = $Folder->find('paths\.php'); $result = $Folder->find('paths\.php');
$expected = array('paths.php'); $expected = array('paths.php');
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$Folder->cd(TMP); $Folder->cd(TMP);
$Folder->delete($Folder->pwd() . DS . 'testme'); $Folder->delete($Folder->pwd() . DS . 'testme');
@ -545,13 +545,13 @@ class FolderTest extends CakeTestCase {
CAKE . 'Config' . DS . 'config.php' CAKE . 'Config' . DS . 'config.php'
); );
$this->assertIdentical(array_diff($expected, $result), array()); $this->assertIdentical(array_diff($expected, $result), array());
$this->assertIdentical(array_diff($result, $expected), array()); $this->assertIdentical(array_diff($expected, $result), array());
$result = $Folder->findRecursive('(config|paths)\.php', true); $result = $Folder->findRecursive('(config|paths)\.php', true);
$expected = array( $expected = array(
CAKE . 'Config' . DS . 'config.php' CAKE . 'Config' . DS . 'config.php'
); );
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$Folder->cd(TMP); $Folder->cd(TMP);
$Folder->create($Folder->pwd() . DS . 'testme'); $Folder->create($Folder->pwd() . DS . 'testme');
@ -561,7 +561,7 @@ class FolderTest extends CakeTestCase {
$Folder->cd(TMP . 'sessions'); $Folder->cd(TMP . 'sessions');
$result = $Folder->findRecursive('paths\.php'); $result = $Folder->findRecursive('paths\.php');
$expected = array(); $expected = array();
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$Folder->cd(TMP . 'testme'); $Folder->cd(TMP . 'testme');
$File = new File($Folder->pwd() . DS . 'my.php'); $File = new File($Folder->pwd() . DS . 'my.php');
@ -574,14 +574,14 @@ class FolderTest extends CakeTestCase {
TMP . 'testme' . DS . 'paths.php' TMP . 'testme' . DS . 'paths.php'
); );
$this->assertIdentical(array_diff($expected, $result), array()); $this->assertIdentical(array_diff($expected, $result), array());
$this->assertIdentical(array_diff($result, $expected), array()); $this->assertIdentical(array_diff($expected, $result), array());
$result = $Folder->findRecursive('(paths|my)\.php', true); $result = $Folder->findRecursive('(paths|my)\.php', true);
$expected = array( $expected = array(
TMP . 'testme' . DS . 'my.php', TMP . 'testme' . DS . 'my.php',
TMP . 'testme' . DS . 'paths.php' TMP . 'testme' . DS . 'paths.php'
); );
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$Folder->cd(CAKE . 'Config'); $Folder->cd(CAKE . 'Config');
$Folder->cd(TMP); $Folder->cd(TMP);

View file

@ -166,59 +166,59 @@ class InflectorTest extends CakeTestCase {
function testInflectorSlug() { function testInflectorSlug() {
$result = Inflector::slug('Foo Bar: Not just for breakfast any-more'); $result = Inflector::slug('Foo Bar: Not just for breakfast any-more');
$expected = 'Foo_Bar_Not_just_for_breakfast_any_more'; $expected = 'Foo_Bar_Not_just_for_breakfast_any_more';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Inflector::slug('this/is/a/path'); $result = Inflector::slug('this/is/a/path');
$expected = 'this_is_a_path'; $expected = 'this_is_a_path';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Inflector::slug('Foo Bar: Not just for breakfast any-more', "-"); $result = Inflector::slug('Foo Bar: Not just for breakfast any-more', "-");
$expected = 'Foo-Bar-Not-just-for-breakfast-any-more'; $expected = 'Foo-Bar-Not-just-for-breakfast-any-more';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Inflector::slug('Foo Bar: Not just for breakfast any-more', "+"); $result = Inflector::slug('Foo Bar: Not just for breakfast any-more', "+");
$expected = 'Foo+Bar+Not+just+for+breakfast+any+more'; $expected = 'Foo+Bar+Not+just+for+breakfast+any+more';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Inflector::slug('Äpfel Über Öl grün ärgert groß öko', '-'); $result = Inflector::slug('Äpfel Über Öl grün ärgert groß öko', '-');
$expected = 'Aepfel-Ueber-Oel-gruen-aergert-gross-oeko'; $expected = 'Aepfel-Ueber-Oel-gruen-aergert-gross-oeko';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Inflector::slug('The truth - and- more- news', '-'); $result = Inflector::slug('The truth - and- more- news', '-');
$expected = 'The-truth-and-more-news'; $expected = 'The-truth-and-more-news';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Inflector::slug('The truth: and more news', '-'); $result = Inflector::slug('The truth: and more news', '-');
$expected = 'The-truth-and-more-news'; $expected = 'The-truth-and-more-news';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Inflector::slug('La langue française est un attribut de souveraineté en France', '-'); $result = Inflector::slug('La langue française est un attribut de souveraineté en France', '-');
$expected = 'La-langue-francaise-est-un-attribut-de-souverainete-en-France'; $expected = 'La-langue-francaise-est-un-attribut-de-souverainete-en-France';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Inflector::slug('!@$#exciting stuff! - what !@-# was that?', '-'); $result = Inflector::slug('!@$#exciting stuff! - what !@-# was that?', '-');
$expected = 'exciting-stuff-what-was-that'; $expected = 'exciting-stuff-what-was-that';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Inflector::slug('20% of profits went to me!', '-'); $result = Inflector::slug('20% of profits went to me!', '-');
$expected = '20-of-profits-went-to-me'; $expected = '20-of-profits-went-to-me';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Inflector::slug('#this melts your face1#2#3', '-'); $result = Inflector::slug('#this melts your face1#2#3', '-');
$expected = 'this-melts-your-face1-2-3'; $expected = 'this-melts-your-face1-2-3';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Inflector::slug('controller/action/りんご/1'); $result = Inflector::slug('controller/action/りんご/1');
$expected = 'controller_action_りんご_1'; $expected = 'controller_action_りんご_1';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Inflector::slug('の話が出たので大丈夫かなあと'); $result = Inflector::slug('の話が出たので大丈夫かなあと');
$expected = 'の話が出たので大丈夫かなあと'; $expected = 'の話が出たので大丈夫かなあと';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Inflector::slug('posts/view/한국어/page:1/sort:asc'); $result = Inflector::slug('posts/view/한국어/page:1/sort:asc');
$expected = 'posts_view_한국어_page_1_sort_asc'; $expected = 'posts_view_한국어_page_1_sort_asc';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -231,11 +231,11 @@ class InflectorTest extends CakeTestCase {
Inflector::rules('transliteration', array('/r/' => '1')); Inflector::rules('transliteration', array('/r/' => '1'));
$result = Inflector::slug('replace every r'); $result = Inflector::slug('replace every r');
$expected = '1eplace_eve1y_1'; $expected = '1eplace_eve1y_1';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Inflector::slug('replace every r', '_'); $result = Inflector::slug('replace every r', '_');
$expected = '1eplace_eve1y_1'; $expected = '1eplace_eve1y_1';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -248,7 +248,7 @@ class InflectorTest extends CakeTestCase {
Inflector::rules('transliteration', array('/å/' => 'aa', '/ø/' => 'oe')); Inflector::rules('transliteration', array('/å/' => 'aa', '/ø/' => 'oe'));
$result = Inflector::slug('Testing æ ø å', '-'); $result = Inflector::slug('Testing æ ø å', '-');
$expected = 'Testing-ae-oe-aa'; $expected = 'Testing-ae-oe-aa';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**

View file

@ -131,47 +131,47 @@ class SanitizeTest extends CakeTestCase {
$string = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line'; $string = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line';
$expected = 'test &amp; &quot;quote&quot; &#039;other&#039; ;.$ symbol.another line'; $expected = 'test &amp; &quot;quote&quot; &#039;other&#039; ;.$ symbol.another line';
$result = Sanitize::clean($string, array('connection' => 'test')); $result = Sanitize::clean($string, array('connection' => 'test'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line'; $string = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line';
$expected = 'test & ' . Sanitize::escape('"quote"', 'test') . ' ' . Sanitize::escape('\'other\'', 'test') . ' ;.$ symbol.another line'; $expected = 'test & ' . Sanitize::escape('"quote"', 'test') . ' ' . Sanitize::escape('\'other\'', 'test') . ' ;.$ symbol.another line';
$result = Sanitize::clean($string, array('encode' => false, 'connection' => 'test')); $result = Sanitize::clean($string, array('encode' => false, 'connection' => 'test'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = 'test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line'; $string = 'test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line';
$expected = 'test & "quote" \'other\' ;.$ $ symbol.another line'; $expected = 'test & "quote" \'other\' ;.$ $ symbol.another line';
$result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'connection' => 'test')); $result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'connection' => 'test'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = 'test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line'; $string = 'test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line';
$expected = 'test & "quote" \'other\' ;.$ \\$ symbol.another line'; $expected = 'test & "quote" \'other\' ;.$ \\$ symbol.another line';
$result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'dollar' => false, 'connection' => 'test')); $result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'dollar' => false, 'connection' => 'test'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line'; $string = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line';
$expected = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line'; $expected = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line';
$result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'carriage' => false, 'connection' => 'test')); $result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'carriage' => false, 'connection' => 'test'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$array = array(array('test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line')); $array = array(array('test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line'));
$expected = array(array('test &amp; &quot;quote&quot; &#039;other&#039; ;.$ symbol.another line')); $expected = array(array('test &amp; &quot;quote&quot; &#039;other&#039; ;.$ symbol.another line'));
$result = Sanitize::clean($array, array('connection' => 'test')); $result = Sanitize::clean($array, array('connection' => 'test'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$array = array(array('test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line')); $array = array(array('test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line'));
$expected = array(array('test & "quote" \'other\' ;.$ $ symbol.another line')); $expected = array(array('test & "quote" \'other\' ;.$ $ symbol.another line'));
$result = Sanitize::clean($array, array('encode' => false, 'escape' => false, 'connection' => 'test')); $result = Sanitize::clean($array, array('encode' => false, 'escape' => false, 'connection' => 'test'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$array = array(array('test odd Ä spacesé')); $array = array(array('test odd Ä spacesé'));
$expected = array(array('test odd &Auml; spaces&eacute;')); $expected = array(array('test odd &Auml; spaces&eacute;'));
$result = Sanitize::clean($array, array('odd_spaces' => false, 'escape' => false, 'connection' => 'test')); $result = Sanitize::clean($array, array('odd_spaces' => false, 'escape' => false, 'connection' => 'test'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$array = array(array('\\$', array('key' => 'test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line'))); $array = array(array('\\$', array('key' => 'test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line')));
$expected = array(array('$', array('key' => 'test & "quote" \'other\' ;.$ $ symbol.another line'))); $expected = array(array('$', array('key' => 'test & "quote" \'other\' ;.$ $ symbol.another line')));
$result = Sanitize::clean($array, array('encode' => false, 'escape' => false)); $result = Sanitize::clean($array, array('encode' => false, 'escape' => false));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = ''; $string = '';
$expected = ''; $expected = '';
@ -212,36 +212,36 @@ class SanitizeTest extends CakeTestCase {
$string = '<p>This is a <em>test string</em> & so is this</p>'; $string = '<p>This is a <em>test string</em> & so is this</p>';
$expected = 'This is a test string &amp; so is this'; $expected = 'This is a test string &amp; so is this';
$result = Sanitize::html($string, array('remove' => true)); $result = Sanitize::html($string, array('remove' => true));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = 'The "lazy" dog \'jumped\' & flew over the moon. If (1+1) = 2 <em>is</em> true, (2-1) = 1 is also true'; $string = 'The "lazy" dog \'jumped\' & flew over the moon. If (1+1) = 2 <em>is</em> true, (2-1) = 1 is also true';
$expected = 'The &quot;lazy&quot; dog &#039;jumped&#039; &amp; flew over the moon. If (1+1) = 2 &lt;em&gt;is&lt;/em&gt; true, (2-1) = 1 is also true'; $expected = 'The &quot;lazy&quot; dog &#039;jumped&#039; &amp; flew over the moon. If (1+1) = 2 &lt;em&gt;is&lt;/em&gt; true, (2-1) = 1 is also true';
$result = Sanitize::html($string); $result = Sanitize::html($string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = 'The "lazy" dog \'jumped\''; $string = 'The "lazy" dog \'jumped\'';
$expected = 'The &quot;lazy&quot; dog \'jumped\''; $expected = 'The &quot;lazy&quot; dog \'jumped\'';
$result = Sanitize::html($string, array('quotes' => ENT_COMPAT)); $result = Sanitize::html($string, array('quotes' => ENT_COMPAT));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = 'The "lazy" dog \'jumped\''; $string = 'The "lazy" dog \'jumped\'';
$result = Sanitize::html($string, array('quotes' => ENT_NOQUOTES)); $result = Sanitize::html($string, array('quotes' => ENT_NOQUOTES));
$this->assertEqual($result, $string); $this->assertEqual($result, $string);
$string = 'The "lazy" dog \'jumped\' & flew over the moon. If (1+1) = 2 <em>is</em> true, (2-1) = 1 is also true'; $string = 'The "lazy" dog \'jumped\' & flew over the moon. If (1+1) = 2 <em>is</em> true, (2-1) = 1 is also true';
$expected = 'The &quot;lazy&quot; dog &#039;jumped&#039; &amp; flew over the moon. If (1+1) = 2 &lt;em&gt;is&lt;/em&gt; true, (2-1) = 1 is also true'; $expected = 'The &quot;lazy&quot; dog &#039;jumped&#039; &amp; flew over the moon. If (1+1) = 2 &lt;em&gt;is&lt;/em&gt; true, (2-1) = 1 is also true';
$result = Sanitize::html($string); $result = Sanitize::html($string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = 'The "lazy" dog & his friend Apple&reg; conquered the world'; $string = 'The "lazy" dog & his friend Apple&reg; conquered the world';
$expected = 'The &quot;lazy&quot; dog &amp; his friend Apple&amp;reg; conquered the world'; $expected = 'The &quot;lazy&quot; dog &amp; his friend Apple&amp;reg; conquered the world';
$result = Sanitize::html($string); $result = Sanitize::html($string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = 'The "lazy" dog & his friend Apple&reg; conquered the world'; $string = 'The "lazy" dog & his friend Apple&reg; conquered the world';
$expected = 'The &quot;lazy&quot; dog &amp; his friend Apple&reg; conquered the world'; $expected = 'The &quot;lazy&quot; dog &amp; his friend Apple&reg; conquered the world';
$result = Sanitize::html($string, array('double' => false)); $result = Sanitize::html($string, array('double' => false));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -254,7 +254,7 @@ class SanitizeTest extends CakeTestCase {
$string = "This sentence \t\t\t has lots of \n\n white\nspace \rthat \r\n needs to be \t \n trimmed."; $string = "This sentence \t\t\t has lots of \n\n white\nspace \rthat \r\n needs to be \t \n trimmed.";
$expected = "This sentence has lots of whitespace that needs to be trimmed."; $expected = "This sentence has lots of whitespace that needs to be trimmed.";
$result = Sanitize::stripWhitespace($string); $result = Sanitize::stripWhitespace($string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -267,7 +267,7 @@ class SanitizeTest extends CakeTestCase {
$string = 'I would like to !%@#% & dance & sing ^$&*()-+'; $string = 'I would like to !%@#% & dance & sing ^$&*()-+';
$expected = 'Iwouldliketodancesing'; $expected = 'Iwouldliketodancesing';
$result = Sanitize::paranoid($string); $result = Sanitize::paranoid($string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = array('This |s th% s0ng that never ends it g*es', $string = array('This |s th% s0ng that never ends it g*es',
'on and on my friends, b^ca#use it is the', 'on and on my friends, b^ca#use it is the',
@ -276,27 +276,27 @@ class SanitizeTest extends CakeTestCase {
'on and on my friends bcause it is the', 'on and on my friends bcause it is the',
'sog tht never ends.'); 'sog tht never ends.');
$result = Sanitize::paranoid($string, array('%', '*', '.', ' ')); $result = Sanitize::paranoid($string, array('%', '*', '.', ' '));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = "anything' OR 1 = 1"; $string = "anything' OR 1 = 1";
$expected = 'anythingOR11'; $expected = 'anythingOR11';
$result = Sanitize::paranoid($string); $result = Sanitize::paranoid($string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = "x' AND email IS NULL; --"; $string = "x' AND email IS NULL; --";
$expected = 'xANDemailISNULL'; $expected = 'xANDemailISNULL';
$result = Sanitize::paranoid($string); $result = Sanitize::paranoid($string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = "x' AND 1=(SELECT COUNT(*) FROM users); --"; $string = "x' AND 1=(SELECT COUNT(*) FROM users); --";
$expected = "xAND1SELECTCOUNTFROMusers"; $expected = "xAND1SELECTCOUNTFROMusers";
$result = Sanitize::paranoid($string); $result = Sanitize::paranoid($string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = "x'; DROP TABLE members; --"; $string = "x'; DROP TABLE members; --";
$expected = "xDROPTABLEmembers"; $expected = "xDROPTABLEmembers";
$result = Sanitize::paranoid($string); $result = Sanitize::paranoid($string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -309,22 +309,22 @@ class SanitizeTest extends CakeTestCase {
$string = '<img src="/img/test.jpg" alt="my image" />'; $string = '<img src="/img/test.jpg" alt="my image" />';
$expected = 'my image<br />'; $expected = 'my image<br />';
$result = Sanitize::stripImages($string); $result = Sanitize::stripImages($string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '<img src="javascript:alert(\'XSS\');" />'; $string = '<img src="javascript:alert(\'XSS\');" />';
$expected = ''; $expected = '';
$result = Sanitize::stripImages($string); $result = Sanitize::stripImages($string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '<a href="http://www.badsite.com/phising"><img src="/img/test.jpg" alt="test image alt" title="test image title" id="myImage" class="image-left"/></a>'; $string = '<a href="http://www.badsite.com/phising"><img src="/img/test.jpg" alt="test image alt" title="test image title" id="myImage" class="image-left"/></a>';
$expected = '<a href="http://www.badsite.com/phising">test image alt</a><br />'; $expected = '<a href="http://www.badsite.com/phising">test image alt</a><br />';
$result = Sanitize::stripImages($string); $result = Sanitize::stripImages($string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '<a onclick="medium()" href="http://example.com"><img src="foobar.png" onclick="evilFunction(); return false;"/></a>'; $string = '<a onclick="medium()" href="http://example.com"><img src="foobar.png" onclick="evilFunction(); return false;"/></a>';
$expected = '<a onclick="medium()" href="http://example.com"></a>'; $expected = '<a onclick="medium()" href="http://example.com"></a>';
$result = Sanitize::stripImages($string); $result = Sanitize::stripImages($string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -337,50 +337,50 @@ class SanitizeTest extends CakeTestCase {
$string = '<link href="/css/styles.css" media="screen" rel="stylesheet" />'; $string = '<link href="/css/styles.css" media="screen" rel="stylesheet" />';
$expected = ''; $expected = '';
$result = Sanitize::stripScripts($string); $result = Sanitize::stripScripts($string);
$this->assertEqual($result, $expected); $this->assertEqual($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" . '<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" />'; $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->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '<script type="text/javascript"> alert("hacked!");</script>'; $string = '<script type="text/javascript"> alert("hacked!");</script>';
$expected = ''; $expected = '';
$result = Sanitize::stripScripts($string); $result = Sanitize::stripScripts($string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '<script> alert("hacked!");</script>'; $string = '<script> alert("hacked!");</script>';
$expected = ''; $expected = '';
$result = Sanitize::stripScripts($string); $result = Sanitize::stripScripts($string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '<style>#content { display:none; }</style>'; $string = '<style>#content { display:none; }</style>';
$expected = ''; $expected = '';
$result = Sanitize::stripScripts($string); $result = Sanitize::stripScripts($string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '<style type="text/css"><!-- #content { display:none; } --></style>'; $string = '<style type="text/css"><!-- #content { display:none; } --></style>';
$expected = ''; $expected = '';
$result = Sanitize::stripScripts($string); $result = Sanitize::stripScripts($string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = <<<HTML $string = <<<HTML
text text
<style type="text/css"> <style type="text/css">
<!-- <!--
#content { display:none; } #content { display:none; }
--> -->
</style> </style>
text text
HTML; HTML;
$expected = "text\n\ntext"; $expected = "text\n\ntext";
$result = Sanitize::stripScripts($string); $result = Sanitize::stripScripts($string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = <<<HTML $string = <<<HTML
text text
<script type="text/javascript"> <script type="text/javascript">
<!-- <!--
alert('wooo'); alert('wooo');
--> -->
</script> </script>
@ -388,7 +388,7 @@ text
HTML; HTML;
$expected = "text\n\ntext"; $expected = "text\n\ntext";
$result = Sanitize::stripScripts($string); $result = Sanitize::stripScripts($string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -401,17 +401,17 @@ HTML;
$string = '<img """><script>alert("xss")</script>"/>'; $string = '<img """><script>alert("xss")</script>"/>';
$expected ='"/>'; $expected ='"/>';
$result = Sanitize::stripAll($string); $result = Sanitize::stripAll($string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '<IMG SRC=&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058&#0000097&#0000108&#0000101&#0000114&#0000116&#0000040&#0000039&#0000088&#0000083&#0000083&#0000039&#0000041>'; $string = '<IMG SRC=&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058&#0000097&#0000108&#0000101&#0000114&#0000116&#0000040&#0000039&#0000088&#0000083&#0000083&#0000039&#0000041>';
$expected = ''; $expected = '';
$result = Sanitize::stripAll($string); $result = Sanitize::stripAll($string);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '<<script>alert("XSS");//<</script>'; $string = '<<script>alert("XSS");//<</script>';
$expected = '<'; $expected = '<';
$result = Sanitize::stripAll($string); $result = Sanitize::stripAll($string);
$this->assertEqual($result, $expected); $this->assertEqual($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".
@ -419,7 +419,7 @@ HTML;
'<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->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
@ -433,37 +433,37 @@ HTML;
$string = '<h2>Headline</h2><p><a href="http://example.com">My Link</a> could go to a bad site</p>'; $string = '<h2>Headline</h2><p><a href="http://example.com">My Link</a> could go to a bad site</p>';
$expected = 'Headline<p>My Link could go to a bad site</p>'; $expected = 'Headline<p>My Link could go to a bad site</p>';
$result = Sanitize::stripTags($string, 'h2', 'a'); $result = Sanitize::stripTags($string, 'h2', 'a');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '<script type="text/javascript" src="http://evildomain.com"> </script>'; $string = '<script type="text/javascript" src="http://evildomain.com"> </script>';
$expected = ' '; $expected = ' ';
$result = Sanitize::stripTags($string, 'script'); $result = Sanitize::stripTags($string, 'script');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '<h2>Important</h2><p>Additional information here <a href="/about"><img src="/img/test.png" /></a>. Read even more here</p>'; $string = '<h2>Important</h2><p>Additional information here <a href="/about"><img src="/img/test.png" /></a>. Read even more here</p>';
$expected = 'Important<p>Additional information here <img src="/img/test.png" />. Read even more here</p>'; $expected = 'Important<p>Additional information here <img src="/img/test.png" />. Read even more here</p>';
$result = Sanitize::stripTags($string, 'h2', 'a'); $result = Sanitize::stripTags($string, 'h2', 'a');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '<h2>Important</h2><p>Additional information here <a href="/about"><img src="/img/test.png" /></a>. Read even more here</p>'; $string = '<h2>Important</h2><p>Additional information here <a href="/about"><img src="/img/test.png" /></a>. Read even more here</p>';
$expected = 'Important<p>Additional information here . Read even more here</p>'; $expected = 'Important<p>Additional information here . Read even more here</p>';
$result = Sanitize::stripTags($string, 'h2', 'a', 'img'); $result = Sanitize::stripTags($string, 'h2', 'a', 'img');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '<b>Important message!</b><br>This message will self destruct!'; $string = '<b>Important message!</b><br>This message will self destruct!';
$expected = 'Important message!<br>This message will self destruct!'; $expected = 'Important message!<br>This message will self destruct!';
$result = Sanitize::stripTags($string, 'b'); $result = Sanitize::stripTags($string, 'b');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '<b>Important message!</b><br />This message will self destruct!'; $string = '<b>Important message!</b><br />This message will self destruct!';
$expected = 'Important message!<br />This message will self destruct!'; $expected = 'Important message!<br />This message will self destruct!';
$result = Sanitize::stripTags($string, 'b'); $result = Sanitize::stripTags($string, 'b');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '<h2 onclick="alert(\'evil\'); onmouseover="badness()">Important</h2><p>Additional information here <a href="/about"><img src="/img/test.png" /></a>. Read even more here</p>'; $string = '<h2 onclick="alert(\'evil\'); onmouseover="badness()">Important</h2><p>Additional information here <a href="/about"><img src="/img/test.png" /></a>. Read even more here</p>';
$expected = 'Important<p>Additional information here . Read even more here</p>'; $expected = 'Important<p>Additional information here . Read even more here</p>';
$result = Sanitize::stripTags($string, 'h2', 'a', 'img'); $result = Sanitize::stripTags($string, 'h2', 'a', 'img');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -494,7 +494,7 @@ HTML;
)); ));
Sanitize::formatColumns($this->DataTest); Sanitize::formatColumns($this->DataTest);
$result = $this->DataTest->data; $result = $this->DataTest->data;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Article = new SanitizeArticle(array('alias' => 'Article')); $this->Article = new SanitizeArticle(array('alias' => 'Article'));
$data = array('Article' => array( $data = array('Article' => array(
@ -514,6 +514,6 @@ HTML;
)); ));
Sanitize::formatColumns($this->Article); Sanitize::formatColumns($this->Article);
$result = $this->Article->data; $result = $this->Article->data;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
} }

View file

@ -88,7 +88,7 @@ class SetTest extends CakeTestCase {
function testFilter() { function testFilter() {
$result = Set::filter(array('0', false, true, 0, array('one thing', 'I can tell you', 'is you got to be', false))); $result = Set::filter(array('0', false, true, 0, array('one thing', 'I can tell you', 'is you got to be', false)));
$expected = array('0', 2 => true, 3 => 0, 4 => array('one thing', 'I can tell you', 'is you got to be')); $expected = array('0', 2 => true, 3 => 0, 4 => array('one thing', 'I can tell you', 'is you got to be'));
$this->assertSame($result, $expected); $this->assertSame($expected, $result);
$result = Set::filter(array(1, array(false))); $result = Set::filter(array(1, array(false)));
$expected = array(1); $expected = array(1);
@ -369,7 +369,7 @@ class SetTest extends CakeTestCase {
array('employees' => array(array('name' => array()))), array('employees' => array(array('name' => array()))),
array('employees' => array(array('name' => array()))) array('employees' => array(array('name' => array())))
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -956,8 +956,8 @@ class SetTest extends CakeTestCase {
); );
$result = Set::extract('/ParentNode/name', $hasMany); $result = Set::extract('/ParentNode/name', $hasMany);
$expected = array('Second'); $expected = array('Second');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
array( array(
'Category' => array( 'Category' => array(
@ -990,7 +990,7 @@ class SetTest extends CakeTestCase {
) )
); );
$result = Set::extract('/Category[id=1]/..', $data); $result = Set::extract('/Category[id=1]/..', $data);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -1198,14 +1198,14 @@ class SetTest extends CakeTestCase {
$expected = array(1, 2, 3); $expected = array(1, 2, 3);
$r = Set::extract('/User/id', $nonZero); $r = Set::extract('/User/id', $nonZero);
$this->assertEqual($r, $expected); $this->assertEqual($r, $expected);
$expected = array( $expected = array(
array('User' => array('id' => 1, 'name' => 'John')), array('User' => array('id' => 1, 'name' => 'John')),
array('User' => array('id' => 2, 'name' => 'Bob')), array('User' => array('id' => 2, 'name' => 'Bob')),
array('User' => array('id' => 3, 'name' => 'Tony')), array('User' => array('id' => 3, 'name' => 'Tony')),
); );
$result = Set::extract('/User', $nonZero); $result = Set::extract('/User', $nonZero);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$nonSequential = array( $nonSequential = array(
'User' => array( 'User' => array(
@ -1231,13 +1231,13 @@ class SetTest extends CakeTestCase {
$this->assertEqual(Set::extract('/User/id', $nonSequential), $expected); $this->assertEqual(Set::extract('/User/id', $nonSequential), $expected);
$result = Set::extract('/User/id', $nonZero); $result = Set::extract('/User/id', $nonZero);
$this->assertEqual($result, $expected, 'Failed non zero array key extract'); $this->assertEqual($expected, $result, 'Failed non zero array key extract');
$expected = array(1, 2, 3, 4, 5); $expected = array(1, 2, 3, 4, 5);
$this->assertEqual(Set::extract('/User/id', $nonSequential), $expected); $this->assertEqual(Set::extract('/User/id', $nonSequential), $expected);
$result = Set::extract('/User/id', $nonZero); $result = Set::extract('/User/id', $nonZero);
$this->assertEqual($result, $expected, 'Failed non zero array key extract'); $this->assertEqual($expected, $result, 'Failed non zero array key extract');
$startingAtOne = array( $startingAtOne = array(
'Article' => array( 'Article' => array(
@ -1250,7 +1250,7 @@ class SetTest extends CakeTestCase {
$expected = array(0 => array('Article' => array('id' => 1, 'approved' => 1))); $expected = array(0 => array('Article' => array('id' => 1, 'approved' => 1)));
$result = Set::extract('/Article[approved=1]', $startingAtOne); $result = Set::extract('/Article[approved=1]', $startingAtOne);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$items = array( $items = array(
240 => array( 240 => array(
@ -1270,7 +1270,7 @@ class SetTest extends CakeTestCase {
); );
$result = Set::extract('/B/field1', $items); $result = Set::extract('/B/field1', $items);
$this->assertIdentical($result, $expected); $this->assertIdentical($expected, $result);
$this->assertIdentical($result, Set::extract('{n}.B.field1', $items)); $this->assertIdentical($result, Set::extract('{n}.B.field1', $items));
} }
/** /**
@ -1307,7 +1307,7 @@ class SetTest extends CakeTestCase {
array('node' => array('foo')), array('node' => array('foo')),
'bar' 'bar'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
'node' => array( 'node' => array(
@ -1320,7 +1320,7 @@ class SetTest extends CakeTestCase {
array('foo' => array('bar')), array('foo' => array('bar')),
array('bar' => array('foo')), array('bar' => array('foo')),
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$data = array( $data = array(
'node' => array( 'node' => array(
@ -1335,7 +1335,7 @@ class SetTest extends CakeTestCase {
array('foo' => array('bar')), array('foo' => array('bar')),
'foo' 'foo'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -1447,19 +1447,19 @@ class SetTest extends CakeTestCase {
$result = Set::extract($a, '{n}.Article.id'); $result = Set::extract($a, '{n}.Article.id');
$expected = array( 1, 2, 3 ); $expected = array( 1, 2, 3 );
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::extract($a, '{n}.Article.title'); $result = Set::extract($a, '{n}.Article.title');
$expected = array( 'Article 1', 'Article 2', 'Article 3' ); $expected = array( 'Article 1', 'Article 2', 'Article 3' );
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::extract($a, '1.Article.title'); $result = Set::extract($a, '1.Article.title');
$expected = 'Article 2'; $expected = 'Article 2';
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::extract($a, '3.Article.title'); $result = Set::extract($a, '3.Article.title');
$expected = null; $expected = null;
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$a = array( $a = array(
array( array(
@ -1478,7 +1478,7 @@ class SetTest extends CakeTestCase {
$result = Set::extract($a, '{n}.Article.User.username'); $result = Set::extract($a, '{n}.Article.User.username');
$expected = array( 'mariano.iglesias', 'mariano.iglesias', 'phpnut' ); $expected = array( 'mariano.iglesias', 'mariano.iglesias', 'phpnut' );
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$a = array( $a = array(
array( array(
@ -1505,7 +1505,7 @@ class SetTest extends CakeTestCase {
$result = Set::extract($a, '{n}.Article.Comment.{n}.id'); $result = Set::extract($a, '{n}.Article.Comment.{n}.id');
$expected = array (array(10, 11, 12), array(13, 14), null); $expected = array (array(10, 11, 12), array(13, 14), null);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::extract($a, '{n}.Article.Comment.{n}.title'); $result = Set::extract($a, '{n}.Article.Comment.{n}.title');
$expected = array( $expected = array(
@ -1513,12 +1513,12 @@ class SetTest extends CakeTestCase {
array('Comment 13', 'Comment 14'), array('Comment 13', 'Comment 14'),
null null
); );
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$a = array(array('1day' => '20 sales'), array('1day' => '2 sales')); $a = array(array('1day' => '20 sales'), array('1day' => '2 sales'));
$result = Set::extract($a, '{n}.1day'); $result = Set::extract($a, '{n}.1day');
$expected = array('20 sales', '2 sales'); $expected = array('20 sales', '2 sales');
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$a = array( $a = array(
'pages' => array('name' => 'page'), 'pages' => array('name' => 'page'),
@ -1527,7 +1527,7 @@ class SetTest extends CakeTestCase {
); );
$result = Set::extract($a, '{s}.name'); $result = Set::extract($a, '{s}.name');
$expected = array('page','fruit'); $expected = array('page','fruit');
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$a = array( $a = array(
0 => array('pages' => array('name' => 'page')), 0 => array('pages' => array('name' => 'page')),
@ -1538,11 +1538,11 @@ class SetTest extends CakeTestCase {
$result = Set::extract($a, '{n}.{s}.name'); $result = Set::extract($a, '{n}.{s}.name');
$expected = array(0 => array('page'), 1 => array('fruit')); $expected = array(0 => array('page'), 1 => array('fruit'));
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::extract($a, '{s}.{n}.name'); $result = Set::extract($a, '{s}.{n}.name');
$expected = array(array('jippi'), array('jippi')); $expected = array(array('jippi'), array('jippi'));
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::extract($a, '{\w+}.{\w+}.name'); $result = Set::extract($a, '{\w+}.{\w+}.name');
$expected = array( $expected = array(
@ -1551,34 +1551,34 @@ class SetTest extends CakeTestCase {
'test' => array('jippi'), 'test' => array('jippi'),
'dot.test' => array('jippi') 'dot.test' => array('jippi')
); );
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::extract($a, '{\d+}.{\w+}.name'); $result = Set::extract($a, '{\d+}.{\w+}.name');
$expected = array(array('pages' => 'page'), array('fruites' => 'fruit')); $expected = array(array('pages' => 'page'), array('fruites' => 'fruit'));
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::extract($a, '{n}.{\w+}.name'); $result = Set::extract($a, '{n}.{\w+}.name');
$expected = array(array('pages' => 'page'), array('fruites' => 'fruit')); $expected = array(array('pages' => 'page'), array('fruites' => 'fruit'));
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::extract($a, '{s}.{\d+}.name'); $result = Set::extract($a, '{s}.{\d+}.name');
$expected = array(array('jippi'), array('jippi')); $expected = array(array('jippi'), array('jippi'));
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::extract($a, '{s}'); $result = Set::extract($a, '{s}');
$expected = array(array(array('name' => 'jippi')), array(array('name' => 'jippi'))); $expected = array(array(array('name' => 'jippi')), array(array('name' => 'jippi')));
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::extract($a, '{[a-z]}'); $result = Set::extract($a, '{[a-z]}');
$expected = array( $expected = array(
'test' => array(array('name' => 'jippi')), 'test' => array(array('name' => 'jippi')),
'dot.test' => array(array('name' => 'jippi')) 'dot.test' => array(array('name' => 'jippi'))
); );
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::extract($a, '{dot\.test}.{n}'); $result = Set::extract($a, '{dot\.test}.{n}');
$expected = array('dot.test' => array(array('name' => 'jippi'))); $expected = array('dot.test' => array(array('name' => 'jippi')));
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$a = new stdClass(); $a = new stdClass();
$a->articles = array( $a->articles = array(
@ -1589,11 +1589,11 @@ class SetTest extends CakeTestCase {
$result = Set::extract($a, 'articles.{n}.Article.id'); $result = Set::extract($a, 'articles.{n}.Article.id');
$expected = array(1, 2, 3); $expected = array(1, 2, 3);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::extract($a, 'articles.{n}.Article.title'); $result = Set::extract($a, 'articles.{n}.Article.title');
$expected = array('Article 1', 'Article 2', 'Article 3'); $expected = array('Article 1', 'Article 2', 'Article 3');
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
} }
/** /**
@ -1612,7 +1612,7 @@ class SetTest extends CakeTestCase {
'pages' => array('name' => 'page'), 'pages' => array('name' => 'page'),
'files' => array('name' => 'files') 'files' => array('name' => 'files')
); );
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$a = array( $a = array(
'pages' => array('name' => 'page') 'pages' => array('name' => 'page')
@ -1621,7 +1621,7 @@ class SetTest extends CakeTestCase {
$expected = array( $expected = array(
'pages' => array('name' => array()), 'pages' => array('name' => array()),
); );
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$a = array( $a = array(
'pages' => array( 'pages' => array(
@ -1637,7 +1637,7 @@ class SetTest extends CakeTestCase {
1 => array('name' => 'about', 'vars' => array('title' => 'page title')) 1 => array('name' => 'about', 'vars' => array('title' => 'page title'))
) )
); );
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
} }
/** /**
@ -1656,7 +1656,7 @@ class SetTest extends CakeTestCase {
$expected = array( $expected = array(
'pages' => array('name' => 'page') 'pages' => array('name' => 'page')
); );
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$a = array( $a = array(
'pages' => array( 'pages' => array(
@ -1672,11 +1672,11 @@ class SetTest extends CakeTestCase {
1 => array('name' => 'about') 1 => array('name' => 'about')
) )
); );
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::remove($a, 'pages.2.vars', array('title' => 'page title')); $result = Set::remove($a, 'pages.2.vars', array('title' => 'page title'));
$expected = $a; $expected = $a;
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
} }
/** /**
@ -1741,15 +1741,15 @@ class SetTest extends CakeTestCase {
$expected = array( $expected = array(
2 => array('name' => 'contact') 2 => array('name' => 'contact')
); );
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::diff($a, array()); $result = Set::diff($a, array());
$expected = $a; $expected = $a;
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::diff(array(), $b); $result = Set::diff(array(), $b);
$expected = $b; $expected = $b;
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$b = array( $b = array(
0 => array('name' => 'me'), 0 => array('name' => 'me'),
@ -1760,7 +1760,7 @@ class SetTest extends CakeTestCase {
$expected = array( $expected = array(
0 => array('name' => 'main') 0 => array('name' => 'main')
); );
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$a = array(); $a = array();
$b = array('name' => 'bob', 'address' => 'home'); $b = array('name' => 'bob', 'address' => 'home');
@ -1777,31 +1777,31 @@ class SetTest extends CakeTestCase {
$b = array('key' => 1, 'another' => 0); $b = array('key' => 1, 'another' => 0);
$expected = array('name' => 'me'); $expected = array('name' => 'me');
$result = Set::diff($a, $b); $result = Set::diff($a, $b);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$a = array('key' => 'value', 'another' => null, 'name' => 'me'); $a = array('key' => 'value', 'another' => null, 'name' => 'me');
$b = array('key' => 'differentValue', 'another' => null); $b = array('key' => 'differentValue', 'another' => null);
$expected = array('key' => 'value', 'name' => 'me'); $expected = array('key' => 'value', 'name' => 'me');
$result = Set::diff($a, $b); $result = Set::diff($a, $b);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$a = array('key' => 'value', 'another' => null, 'name' => 'me'); $a = array('key' => 'value', 'another' => null, 'name' => 'me');
$b = array('key' => 'differentValue', 'another' => 'value'); $b = array('key' => 'differentValue', 'another' => 'value');
$expected = array('key' => 'value', 'another' => null, 'name' => 'me'); $expected = array('key' => 'value', 'another' => null, 'name' => 'me');
$result = Set::diff($a, $b); $result = Set::diff($a, $b);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$a = array('key' => 'value', 'another' => null, 'name' => 'me'); $a = array('key' => 'value', 'another' => null, 'name' => 'me');
$b = array('key' => 'differentValue', 'another' => 'value'); $b = array('key' => 'differentValue', 'another' => 'value');
$expected = array('key' => 'differentValue', 'another' => 'value', 'name' => 'me'); $expected = array('key' => 'differentValue', 'another' => 'value', 'name' => 'me');
$result = Set::diff($b, $a); $result = Set::diff($b, $a);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$a = array('key' => 'value', 'another' => null, 'name' => 'me'); $a = array('key' => 'value', 'another' => null, 'name' => 'me');
$b = array(0 => 'differentValue', 1 => 'value'); $b = array(0 => 'differentValue', 1 => 'value');
$expected = $a + $b; $expected = $a + $b;
$result = Set::diff($a, $b); $result = Set::diff($a, $b);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
} }
/** /**
@ -1848,25 +1848,25 @@ class SetTest extends CakeTestCase {
'Data' => array('user' => 'gwoo','name' => 'The Gwoo')))); 'Data' => array('user' => 'gwoo','name' => 'The Gwoo'))));
$result = Set::combine($a, '{n}.User.id'); $result = Set::combine($a, '{n}.User.id');
$expected = array(2 => null, 14 => null, 25 => null); $expected = array(2 => null, 14 => null, 25 => null);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::combine($a, '{n}.User.id', '{n}.User.non-existant'); $result = Set::combine($a, '{n}.User.id', '{n}.User.non-existant');
$expected = array(2 => null, 14 => null, 25 => null); $expected = array(2 => null, 14 => null, 25 => null);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::combine($a, '{n}.User.id', '{n}.User.Data'); $result = Set::combine($a, '{n}.User.id', '{n}.User.Data');
$expected = array( $expected = array(
2 => array('user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias'), 2 => array('user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias'),
14 => array('user' => 'phpnut', 'name' => 'Larry E. Masters'), 14 => array('user' => 'phpnut', 'name' => 'Larry E. Masters'),
25 => array('user' => 'gwoo', 'name' => 'The Gwoo')); 25 => array('user' => 'gwoo', 'name' => 'The Gwoo'));
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::combine($a, '{n}.User.id', '{n}.User.Data.name'); $result = Set::combine($a, '{n}.User.id', '{n}.User.Data.name');
$expected = array( $expected = array(
2 => 'Mariano Iglesias', 2 => 'Mariano Iglesias',
14 => 'Larry E. Masters', 14 => 'Larry E. Masters',
25 => 'The Gwoo'); 25 => 'The Gwoo');
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::combine($a, '{n}.User.id', '{n}.User.Data', '{n}.User.group_id'); $result = Set::combine($a, '{n}.User.id', '{n}.User.Data', '{n}.User.group_id');
$expected = array( $expected = array(
@ -1875,7 +1875,7 @@ class SetTest extends CakeTestCase {
25 => array('user' => 'gwoo', 'name' => 'The Gwoo')), 25 => array('user' => 'gwoo', 'name' => 'The Gwoo')),
2 => array( 2 => array(
14 => array('user' => 'phpnut', 'name' => 'Larry E. Masters'))); 14 => array('user' => 'phpnut', 'name' => 'Larry E. Masters')));
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::combine($a, '{n}.User.id', '{n}.User.Data.name', '{n}.User.group_id'); $result = Set::combine($a, '{n}.User.id', '{n}.User.Data.name', '{n}.User.group_id');
$expected = array( $expected = array(
@ -1884,22 +1884,22 @@ class SetTest extends CakeTestCase {
25 => 'The Gwoo'), 25 => 'The Gwoo'),
2 => array( 2 => array(
14 => 'Larry E. Masters')); 14 => 'Larry E. Masters'));
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::combine($a, '{n}.User.id'); $result = Set::combine($a, '{n}.User.id');
$expected = array(2 => null, 14 => null, 25 => null); $expected = array(2 => null, 14 => null, 25 => null);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::combine($a, '{n}.User.id', '{n}.User.Data'); $result = Set::combine($a, '{n}.User.id', '{n}.User.Data');
$expected = array( $expected = array(
2 => array('user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias'), 2 => array('user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias'),
14 => array('user' => 'phpnut', 'name' => 'Larry E. Masters'), 14 => array('user' => 'phpnut', 'name' => 'Larry E. Masters'),
25 => array('user' => 'gwoo', 'name' => 'The Gwoo')); 25 => array('user' => 'gwoo', 'name' => 'The Gwoo'));
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::combine($a, '{n}.User.id', '{n}.User.Data.name'); $result = Set::combine($a, '{n}.User.id', '{n}.User.Data.name');
$expected = array(2 => 'Mariano Iglesias', 14 => 'Larry E. Masters', 25 => 'The Gwoo'); $expected = array(2 => 'Mariano Iglesias', 14 => 'Larry E. Masters', 25 => 'The Gwoo');
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::combine($a, '{n}.User.id', '{n}.User.Data', '{n}.User.group_id'); $result = Set::combine($a, '{n}.User.id', '{n}.User.Data', '{n}.User.group_id');
$expected = array( $expected = array(
@ -1908,7 +1908,7 @@ class SetTest extends CakeTestCase {
25 => array('user' => 'gwoo', 'name' => 'The Gwoo')), 25 => array('user' => 'gwoo', 'name' => 'The Gwoo')),
2 => array( 2 => array(
14 => array('user' => 'phpnut', 'name' => 'Larry E. Masters'))); 14 => array('user' => 'phpnut', 'name' => 'Larry E. Masters')));
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::combine($a, '{n}.User.id', '{n}.User.Data.name', '{n}.User.group_id'); $result = Set::combine($a, '{n}.User.id', '{n}.User.Data.name', '{n}.User.group_id');
$expected = array( $expected = array(
@ -1917,7 +1917,7 @@ class SetTest extends CakeTestCase {
25 => 'The Gwoo'), 25 => 'The Gwoo'),
2 => array( 2 => array(
14 => 'Larry E. Masters')); 14 => 'Larry E. Masters'));
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::combine($a, '{n}.User.id', array('{0}: {1}', '{n}.User.Data.user', '{n}.User.Data.name'), '{n}.User.group_id'); $result = Set::combine($a, '{n}.User.id', array('{0}: {1}', '{n}.User.Data.user', '{n}.User.Data.name'), '{n}.User.group_id');
$expected = array ( $expected = array (
@ -1925,23 +1925,23 @@ class SetTest extends CakeTestCase {
2 => 'mariano.iglesias: Mariano Iglesias', 2 => 'mariano.iglesias: Mariano Iglesias',
25 => 'gwoo: The Gwoo'), 25 => 'gwoo: The Gwoo'),
2 => array (14 => 'phpnut: Larry E. Masters')); 2 => array (14 => 'phpnut: Larry E. Masters'));
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::combine($a, array('{0}: {1}', '{n}.User.Data.user', '{n}.User.Data.name'), '{n}.User.id'); $result = Set::combine($a, array('{0}: {1}', '{n}.User.Data.user', '{n}.User.Data.name'), '{n}.User.id');
$expected = array('mariano.iglesias: Mariano Iglesias' => 2, 'phpnut: Larry E. Masters' => 14, 'gwoo: The Gwoo' => 25); $expected = array('mariano.iglesias: Mariano Iglesias' => 2, 'phpnut: Larry E. Masters' => 14, 'gwoo: The Gwoo' => 25);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::combine($a, array('{1}: {0}', '{n}.User.Data.user', '{n}.User.Data.name'), '{n}.User.id'); $result = Set::combine($a, array('{1}: {0}', '{n}.User.Data.user', '{n}.User.Data.name'), '{n}.User.id');
$expected = array('Mariano Iglesias: mariano.iglesias' => 2, 'Larry E. Masters: phpnut' => 14, 'The Gwoo: gwoo' => 25); $expected = array('Mariano Iglesias: mariano.iglesias' => 2, 'Larry E. Masters: phpnut' => 14, 'The Gwoo: gwoo' => 25);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::combine($a, array('%1$s: %2$d', '{n}.User.Data.user', '{n}.User.id'), '{n}.User.Data.name'); $result = Set::combine($a, array('%1$s: %2$d', '{n}.User.Data.user', '{n}.User.id'), '{n}.User.Data.name');
$expected = array('mariano.iglesias: 2' => 'Mariano Iglesias', 'phpnut: 14' => 'Larry E. Masters', 'gwoo: 25' => 'The Gwoo'); $expected = array('mariano.iglesias: 2' => 'Mariano Iglesias', 'phpnut: 14' => 'Larry E. Masters', 'gwoo: 25' => 'The Gwoo');
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::combine($a, array('%2$d: %1$s', '{n}.User.Data.user', '{n}.User.id'), '{n}.User.Data.name'); $result = Set::combine($a, array('%2$d: %1$s', '{n}.User.Data.user', '{n}.User.id'), '{n}.User.Data.name');
$expected = array('2: mariano.iglesias' => 'Mariano Iglesias', '14: phpnut' => 'Larry E. Masters', '25: gwoo' => 'The Gwoo'); $expected = array('2: mariano.iglesias' => 'Mariano Iglesias', '14: phpnut' => 'Larry E. Masters', '25: gwoo' => 'The Gwoo');
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$b = new stdClass(); $b = new stdClass();
$b->users = array( $b->users = array(
@ -1953,11 +1953,11 @@ class SetTest extends CakeTestCase {
'Data' => array('user' => 'gwoo','name' => 'The Gwoo')))); 'Data' => array('user' => 'gwoo','name' => 'The Gwoo'))));
$result = Set::combine($b, 'users.{n}.User.id'); $result = Set::combine($b, 'users.{n}.User.id');
$expected = array(2 => null, 14 => null, 25 => null); $expected = array(2 => null, 14 => null, 25 => null);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::combine($b, 'users.{n}.User.id', 'users.{n}.User.non-existant'); $result = Set::combine($b, 'users.{n}.User.id', 'users.{n}.User.non-existant');
$expected = array(2 => null, 14 => null, 25 => null); $expected = array(2 => null, 14 => null, 25 => null);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::combine($a, 'fail', 'fail'); $result = Set::combine($a, 'fail', 'fail');
$this->assertEqual($result, array()); $this->assertEqual($result, array());
@ -1996,7 +1996,7 @@ class SetTest extends CakeTestCase {
$this->assertEqual($map->Array2[0]->Array2Data1, $expected['Array2'][0]['Array2Data1']); $this->assertEqual($map->Array2[0]->Array2Data1, $expected['Array2'][0]['Array2Data1']);
$result = Set::reverse($map); $result = Set::reverse($map);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$expected = array( $expected = array(
'Post' => array('id'=> 1, 'title' => 'First Post'), 'Post' => array('id'=> 1, 'title' => 'First Post'),
@ -2037,7 +2037,7 @@ class SetTest extends CakeTestCase {
4 => array('Array3Data1' => 5, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'))); 4 => array('Array3Data1' => 5, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4')));
$map = Set::map($expected, true); $map = Set::map($expected, true);
$result = Set::reverse($map); $result = Set::reverse($map);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$expected = array( $expected = array(
'Array1' => array( 'Array1' => array(
@ -2066,12 +2066,12 @@ class SetTest extends CakeTestCase {
'some3' => 'thing else'); 'some3' => 'thing else');
$map = Set::map($expected, true); $map = Set::map($expected, true);
$result = Set::reverse($map); $result = Set::reverse($map);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$expected = array('User' => array('psword'=> 'whatever', 'Icon' => array('id'=> 851))); $expected = array('User' => array('psword'=> 'whatever', 'Icon' => array('id'=> 851)));
$map = Set::map($expected); $map = Set::map($expected);
$result = Set::reverse($map); $result = Set::reverse($map);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$expected = array('User' => array('psword'=> 'whatever', 'Icon' => array('id'=> 851))); $expected = array('User' => array('psword'=> 'whatever', 'Icon' => array('id'=> 851)));
$class = new stdClass; $class = new stdClass;
@ -2080,7 +2080,7 @@ class SetTest extends CakeTestCase {
$class->User->Icon = new stdClass; $class->User->Icon = new stdClass;
$class->User->Icon->id = 851; $class->User->Icon->id = 851;
$result = Set::reverse($class); $result = Set::reverse($class);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$expected = array('User' => array('psword'=> 'whatever', 'Icon' => array('id'=> 851), 'Profile' => array('name' => 'Some Name', 'address' => 'Some Address'))); $expected = array('User' => array('psword'=> 'whatever', 'Icon' => array('id'=> 851), 'Profile' => array('name' => 'Some Name', 'address' => 'Some Address')));
$class = new stdClass; $class = new stdClass;
@ -2093,7 +2093,7 @@ class SetTest extends CakeTestCase {
$class->User->Profile->address = 'Some Address'; $class->User->Profile->address = 'Some Address';
$result = Set::reverse($class); $result = Set::reverse($class);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$expected = array('User' => array('psword'=> 'whatever', $expected = array('User' => array('psword'=> 'whatever',
'Icon' => array('id'=> 851), 'Icon' => array('id'=> 851),
@ -2129,7 +2129,7 @@ class SetTest extends CakeTestCase {
$class->User->Comment->{'1'}->updated = '2007-03-18 10:49:31'; $class->User->Comment->{'1'}->updated = '2007-03-18 10:49:31';
$result = Set::reverse($class); $result = Set::reverse($class);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$expected = array('User' => array('psword'=> 'whatever', $expected = array('User' => array('psword'=> 'whatever',
'Icon' => array('id'=> 851), 'Icon' => array('id'=> 851),
@ -2165,7 +2165,7 @@ class SetTest extends CakeTestCase {
$comment2->updated = '2007-03-18 10:49:31'; $comment2->updated = '2007-03-18 10:49:31';
$class->User->Comment = array($comment, $comment2); $class->User->Comment = array($comment, $comment2);
$result = Set::reverse($class); $result = Set::reverse($class);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$class = new stdClass; $class = new stdClass;
$class->User = new stdClass; $class->User = new stdClass;
@ -2176,7 +2176,7 @@ class SetTest extends CakeTestCase {
$result = Set::reverse($class); $result = Set::reverse($class);
$expected = array('User' => array('id' => '100'), 'someString'=> 'this is some string', 'Profile' => array('name' => 'Joe Mamma')); $expected = array('User' => array('id' => '100'), 'someString'=> 'this is some string', 'Profile' => array('name' => 'Joe Mamma'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$class = new stdClass; $class = new stdClass;
$class->User = new stdClass; $class->User = new stdClass;
@ -2188,7 +2188,7 @@ class SetTest extends CakeTestCase {
$result = Set::reverse($class); $result = Set::reverse($class);
$expected = array('User' => array('id' => '100'), 'Profile' => array('name' => 'Joe Mamma')); $expected = array('User' => array('id' => '100'), 'Profile' => array('name' => 'Joe Mamma'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -2205,38 +2205,38 @@ class SetTest extends CakeTestCase {
$result = Set::format($data, '{1}, {0}', array('{n}.Person.first_name', '{n}.Person.last_name')); $result = Set::format($data, '{1}, {0}', array('{n}.Person.first_name', '{n}.Person.last_name'));
$expected = array('Abele, Nate', 'Masters, Larry', 'Woodworth, Garrett'); $expected = array('Abele, Nate', 'Masters, Larry', 'Woodworth, Garrett');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::format($data, '{0}, {1}', array('{n}.Person.last_name', '{n}.Person.first_name')); $result = Set::format($data, '{0}, {1}', array('{n}.Person.last_name', '{n}.Person.first_name'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::format($data, '{0}, {1}', array('{n}.Person.city', '{n}.Person.state')); $result = Set::format($data, '{0}, {1}', array('{n}.Person.city', '{n}.Person.state'));
$expected = array('Boston, MA', 'Boondock, TN', 'Venice Beach, CA'); $expected = array('Boston, MA', 'Boondock, TN', 'Venice Beach, CA');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::format($data, '{{0}, {1}}', array('{n}.Person.city', '{n}.Person.state')); $result = Set::format($data, '{{0}, {1}}', array('{n}.Person.city', '{n}.Person.state'));
$expected = array('{Boston, MA}', '{Boondock, TN}', '{Venice Beach, CA}'); $expected = array('{Boston, MA}', '{Boondock, TN}', '{Venice Beach, CA}');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::format($data, '{{0}, {1}}', array('{n}.Person.something', '{n}.Person.something')); $result = Set::format($data, '{{0}, {1}}', array('{n}.Person.something', '{n}.Person.something'));
$expected = array('{42, 42}', '{{0}, {0}}', '{{1}, {1}}'); $expected = array('{42, 42}', '{{0}, {0}}', '{{1}, {1}}');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::format($data, '{%2$d, %1$s}', array('{n}.Person.something', '{n}.Person.something')); $result = Set::format($data, '{%2$d, %1$s}', array('{n}.Person.something', '{n}.Person.something'));
$expected = array('{42, 42}', '{0, {0}}', '{0, {1}}'); $expected = array('{42, 42}', '{0, {0}}', '{0, {1}}');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::format($data, '{%1$s, %1$s}', array('{n}.Person.something', '{n}.Person.something')); $result = Set::format($data, '{%1$s, %1$s}', array('{n}.Person.something', '{n}.Person.something'));
$expected = array('{42, 42}', '{{0}, {0}}', '{{1}, {1}}'); $expected = array('{42, 42}', '{{0}, {0}}', '{{1}, {1}}');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::format($data, '%2$d, %1$s', array('{n}.Person.first_name', '{n}.Person.something')); $result = Set::format($data, '%2$d, %1$s', array('{n}.Person.first_name', '{n}.Person.something'));
$expected = array('42, Nate', '0, Larry', '0, Garrett'); $expected = array('42, Nate', '0, Larry', '0, Garrett');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::format($data, '%1$s, %2$d', array('{n}.Person.first_name', '{n}.Person.something')); $result = Set::format($data, '%1$s, %2$d', array('{n}.Person.first_name', '{n}.Person.something'));
$expected = array('Nate, 42', 'Larry, 0', 'Garrett, 0'); $expected = array('Nate, 42', 'Larry, 0', 'Garrett, 0');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -2368,7 +2368,7 @@ class SetTest extends CakeTestCase {
$this->assertEqual(get_object_vars($mapped[0]->headers), $expected[0]['IndexedPage']['headers']); $this->assertEqual(get_object_vars($mapped[0]->headers), $expected[0]['IndexedPage']['headers']);
$result = Set::reverse($mapped); $result = Set::reverse($mapped);
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$data = array( $data = array(
array( array(
@ -2416,7 +2416,7 @@ class SetTest extends CakeTestCase {
$result = Set::map(null); $result = Set::map(null);
$expected = null; $expected = null;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -2686,7 +2686,7 @@ class SetTest extends CakeTestCase {
$result = Set::pushDiff($array1, $array3); $result = Set::pushDiff($array1, $array3);
$expected = array('ModelOne' => array('id'=>1001, 'field_one'=>'a1.m1.f1', 'field_two'=>'a1.m1.f2', 'field_three'=>'a3.m1.f3')); $expected = array('ModelOne' => array('id'=>1001, 'field_one'=>'a1.m1.f1', 'field_two'=>'a1.m1.f2', 'field_three'=>'a3.m1.f3'));
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$array1 = array( $array1 = array(
@ -2706,7 +2706,7 @@ class SetTest extends CakeTestCase {
0 => array('ModelOne' => array('id'=>1001, 'field_one'=>'s1.0.m1.f1', 'field_two'=>'s1.0.m1.f2'), 0 => array('ModelOne' => array('id'=>1001, 'field_one'=>'s1.0.m1.f1', 'field_two'=>'s1.0.m1.f2'),
'ModelThree' => array('id'=>1003, 'field_one'=>'s3.0.m3.f1', 'field_two'=>'s3.0.m3.f2')), 'ModelThree' => array('id'=>1003, 'field_one'=>'s3.0.m3.f1', 'field_two'=>'s3.0.m3.f2')),
1 => array('ModelTwo' => array('id'=>1002, 'field_one'=>'s1.1.m2.f2', 'field_two'=>'s1.1.m2.f2'))); 1 => array('ModelTwo' => array('id'=>1002, 'field_one'=>'s1.1.m2.f2', 'field_two'=>'s1.1.m2.f2')));
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$result = Set::pushDiff($array1, null); $result = Set::pushDiff($array1, null);
$this->assertEquals($result, $array1); $this->assertEquals($result, $array1);
@ -2730,28 +2730,28 @@ class SetTest extends CakeTestCase {
$result = Set::apply('/Movie/rating', $data, 'array_sum'); $result = Set::apply('/Movie/rating', $data, 'array_sum');
$expected = 9; $expected = 9;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::apply('/Movie/rating', $data, 'array_product'); $result = Set::apply('/Movie/rating', $data, 'array_product');
$expected = 15; $expected = 15;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::apply('/Movie/title', $data, 'ucfirst', array('type' => 'map')); $result = Set::apply('/Movie/title', $data, 'ucfirst', array('type' => 'map'));
$expected = array('Movie 3', 'Movie 1', 'Movie 2'); $expected = array('Movie 3', 'Movie 1', 'Movie 2');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::apply('/Movie/title', $data, 'strtoupper', array('type' => 'map')); $result = Set::apply('/Movie/title', $data, 'strtoupper', array('type' => 'map'));
$expected = array('MOVIE 3', 'MOVIE 1', 'MOVIE 2'); $expected = array('MOVIE 3', 'MOVIE 1', 'MOVIE 2');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::apply('/Movie/rating', $data, array('SetTest', '_method'), array('type' => 'reduce')); $result = Set::apply('/Movie/rating', $data, array('SetTest', '_method'), array('type' => 'reduce'));
$expected = 9; $expected = 9;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = Set::apply('/Movie/rating', $data, 'strtoupper', array('type' => 'non existing type')); $result = Set::apply('/Movie/rating', $data, 'strtoupper', array('type' => 'non existing type'));
$expected = null; $expected = null;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
@ -2828,13 +2828,13 @@ class SetTest extends CakeTestCase {
) )
) )
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string ='<data><post title="Title of this post" description="cool"/></data>'; $string ='<data><post title="Title of this post" description="cool"/></data>';
$xml = Xml::build($string); $xml = Xml::build($string);
$result = Set::reverse($xml); $result = Set::reverse($xml);
$expected = array('data' => array('post' => array('@title' => 'Title of this post', '@description' => 'cool'))); $expected = array('data' => array('post' => array('@title' => 'Title of this post', '@description' => 'cool')));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$xml = Xml::build('<example><item><title>An example of a correctly reversed SimpleXMLElement</title><desc/></item></example>'); $xml = Xml::build('<example><item><title>An example of a correctly reversed SimpleXMLElement</title><desc/></item></example>');
$result = Set::reverse($xml); $result = Set::reverse($xml);
@ -2846,7 +2846,7 @@ class SetTest extends CakeTestCase {
) )
) )
); );
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$xml = Xml::build('<example><item attr="123"><titles><title>title1</title><title>title2</title></titles></item></example>'); $xml = Xml::build('<example><item attr="123"><titles><title>title1</title><title>title2</title></titles></item></example>');
$result = Set::reverse($xml); $result = Set::reverse($xml);
@ -2860,7 +2860,7 @@ class SetTest extends CakeTestCase {
) )
) )
); );
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$xml = Xml::build('<example attr="ex_attr"><item attr="123"><titles>list</titles>textforitems</item></example>'); $xml = Xml::build('<example attr="ex_attr"><item attr="123"><titles>list</titles>textforitems</item></example>');
$result = Set::reverse($xml); $result = Set::reverse($xml);
@ -2874,7 +2874,7 @@ class SetTest extends CakeTestCase {
) )
) )
); );
$this->assertEquals($result, $expected); $this->assertEquals($expected, $result);
$string = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?> $string = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<rss version="2.0" xmlns:dc="http://www.cakephp.org/"> <rss version="2.0" xmlns:dc="http://www.cakephp.org/">
@ -2942,7 +2942,7 @@ class SetTest extends CakeTestCase {
) )
) )
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$text = '<?xml version="1.0" encoding="UTF-8"?> $text = '<?xml version="1.0" encoding="UTF-8"?>
<XRDS xmlns="xri://$xrds"> <XRDS xmlns="xri://$xrds">
@ -3005,7 +3005,7 @@ class SetTest extends CakeTestCase {
) )
) )
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -3052,7 +3052,7 @@ class SetTest extends CakeTestCase {
'1.Post.title' => 'Second Post', '1.Post.body' => 'Second Post Body', '1.Author.id' => '3', '1.Post.title' => 'Second Post', '1.Post.body' => 'Second Post Body', '1.Author.id' => '3',
'1.Author.user' => 'larry', '1.Author.password' => null '1.Author.user' => 'larry', '1.Author.password' => null
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**

View file

@ -68,124 +68,124 @@ class StringTest extends CakeTestCase {
$string = 'some string'; $string = 'some string';
$expected = 'some string'; $expected = 'some string';
$result = String::insert($string, array()); $result = String::insert($string, array());
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '2 + 2 = :sum. Cake is :adjective.'; $string = '2 + 2 = :sum. Cake is :adjective.';
$expected = '2 + 2 = 4. Cake is yummy.'; $expected = '2 + 2 = 4. Cake is yummy.';
$result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy')); $result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '2 + 2 = %sum. Cake is %adjective.'; $string = '2 + 2 = %sum. Cake is %adjective.';
$result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('before' => '%')); $result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('before' => '%'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '2 + 2 = 2sum2. Cake is 9adjective9.'; $string = '2 + 2 = 2sum2. Cake is 9adjective9.';
$result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('format' => '/([\d])%s\\1/')); $result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('format' => '/([\d])%s\\1/'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '2 + 2 = 12sum21. Cake is 23adjective45.'; $string = '2 + 2 = 12sum21. Cake is 23adjective45.';
$expected = '2 + 2 = 4. Cake is 23adjective45.'; $expected = '2 + 2 = 4. Cake is 23adjective45.';
$result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('format' => '/([\d])([\d])%s\\2\\1/')); $result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('format' => '/([\d])([\d])%s\\2\\1/'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = ':web :web_site'; $string = ':web :web_site';
$expected = 'www http'; $expected = 'www http';
$result = String::insert($string, array('web' => 'www', 'web_site' => 'http')); $result = String::insert($string, array('web' => 'www', 'web_site' => 'http'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '2 + 2 = <sum. Cake is <adjective>.'; $string = '2 + 2 = <sum. Cake is <adjective>.';
$expected = '2 + 2 = <sum. Cake is yummy.'; $expected = '2 + 2 = <sum. Cake is yummy.';
$result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('before' => '<', 'after' => '>')); $result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('before' => '<', 'after' => '>'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '2 + 2 = \:sum. Cake is :adjective.'; $string = '2 + 2 = \:sum. Cake is :adjective.';
$expected = '2 + 2 = :sum. Cake is yummy.'; $expected = '2 + 2 = :sum. Cake is yummy.';
$result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy')); $result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '2 + 2 = !:sum. Cake is :adjective.'; $string = '2 + 2 = !:sum. Cake is :adjective.';
$result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('escape' => '!')); $result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('escape' => '!'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '2 + 2 = \%sum. Cake is %adjective.'; $string = '2 + 2 = \%sum. Cake is %adjective.';
$expected = '2 + 2 = %sum. Cake is yummy.'; $expected = '2 + 2 = %sum. Cake is yummy.';
$result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('before' => '%')); $result = String::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('before' => '%'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = ':a :b \:a :a'; $string = ':a :b \:a :a';
$expected = '1 2 :a 1'; $expected = '1 2 :a 1';
$result = String::insert($string, array('a' => 1, 'b' => 2)); $result = String::insert($string, array('a' => 1, 'b' => 2));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = ':a :b :c'; $string = ':a :b :c';
$expected = '2 3'; $expected = '2 3';
$result = String::insert($string, array('b' => 2, 'c' => 3), array('clean' => true)); $result = String::insert($string, array('b' => 2, 'c' => 3), array('clean' => true));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = ':a :b :c'; $string = ':a :b :c';
$expected = '1 3'; $expected = '1 3';
$result = String::insert($string, array('a' => 1, 'c' => 3), array('clean' => true)); $result = String::insert($string, array('a' => 1, 'c' => 3), array('clean' => true));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = ':a :b :c'; $string = ':a :b :c';
$expected = '2 3'; $expected = '2 3';
$result = String::insert($string, array('b' => 2, 'c' => 3), array('clean' => true)); $result = String::insert($string, array('b' => 2, 'c' => 3), array('clean' => true));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = ':a, :b and :c'; $string = ':a, :b and :c';
$expected = '2 and 3'; $expected = '2 and 3';
$result = String::insert($string, array('b' => 2, 'c' => 3), array('clean' => true)); $result = String::insert($string, array('b' => 2, 'c' => 3), array('clean' => true));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '":a, :b and :c"'; $string = '":a, :b and :c"';
$expected = '"1, 2"'; $expected = '"1, 2"';
$result = String::insert($string, array('a' => 1, 'b' => 2), array('clean' => true)); $result = String::insert($string, array('a' => 1, 'b' => 2), array('clean' => true));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '"${a}, ${b} and ${c}"'; $string = '"${a}, ${b} and ${c}"';
$expected = '"1, 2"'; $expected = '"1, 2"';
$result = String::insert($string, array('a' => 1, 'b' => 2), array('before' => '${', 'after' => '}', 'clean' => true)); $result = String::insert($string, array('a' => 1, 'b' => 2), array('before' => '${', 'after' => '}', 'clean' => true));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '<img src=":src" alt=":alt" class="foo :extra bar"/>'; $string = '<img src=":src" alt=":alt" class="foo :extra bar"/>';
$expected = '<img src="foo" class="foo bar"/>'; $expected = '<img src="foo" class="foo bar"/>';
$result = String::insert($string, array('src' => 'foo'), array('clean' => 'html')); $result = String::insert($string, array('src' => 'foo'), array('clean' => 'html'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '<img src=":src" class=":no :extra"/>'; $string = '<img src=":src" class=":no :extra"/>';
$expected = '<img src="foo"/>'; $expected = '<img src="foo"/>';
$result = String::insert($string, array('src' => 'foo'), array('clean' => 'html')); $result = String::insert($string, array('src' => 'foo'), array('clean' => 'html'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = '<img src=":src" class=":no :extra"/>'; $string = '<img src=":src" class=":no :extra"/>';
$expected = '<img src="foo" class="bar"/>'; $expected = '<img src="foo" class="bar"/>';
$result = String::insert($string, array('src' => 'foo', 'extra' => 'bar'), array('clean' => 'html')); $result = String::insert($string, array('src' => 'foo', 'extra' => 'bar'), array('clean' => 'html'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = String::insert("this is a ? string", "test"); $result = String::insert("this is a ? string", "test");
$expected = "this is a test string"; $expected = "this is a test string";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = String::insert("this is a ? string with a ? ? ?", array('long', 'few?', 'params', 'you know')); $result = String::insert("this is a ? string with a ? ? ?", array('long', 'few?', 'params', 'you know'));
$expected = "this is a long string with a few? params you know"; $expected = "this is a long string with a few? params you know";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = String::insert('update saved_urls set url = :url where id = :id', array('url' => 'http://www.testurl.com/param1:url/param2:id','id' => 1)); $result = String::insert('update saved_urls set url = :url where id = :id', array('url' => 'http://www.testurl.com/param1:url/param2:id','id' => 1));
$expected = "update saved_urls set url = http://www.testurl.com/param1:url/param2:id where id = 1"; $expected = "update saved_urls set url = http://www.testurl.com/param1:url/param2:id where id = 1";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = String::insert('update saved_urls set url = :url where id = :id', array('id' => 1, 'url' => 'http://www.testurl.com/param1:url/param2:id')); $result = String::insert('update saved_urls set url = :url where id = :id', array('id' => 1, 'url' => 'http://www.testurl.com/param1:url/param2:id'));
$expected = "update saved_urls set url = http://www.testurl.com/param1:url/param2:id where id = 1"; $expected = "update saved_urls set url = http://www.testurl.com/param1:url/param2:id where id = 1";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = String::insert(':me cake. :subject :verb fantastic.', array('me' => 'I :verb', 'subject' => 'cake', 'verb' => 'is')); $result = String::insert(':me cake. :subject :verb fantastic.', array('me' => 'I :verb', 'subject' => 'cake', 'verb' => 'is'));
$expected = "I :verb cake. cake is fantastic."; $expected = "I :verb cake. cake is fantastic.";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = String::insert(':I.am: :not.yet: passing.', array('I.am' => 'We are'), array('before' => ':', 'after' => ':', 'clean' => array('replacement' => ' of course', 'method' => 'text'))); $result = String::insert(':I.am: :not.yet: passing.', array('I.am' => 'We are'), array('before' => ':', 'after' => ':', 'clean' => array('replacement' => ' of course', 'method' => 'text')));
$expected = "We are of course passing."; $expected = "We are of course passing.";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = String::insert( $result = String::insert(
':I.am: :not.yet: passing.', ':I.am: :not.yet: passing.',
@ -193,31 +193,31 @@ class StringTest extends CakeTestCase {
array('before' => ':', 'after' => ':', 'clean' => true) array('before' => ':', 'after' => ':', 'clean' => true)
); );
$expected = "We are passing."; $expected = "We are passing.";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = String::insert('?-pended result', array('Pre')); $result = String::insert('?-pended result', array('Pre'));
$expected = "Pre-pended result"; $expected = "Pre-pended result";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = 'switching :timeout / :timeout_count'; $string = 'switching :timeout / :timeout_count';
$expected = 'switching 5 / 10'; $expected = 'switching 5 / 10';
$result = String::insert($string, array('timeout' => 5, 'timeout_count' => 10)); $result = String::insert($string, array('timeout' => 5, 'timeout_count' => 10));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = 'switching :timeout / :timeout_count'; $string = 'switching :timeout / :timeout_count';
$expected = 'switching 5 / 10'; $expected = 'switching 5 / 10';
$result = String::insert($string, array('timeout_count' => 10, 'timeout' => 5)); $result = String::insert($string, array('timeout_count' => 10, 'timeout' => 5));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = 'switching :timeout_count by :timeout'; $string = 'switching :timeout_count by :timeout';
$expected = 'switching 10 by 5'; $expected = 'switching 10 by 5';
$result = String::insert($string, array('timeout' => 5, 'timeout_count' => 10)); $result = String::insert($string, array('timeout' => 5, 'timeout_count' => 10));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$string = 'switching :timeout_count by :timeout'; $string = 'switching :timeout_count by :timeout';
$expected = 'switching 10 by 5'; $expected = 'switching 10 by 5';
$result = String::insert($string, array('timeout_count' => 10, 'timeout' => 5)); $result = String::insert($string, array('timeout_count' => 10, 'timeout' => 5));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -280,15 +280,15 @@ class StringTest extends CakeTestCase {
function testTokenize() { function testTokenize() {
$result = String::tokenize('A,(short,boring test)'); $result = String::tokenize('A,(short,boring test)');
$expected = array('A', '(short,boring test)'); $expected = array('A', '(short,boring test)');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = String::tokenize('A,(short,more interesting( test)'); $result = String::tokenize('A,(short,more interesting( test)');
$expected = array('A', '(short,more interesting( test)'); $expected = array('A', '(short,more interesting( test)');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = String::tokenize('A,(short,very interesting( test))'); $result = String::tokenize('A,(short,very interesting( test))');
$expected = array('A', '(short,very interesting( test))'); $expected = array('A', '(short,very interesting( test))');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = String::tokenize('"single tag"', ' ', '"', '"'); $result = String::tokenize('"single tag"', ' ', '"', '"');
$expected = array('"single tag"'); $expected = array('"single tag"');
@ -298,7 +298,7 @@ class StringTest extends CakeTestCase {
$expected = array('tagA', '"single tag"', 'tagB'); $expected = array('tagA', '"single tag"', 'tagB');
$this->assertEqual($expected, $result); $this->assertEqual($expected, $result);
} }
function testReplaceWithQuestionMarkInString() { function testReplaceWithQuestionMarkInString() {
$string = ':a, :b and :c?'; $string = ':a, :b and :c?';
$expected = '2 and 3?'; $expected = '2 and 3?';
@ -326,7 +326,7 @@ TEXT;
This is the song th This is the song th
at never ends. This at never ends. This
is the song that n is the song that n
ever ends. This is ever ends. This is
the song that never the song that never
ends. ends.
TEXT; TEXT;

File diff suppressed because it is too large Load diff

View file

@ -174,11 +174,11 @@ class HtmlHelperTest extends CakeTestCase {
function testDocType() { function testDocType() {
$result = $this->Html->docType(); $result = $this->Html->docType();
$expected = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'; $expected = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Html->docType('html4-strict'); $result = $this->Html->docType('html4-strict');
$expected = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'; $expected = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertNull($this->Html->docType('non-existing-doctype')); $this->assertNull($this->Html->docType('non-existing-doctype'));
} }
@ -194,11 +194,11 @@ class HtmlHelperTest extends CakeTestCase {
$result = $this->Html->link('/home'); $result = $this->Html->link('/home');
$expected = array('a' => array('href' => '/home'), 'preg:/\/home/', '/a'); $expected = array('a' => array('href' => '/home'), 'preg:/\/home/', '/a');
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->link('Posts', array('controller' => 'posts', 'action' => 'index', 'full_base' => true)); $result = $this->Html->link('Posts', array('controller' => 'posts', 'action' => 'index', 'full_base' => true));
$expected = array('a' => array('href' => FULL_BASE_URL . '/posts'), 'Posts', '/a'); $expected = array('a' => array('href' => FULL_BASE_URL . '/posts'), 'Posts', '/a');
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->link('Home', '/home', array('confirm' => 'Are you sure you want to do this?')); $result = $this->Html->link('Home', '/home', array('confirm' => 'Are you sure you want to do this?'));
$expected = array( $expected = array(
@ -206,7 +206,7 @@ class HtmlHelperTest extends CakeTestCase {
'Home', 'Home',
'/a' '/a'
); );
$this->assertTags($result, $expected, true); $this->assertTags($expected, $result, true);
$result = $this->Html->link('Home', '/home', array('default' => false)); $result = $this->Html->link('Home', '/home', array('default' => false));
$expected = array( $expected = array(
@ -214,7 +214,7 @@ class HtmlHelperTest extends CakeTestCase {
'Home', 'Home',
'/a' '/a'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->link('Next >', '#'); $result = $this->Html->link('Next >', '#');
$expected = array( $expected = array(
@ -222,7 +222,7 @@ class HtmlHelperTest extends CakeTestCase {
'Next &gt;', 'Next &gt;',
'/a' '/a'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->link('Next >', '#', array('escape' => true)); $result = $this->Html->link('Next >', '#', array('escape' => true));
$expected = array( $expected = array(
@ -230,7 +230,7 @@ class HtmlHelperTest extends CakeTestCase {
'Next &gt;', 'Next &gt;',
'/a' '/a'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->link('Next >', '#', array('escape' => 'utf-8')); $result = $this->Html->link('Next >', '#', array('escape' => 'utf-8'));
$expected = array( $expected = array(
@ -238,7 +238,7 @@ class HtmlHelperTest extends CakeTestCase {
'Next &gt;', 'Next &gt;',
'/a' '/a'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->link('Next >', '#', array('escape' => false)); $result = $this->Html->link('Next >', '#', array('escape' => false));
$expected = array( $expected = array(
@ -246,7 +246,7 @@ class HtmlHelperTest extends CakeTestCase {
'Next >', 'Next >',
'/a' '/a'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->link('Next >', '#', array( $result = $this->Html->link('Next >', '#', array(
'title' => 'to escape &#8230; or not escape?', 'title' => 'to escape &#8230; or not escape?',
@ -257,7 +257,7 @@ class HtmlHelperTest extends CakeTestCase {
'Next >', 'Next >',
'/a' '/a'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->link('Next >', '#', array( $result = $this->Html->link('Next >', '#', array(
'title' => 'to escape &#8230; or not escape?', 'title' => 'to escape &#8230; or not escape?',
@ -268,7 +268,7 @@ class HtmlHelperTest extends CakeTestCase {
'Next &gt;', 'Next &gt;',
'/a' '/a'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->link('Original size', array( $result = $this->Html->link('Original size', array(
'controller' => 'images', 'action' => 'view', 3, '?' => array('height' => 100, 'width' => 200) 'controller' => 'images', 'action' => 'view', 3, '?' => array('height' => 100, 'width' => 200)
@ -278,7 +278,7 @@ class HtmlHelperTest extends CakeTestCase {
'Original size', 'Original size',
'/a' '/a'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
Configure::write('Asset.timestamp', false); Configure::write('Asset.timestamp', false);
@ -288,7 +288,7 @@ class HtmlHelperTest extends CakeTestCase {
'img' => array('src' => 'img/test.gif', 'alt' => ''), 'img' => array('src' => 'img/test.gif', 'alt' => ''),
'/a' '/a'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->image('test.gif', array('url' => '#')); $result = $this->Html->image('test.gif', array('url' => '#'));
$expected = array( $expected = array(
@ -296,7 +296,7 @@ class HtmlHelperTest extends CakeTestCase {
'img' => array('src' => 'img/test.gif', 'alt' => ''), 'img' => array('src' => 'img/test.gif', 'alt' => ''),
'/a' '/a'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
Configure::write('Asset.timestamp', 'force'); Configure::write('Asset.timestamp', 'force');
@ -306,7 +306,7 @@ class HtmlHelperTest extends CakeTestCase {
'img' => array('src' => 'preg:/img\/..\/favicon\.ico\?\d*/', 'alt' => ''), 'img' => array('src' => 'preg:/img\/..\/favicon\.ico\?\d*/', 'alt' => ''),
'/a' '/a'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->image('../favicon.ico', array('url' => '#')); $result = $this->Html->image('../favicon.ico', array('url' => '#'));
$expected = array( $expected = array(
@ -314,7 +314,7 @@ class HtmlHelperTest extends CakeTestCase {
'img' => array('src' => 'preg:/img\/..\/favicon\.ico\?\d*/', 'alt' => ''), 'img' => array('src' => 'preg:/img\/..\/favicon\.ico\?\d*/', 'alt' => ''),
'/a' '/a'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
} }
/** /**
@ -362,7 +362,7 @@ class HtmlHelperTest extends CakeTestCase {
$expected = array( $expected = array(
'img' => array('src' => 'preg:/\/testing\/longer\/img\/cake\.icon\.png\?[0-9]+/', 'alt' => '') 'img' => array('src' => 'preg:/\/testing\/longer\/img\/cake\.icon\.png\?[0-9]+/', 'alt' => '')
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
} }
/** /**
@ -426,14 +426,14 @@ class HtmlHelperTest extends CakeTestCase {
$expected = array( $expected = array(
'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'preg:/.*theme\/test_theme\/css\/webroot_test\.css/') 'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'preg:/.*theme\/test_theme\/css\/webroot_test\.css/')
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$this->Html->theme = 'test_theme'; $this->Html->theme = 'test_theme';
$result = $this->Html->css('theme_webroot'); $result = $this->Html->css('theme_webroot');
$expected = array( $expected = array(
'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'preg:/.*theme\/test_theme\/css\/theme_webroot\.css/') 'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'preg:/.*theme\/test_theme\/css\/theme_webroot\.css/')
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
Configure::write('App.www_root', $webRoot); Configure::write('App.www_root', $webRoot);
} }
@ -468,27 +468,27 @@ class HtmlHelperTest extends CakeTestCase {
$expected = array( $expected = array(
'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'preg:/.*css\/screen\.css/') 'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'preg:/.*css\/screen\.css/')
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->css('screen.css'); $result = $this->Html->css('screen.css');
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->css('my.css.library'); $result = $this->Html->css('my.css.library');
$expected['link']['href'] = 'preg:/.*css\/my\.css\.library\.css/'; $expected['link']['href'] = 'preg:/.*css\/my\.css\.library\.css/';
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->css('screen.css?1234'); $result = $this->Html->css('screen.css?1234');
$expected['link']['href'] = 'preg:/.*css\/screen\.css\?1234/'; $expected['link']['href'] = 'preg:/.*css\/screen\.css\?1234/';
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->css('http://whatever.com/screen.css?1234'); $result = $this->Html->css('http://whatever.com/screen.css?1234');
$expected['link']['href'] = 'preg:/http:\/\/.*\/screen\.css\?1234/'; $expected['link']['href'] = 'preg:/http:\/\/.*\/screen\.css\?1234/';
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
Configure::write('Asset.filter.css', 'css.php'); Configure::write('Asset.filter.css', 'css.php');
$result = $this->Html->css('cake.generic'); $result = $this->Html->css('cake.generic');
$expected['link']['href'] = 'preg:/.*ccss\/cake\.generic\.css/'; $expected['link']['href'] = 'preg:/.*ccss\/cake\.generic\.css/';
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
Configure::write('Asset.filter.css', false); Configure::write('Asset.filter.css', false);
@ -528,29 +528,29 @@ class HtmlHelperTest extends CakeTestCase {
$result = $this->Html->css('cake.generic'); $result = $this->Html->css('cake.generic');
$expected['link']['href'] = 'preg:/.*css\/cake\.generic\.css\?[0-9]+/'; $expected['link']['href'] = 'preg:/.*css\/cake\.generic\.css\?[0-9]+/';
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
Configure::write('debug', 0); Configure::write('debug', 0);
$result = $this->Html->css('cake.generic'); $result = $this->Html->css('cake.generic');
$expected['link']['href'] = 'preg:/.*css\/cake\.generic\.css/'; $expected['link']['href'] = 'preg:/.*css\/cake\.generic\.css/';
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
Configure::write('Asset.timestamp', 'force'); Configure::write('Asset.timestamp', 'force');
$result = $this->Html->css('cake.generic'); $result = $this->Html->css('cake.generic');
$expected['link']['href'] = 'preg:/.*css\/cake\.generic\.css\?[0-9]+/'; $expected['link']['href'] = 'preg:/.*css\/cake\.generic\.css\?[0-9]+/';
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$this->Html->request->webroot = '/testing/'; $this->Html->request->webroot = '/testing/';
$result = $this->Html->css('cake.generic'); $result = $this->Html->css('cake.generic');
$expected['link']['href'] = 'preg:/\/testing\/css\/cake\.generic\.css\?[0-9]+/'; $expected['link']['href'] = 'preg:/\/testing\/css\/cake\.generic\.css\?[0-9]+/';
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$this->Html->request->webroot = '/testing/longer/'; $this->Html->request->webroot = '/testing/longer/';
$result = $this->Html->css('cake.generic'); $result = $this->Html->css('cake.generic');
$expected['link']['href'] = 'preg:/\/testing\/longer\/css\/cake\.generic\.css\?[0-9]+/'; $expected['link']['href'] = 'preg:/\/testing\/longer\/css\/cake\.generic\.css\?[0-9]+/';
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
} }
/** /**
@ -591,7 +591,7 @@ class HtmlHelperTest extends CakeTestCase {
$expected = array( $expected = array(
'script' => array('type' => 'text/javascript', 'src' => 'js/foo.js') 'script' => array('type' => 'text/javascript', 'src' => 'js/foo.js')
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->script(array('foobar', 'bar')); $result = $this->Html->script(array('foobar', 'bar'));
$expected = array( $expected = array(
@ -600,31 +600,31 @@ class HtmlHelperTest extends CakeTestCase {
array('script' => array('type' => 'text/javascript', 'src' => 'js/bar.js')), array('script' => array('type' => 'text/javascript', 'src' => 'js/bar.js')),
'/script', '/script',
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->script('jquery-1.3'); $result = $this->Html->script('jquery-1.3');
$expected = array( $expected = array(
'script' => array('type' => 'text/javascript', 'src' => 'js/jquery-1.3.js') 'script' => array('type' => 'text/javascript', 'src' => 'js/jquery-1.3.js')
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->script('test.json'); $result = $this->Html->script('test.json');
$expected = array( $expected = array(
'script' => array('type' => 'text/javascript', 'src' => 'js/test.json.js') 'script' => array('type' => 'text/javascript', 'src' => 'js/test.json.js')
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->script('/plugin/js/jquery-1.3.2.js?someparam=foo'); $result = $this->Html->script('/plugin/js/jquery-1.3.2.js?someparam=foo');
$expected = array( $expected = array(
'script' => array('type' => 'text/javascript', 'src' => '/plugin/js/jquery-1.3.2.js?someparam=foo') 'script' => array('type' => 'text/javascript', 'src' => '/plugin/js/jquery-1.3.2.js?someparam=foo')
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->script('test.json.js?foo=bar'); $result = $this->Html->script('test.json.js?foo=bar');
$expected = array( $expected = array(
'script' => array('type' => 'text/javascript', 'src' => 'js/test.json.js?foo=bar') 'script' => array('type' => 'text/javascript', 'src' => 'js/test.json.js?foo=bar')
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->script('foo'); $result = $this->Html->script('foo');
$this->assertNull($result, 'Script returned upon duplicate inclusion %s'); $this->assertNull($result, 'Script returned upon duplicate inclusion %s');
@ -639,7 +639,7 @@ class HtmlHelperTest extends CakeTestCase {
$expected = array( $expected = array(
'script' => array('type' => 'text/javascript', 'src' => 'js/jquery-1.3.2.js', 'defer' => 'defer', 'encoding' => 'utf-8') 'script' => array('type' => 'text/javascript', 'src' => 'js/jquery-1.3.2.js', 'defer' => 'defer', 'encoding' => 'utf-8')
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$this->View->expects($this->any())->method('addScript') $this->View->expects($this->any())->method('addScript')
->with($this->matchesRegularExpression('/script_in_head.js/')); ->with($this->matchesRegularExpression('/script_in_head.js/'));
@ -671,7 +671,7 @@ class HtmlHelperTest extends CakeTestCase {
$expected = array( $expected = array(
'script' => array('src' => '/theme/test_theme/js/__test_js.js', 'type' => 'text/javascript') 'script' => array('src' => '/theme/test_theme/js/__test_js.js', 'type' => 'text/javascript')
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$folder = new Folder(WWW_ROOT . 'theme' . DS . 'test_theme'); $folder = new Folder(WWW_ROOT . 'theme' . DS . 'test_theme');
$folder->delete(); $folder->delete();
@ -692,7 +692,7 @@ class HtmlHelperTest extends CakeTestCase {
$this->cDataEnd, $this->cDataEnd,
'/script', '/script',
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->scriptBlock('window.foo = 2;', array('safe' => false)); $result = $this->Html->scriptBlock('window.foo = 2;', array('safe' => false));
$expected = array( $expected = array(
@ -700,7 +700,7 @@ class HtmlHelperTest extends CakeTestCase {
'window.foo = 2;', 'window.foo = 2;',
'/script', '/script',
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->scriptBlock('window.foo = 2;', array('safe' => true)); $result = $this->Html->scriptBlock('window.foo = 2;', array('safe' => true));
$expected = array( $expected = array(
@ -710,7 +710,7 @@ class HtmlHelperTest extends CakeTestCase {
$this->cDataEnd, $this->cDataEnd,
'/script', '/script',
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$this->View->expects($this->any())->method('addScript') $this->View->expects($this->any())->method('addScript')
@ -725,7 +725,7 @@ class HtmlHelperTest extends CakeTestCase {
'window.foo = 2;', 'window.foo = 2;',
'/script', '/script',
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
} }
/** /**
@ -746,7 +746,7 @@ class HtmlHelperTest extends CakeTestCase {
$this->cDataEnd, $this->cDataEnd,
'/script' '/script'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->scriptStart(array('safe' => false)); $result = $this->Html->scriptStart(array('safe' => false));
@ -759,7 +759,7 @@ class HtmlHelperTest extends CakeTestCase {
'this is some javascript', 'this is some javascript',
'/script' '/script'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$this->View->expects($this->once())->method('addScript'); $this->View->expects($this->once())->method('addScript');
$result = $this->Html->scriptStart(array('safe' => false, 'inline' => false)); $result = $this->Html->scriptStart(array('safe' => false, 'inline' => false));
@ -814,7 +814,7 @@ class HtmlHelperTest extends CakeTestCase {
'Third', 'Third',
'/a', '/a',
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->getCrumbs(' &gt; '); $result = $this->Html->getCrumbs(' &gt; ');
$expected = array( $expected = array(
@ -830,7 +830,7 @@ class HtmlHelperTest extends CakeTestCase {
'Third', 'Third',
'/a', '/a',
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$this->assertPattern('/^<a[^<>]+>First<\/a> &gt; <a[^<>]+>Second<\/a> &gt; <a[^<>]+>Third<\/a>$/', $result); $this->assertPattern('/^<a[^<>]+>First<\/a> &gt; <a[^<>]+>Second<\/a> &gt; <a[^<>]+>Third<\/a>$/', $result);
$this->assertPattern('/<a\s+href=["\']+\#first["\']+[^<>]*>First<\/a>/', $result); $this->assertPattern('/<a\s+href=["\']+\#first["\']+[^<>]*>First<\/a>/', $result);
@ -856,7 +856,7 @@ class HtmlHelperTest extends CakeTestCase {
'&raquo;', '&raquo;',
'Fourth' 'Fourth'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
} }
/** /**
@ -914,7 +914,7 @@ class HtmlHelperTest extends CakeTestCase {
'/li', '/li',
'/ul' '/ul'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->nestedList($list, null); $result = $this->Html->nestedList($list, null);
$expected = array( $expected = array(
@ -944,7 +944,7 @@ class HtmlHelperTest extends CakeTestCase {
'/li', '/li',
'/ul' '/ul'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->nestedList($list, array(), array(), 'ol'); $result = $this->Html->nestedList($list, array(), array(), 'ol');
$expected = array( $expected = array(
@ -974,7 +974,7 @@ class HtmlHelperTest extends CakeTestCase {
'/li', '/li',
'/ol' '/ol'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->nestedList($list, 'ol'); $result = $this->Html->nestedList($list, 'ol');
$expected = array( $expected = array(
@ -1004,7 +1004,7 @@ class HtmlHelperTest extends CakeTestCase {
'/li', '/li',
'/ol' '/ol'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->nestedList($list, array('class'=>'list')); $result = $this->Html->nestedList($list, array('class'=>'list'));
$expected = array( $expected = array(
@ -1034,7 +1034,7 @@ class HtmlHelperTest extends CakeTestCase {
'/li', '/li',
'/ul' '/ul'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->nestedList($list, array(), array('class' => 'item')); $result = $this->Html->nestedList($list, array(), array('class' => 'item'));
$expected = array( $expected = array(
@ -1064,7 +1064,7 @@ class HtmlHelperTest extends CakeTestCase {
'/li', '/li',
'/ul' '/ul'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->nestedList($list, array(), array('even' => 'even', 'odd' => 'odd')); $result = $this->Html->nestedList($list, array(), array('even' => 'even', 'odd' => 'odd'));
$expected = array( $expected = array(
@ -1094,7 +1094,7 @@ class HtmlHelperTest extends CakeTestCase {
'/li', '/li',
'/ul' '/ul'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->nestedList($list, array('class'=>'list'), array('class' => 'item')); $result = $this->Html->nestedList($list, array('class'=>'list'), array('class' => 'item'));
$expected = array( $expected = array(
@ -1124,7 +1124,7 @@ class HtmlHelperTest extends CakeTestCase {
'/li', '/li',
'/ul' '/ul'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
} }
/** /**
@ -1160,14 +1160,14 @@ class HtmlHelperTest extends CakeTestCase {
'link' => array('href' => 'preg:/.*favicon\.ico/', 'rel' => 'icon'), 'link' => array('href' => 'preg:/.*favicon\.ico/', 'rel' => 'icon'),
array('link' => array('href' => 'preg:/.*favicon\.ico/', 'rel' => 'shortcut icon')) array('link' => array('href' => 'preg:/.*favicon\.ico/', 'rel' => 'shortcut icon'))
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->meta('icon', 'favicon.ico'); $result = $this->Html->meta('icon', 'favicon.ico');
$expected = array( $expected = array(
'link' => array('href' => 'preg:/.*favicon\.ico/', 'type' => 'image/x-icon', 'rel' => 'icon'), 'link' => array('href' => 'preg:/.*favicon\.ico/', 'type' => 'image/x-icon', 'rel' => 'icon'),
array('link' => array('href' => 'preg:/.*favicon\.ico/', 'type' => 'image/x-icon', 'rel' => 'shortcut icon')) array('link' => array('href' => 'preg:/.*favicon\.ico/', 'type' => 'image/x-icon', 'rel' => 'shortcut icon'))
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Html->meta('keywords', 'these, are, some, meta, keywords'); $result = $this->Html->meta('keywords', 'these, are, some, meta, keywords');
$this->assertTags($result, array('meta' => array('name' => 'keywords', 'content' => 'these, are, some, meta, keywords'))); $this->assertTags($result, array('meta' => array('name' => 'keywords', 'content' => 'these, are, some, meta, keywords')));
@ -1197,7 +1197,7 @@ class HtmlHelperTest extends CakeTestCase {
function testTableHeaders() { function testTableHeaders() {
$result = $this->Html->tableHeaders(array('ID', 'Name', 'Date')); $result = $this->Html->tableHeaders(array('ID', 'Name', 'Date'));
$expected = array('<tr', '<th', 'ID', '/th', '<th', 'Name', '/th', '<th', 'Date', '/th', '/tr'); $expected = array('<tr', '<th', 'ID', '/th', '<th', 'Name', '/th', '<th', 'Date', '/th', '/tr');
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
} }
/** /**
@ -1220,7 +1220,7 @@ class HtmlHelperTest extends CakeTestCase {
array('td' => array('width' => 'preg:/100px/')), 'td content 3', '/td', array('td' => array('width' => 'preg:/100px/')), 'td content 3', '/td',
'/tr' '/tr'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$tr = array('td content 1', 'td content 2', 'td content 3'); $tr = array('td content 1', 'td content 2', 'td content 3');
$result = $this->Html->tableCells($tr, null, null, true); $result = $this->Html->tableCells($tr, null, null, true);
@ -1231,7 +1231,7 @@ class HtmlHelperTest extends CakeTestCase {
array('td' => array('class' => 'column-3')), 'td content 3', '/td', array('td' => array('class' => 'column-3')), 'td content 3', '/td',
'/tr' '/tr'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$tr = array('td content 1', 'td content 2', 'td content 3'); $tr = array('td content 1', 'td content 2', 'td content 3');
$result = $this->Html->tableCells($tr, true); $result = $this->Html->tableCells($tr, true);
@ -1242,7 +1242,7 @@ class HtmlHelperTest extends CakeTestCase {
array('td' => array('class' => 'column-3')), 'td content 3', '/td', array('td' => array('class' => 'column-3')), 'td content 3', '/td',
'/tr' '/tr'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$tr = array( $tr = array(
array('td content 1', 'td content 2', 'td content 3'), array('td content 1', 'td content 2', 'td content 3'),
@ -1251,7 +1251,7 @@ class HtmlHelperTest extends CakeTestCase {
); );
$result = $this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even')); $result = $this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even'));
$expected = "<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>"; $expected = "<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$tr = array( $tr = array(
array('td content 1', 'td content 2', 'td content 3'), array('td content 1', 'td content 2', 'td content 3'),
@ -1261,7 +1261,7 @@ class HtmlHelperTest extends CakeTestCase {
); );
$result = $this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even')); $result = $this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even'));
$expected = "<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>"; $expected = "<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$tr = array( $tr = array(
array('td content 1', 'td content 2', 'td content 3'), array('td content 1', 'td content 2', 'td content 3'),
@ -1271,7 +1271,7 @@ class HtmlHelperTest extends CakeTestCase {
$this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even')); $this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even'));
$result = $this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even'), false, false); $result = $this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even'), false, false);
$expected = "<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>"; $expected = "<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -1392,7 +1392,7 @@ class HtmlHelperTest extends CakeTestCase {
'formend' => 'finish form' 'formend' => 'finish form'
) )
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$tags = $this->Html->getAttribute('_tags'); $tags = $this->Html->getAttribute('_tags');
$this->assertEqual($tags['form'], 'start form'); $this->assertEqual($tags['form'], 'start form');
$this->assertEqual($tags['formend'], 'finish form'); $this->assertEqual($tags['formend'], 'finish form');
@ -1402,7 +1402,7 @@ class HtmlHelperTest extends CakeTestCase {
$expected = array( $expected = array(
'minimizedAttributeFormat' => 'format' 'minimizedAttributeFormat' => 'format'
); );
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertEqual($this->Html->getAttribute('_minimizedAttributeFormat'), 'format'); $this->assertEqual($this->Html->getAttribute('_minimizedAttributeFormat'), 'format');
} }

View file

@ -79,15 +79,15 @@ class JqueryEngineHelperTest extends CakeTestCase {
$this->Jquery->get('#myLink'); $this->Jquery->get('#myLink');
$result = $this->Jquery->event('click', 'doClick', array('wrap' => false)); $result = $this->Jquery->event('click', 'doClick', array('wrap' => false));
$expected = '$("#myLink").bind("click", doClick);'; $expected = '$("#myLink").bind("click", doClick);';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Jquery->event('click', '$(this).show();', array('stop' => false)); $result = $this->Jquery->event('click', '$(this).show();', array('stop' => false));
$expected = '$("#myLink").bind("click", function (event) {$(this).show();});'; $expected = '$("#myLink").bind("click", function (event) {$(this).show();});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Jquery->event('click', '$(this).hide();'); $result = $this->Jquery->event('click', '$(this).hide();');
$expected = '$("#myLink").bind("click", function (event) {$(this).hide();'."\n".'return false;});'; $expected = '$("#myLink").bind("click", function (event) {$(this).hide();'."\n".'return false;});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -98,7 +98,7 @@ class JqueryEngineHelperTest extends CakeTestCase {
function testDomReady() { function testDomReady() {
$result = $this->Jquery->domReady('foo.name = "bar";'); $result = $this->Jquery->domReady('foo.name = "bar";');
$expected = '$(document).ready(function () {foo.name = "bar";});'; $expected = '$(document).ready(function () {foo.name = "bar";});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -110,7 +110,7 @@ class JqueryEngineHelperTest extends CakeTestCase {
$this->Jquery->get('#foo'); $this->Jquery->get('#foo');
$result = $this->Jquery->each('$(this).hide();'); $result = $this->Jquery->each('$(this).hide();');
$expected = '$("#foo").each(function () {$(this).hide();});'; $expected = '$("#foo").each(function () {$(this).hide();});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -122,39 +122,39 @@ class JqueryEngineHelperTest extends CakeTestCase {
$this->Jquery->get('#foo'); $this->Jquery->get('#foo');
$result = $this->Jquery->effect('show'); $result = $this->Jquery->effect('show');
$expected = '$("#foo").show();'; $expected = '$("#foo").show();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Jquery->effect('hide'); $result = $this->Jquery->effect('hide');
$expected = '$("#foo").hide();'; $expected = '$("#foo").hide();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Jquery->effect('hide', array('speed' => 'fast')); $result = $this->Jquery->effect('hide', array('speed' => 'fast'));
$expected = '$("#foo").hide("fast");'; $expected = '$("#foo").hide("fast");';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Jquery->effect('fadeIn'); $result = $this->Jquery->effect('fadeIn');
$expected = '$("#foo").fadeIn();'; $expected = '$("#foo").fadeIn();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Jquery->effect('fadeOut'); $result = $this->Jquery->effect('fadeOut');
$expected = '$("#foo").fadeOut();'; $expected = '$("#foo").fadeOut();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Jquery->effect('slideIn'); $result = $this->Jquery->effect('slideIn');
$expected = '$("#foo").slideDown();'; $expected = '$("#foo").slideDown();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Jquery->effect('slideOut'); $result = $this->Jquery->effect('slideOut');
$expected = '$("#foo").slideUp();'; $expected = '$("#foo").slideUp();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Jquery->effect('slideDown'); $result = $this->Jquery->effect('slideDown');
$expected = '$("#foo").slideDown();'; $expected = '$("#foo").slideDown();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Jquery->effect('slideUp'); $result = $this->Jquery->effect('slideUp');
$expected = '$("#foo").slideUp();'; $expected = '$("#foo").slideUp();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -165,13 +165,13 @@ class JqueryEngineHelperTest extends CakeTestCase {
function testRequest() { function testRequest() {
$result = $this->Jquery->request(array('controller' => 'posts', 'action' => 'view', 1)); $result = $this->Jquery->request(array('controller' => 'posts', 'action' => 'view', 1));
$expected = '$.ajax({url:"\\/posts\\/view\\/1"});'; $expected = '$.ajax({url:"\\/posts\\/view\\/1"});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Jquery->request(array('controller' => 'posts', 'action' => 'view', 1), array( $result = $this->Jquery->request(array('controller' => 'posts', 'action' => 'view', 1), array(
'update' => '#content' 'update' => '#content'
)); ));
$expected = '$.ajax({dataType:"html", success:function (data, textStatus) {$("#content").html(data);}, url:"\/posts\/view\/1"});'; $expected = '$.ajax({dataType:"html", success:function (data, textStatus) {$("#content").html(data);}, url:"\/posts\/view\/1"});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Jquery->request('/people/edit/1', array( $result = $this->Jquery->request('/people/edit/1', array(
'method' => 'post', 'method' => 'post',
@ -184,7 +184,7 @@ class JqueryEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = '$.ajax({beforeSend:doBefore, complete:doComplete, data:"name=jim&height=185cm", dataType:"json", error:handleError, success:doSuccess, type:"post", url:"\\/people\\/edit\\/1"});'; $expected = '$.ajax({beforeSend:doBefore, complete:doComplete, data:"name=jim&height=185cm", dataType:"json", error:handleError, success:doSuccess, type:"post", url:"\\/people\\/edit\\/1"});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Jquery->request('/people/edit/1', array( $result = $this->Jquery->request('/people/edit/1', array(
'update' => '#updated', 'update' => '#updated',
@ -193,7 +193,7 @@ class JqueryEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = '$.ajax({dataType:"html", success:function (data, textStatus) {doFoo$("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});'; $expected = '$.ajax({dataType:"html", success:function (data, textStatus) {doFoo$("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Jquery->request('/people/edit/1', array( $result = $this->Jquery->request('/people/edit/1', array(
'update' => '#updated', 'update' => '#updated',
@ -204,7 +204,7 @@ class JqueryEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = '$.ajax({data:$("#someId").serialize(), dataType:"html", success:function (data, textStatus) {doFoo$("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});'; $expected = '$.ajax({data:$("#someId").serialize(), dataType:"html", success:function (data, textStatus) {doFoo$("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Jquery->request('/people/edit/1', array( $result = $this->Jquery->request('/people/edit/1', array(
'success' => 'doFoo', 'success' => 'doFoo',
@ -214,7 +214,7 @@ class JqueryEngineHelperTest extends CakeTestCase {
'data' => '$("#someId").serialize()', 'data' => '$("#someId").serialize()',
)); ));
$expected = '$.ajax({beforeSend:function (XMLHttpRequest) {doBefore}, data:$("#someId").serialize(), success:function (data, textStatus) {doFoo}, type:"post", url:"\\/people\\/edit\\/1"});'; $expected = '$.ajax({beforeSend:function (XMLHttpRequest) {doBefore}, data:$("#someId").serialize(), success:function (data, textStatus) {doFoo}, type:"post", url:"\\/people\\/edit\\/1"});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -234,7 +234,7 @@ class JqueryEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = '$j.ajax({data:$j("#someId").serialize(), dataType:"html", success:function (data, textStatus) {doFoo$j("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});'; $expected = '$j.ajax({data:$j("#someId").serialize(), dataType:"html", success:function (data, textStatus) {doFoo$j("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -253,7 +253,7 @@ class JqueryEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = '$("#myList").sortable({containment:"parent", distance:5, sort:onSort, start:onStart, stop:onStop});'; $expected = '$("#myList").sortable({containment:"parent", distance:5, sort:onSort, start:onStart, stop:onStop});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Jquery->sortable(array( $result = $this->Jquery->sortable(array(
'distance' => 5, 'distance' => 5,
@ -263,7 +263,7 @@ class JqueryEngineHelperTest extends CakeTestCase {
'sort' => 'onSort', 'sort' => 'onSort',
)); ));
$expected = '$("#myList").sortable({containment:"parent", distance:5, sort:function (event, ui) {onSort}, start:function (event, ui) {onStart}, stop:function (event, ui) {onStop}});'; $expected = '$("#myList").sortable({containment:"parent", distance:5, sort:function (event, ui) {onSort}, start:function (event, ui) {onStart}, stop:function (event, ui) {onStop}});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -282,7 +282,7 @@ class JqueryEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = '$("#element").draggable({containment:"#content", drag:onDrag, grid:[10,10], start:onStart, stop:onStop});'; $expected = '$("#element").draggable({containment:"#content", drag:onDrag, grid:[10,10], start:onStart, stop:onStop});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Jquery->drag(array( $result = $this->Jquery->drag(array(
'container' => '#content', 'container' => '#content',
@ -292,7 +292,7 @@ class JqueryEngineHelperTest extends CakeTestCase {
'snapGrid' => array(10, 10), 'snapGrid' => array(10, 10),
)); ));
$expected = '$("#element").draggable({containment:"#content", drag:function (event, ui) {onDrag}, grid:[10,10], start:function (event, ui) {onStart}, stop:function (event, ui) {onStop}});'; $expected = '$("#element").draggable({containment:"#content", drag:function (event, ui) {onDrag}, grid:[10,10], start:function (event, ui) {onStart}, stop:function (event, ui) {onStop}});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -310,7 +310,7 @@ class JqueryEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = '$("#element").droppable({accept:".items", drop:onDrop, out:onExit, over:onHover});'; $expected = '$("#element").droppable({accept:".items", drop:onDrop, out:onExit, over:onHover});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Jquery->drop(array( $result = $this->Jquery->drop(array(
'accept' => '.items', 'accept' => '.items',
@ -319,7 +319,7 @@ class JqueryEngineHelperTest extends CakeTestCase {
'drop' => 'onDrop', 'drop' => 'onDrop',
)); ));
$expected = '$("#element").droppable({accept:".items", drop:function (event, ui) {onDrop}, out:function (event, ui) {onExit}, over:function (event, ui) {onHover}});'; $expected = '$("#element").droppable({accept:".items", drop:function (event, ui) {onDrop}, out:function (event, ui) {onExit}, over:function (event, ui) {onHover}});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -339,7 +339,7 @@ class JqueryEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = '$("#element").slider({change:onChange, max:10, min:0, orientation:"vertical", stop:onComplete, value:2});'; $expected = '$("#element").slider({change:onChange, max:10, min:0, orientation:"vertical", stop:onComplete, value:2});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Jquery->slider(array( $result = $this->Jquery->slider(array(
'complete' => 'onComplete', 'complete' => 'onComplete',
@ -350,7 +350,7 @@ class JqueryEngineHelperTest extends CakeTestCase {
'direction' => 'vertical', 'direction' => 'vertical',
)); ));
$expected = '$("#element").slider({change:function (event, ui) {onChange}, max:10, min:0, orientation:"vertical", stop:function (event, ui) {onComplete}, value:2});'; $expected = '$("#element").slider({change:function (event, ui) {onChange}, max:10, min:0, orientation:"vertical", stop:function (event, ui) {onComplete}, value:2});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -362,14 +362,14 @@ class JqueryEngineHelperTest extends CakeTestCase {
$this->Jquery->get('#element'); $this->Jquery->get('#element');
$result = $this->Jquery->serializeForm(array('isForm' => false)); $result = $this->Jquery->serializeForm(array('isForm' => false));
$expected = '$("#element").closest("form").serialize();'; $expected = '$("#element").closest("form").serialize();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Jquery->serializeForm(array('isForm' => true)); $result = $this->Jquery->serializeForm(array('isForm' => true));
$expected = '$("#element").serialize();'; $expected = '$("#element").serialize();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Jquery->serializeForm(array('isForm' => false, 'inline' => true)); $result = $this->Jquery->serializeForm(array('isForm' => false, 'inline' => true));
$expected = '$("#element").closest("form").serialize()'; $expected = '$("#element").closest("form").serialize()';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
} }

View file

@ -269,7 +269,7 @@ class JsHelperTest extends CakeTestCase {
$this->cDataEnd, $this->cDataEnd,
'/script', '/script',
); );
$this->assertTags($result, $expected, true); $this->assertTags($expected, $result, true);
$this->Js->TestJsEngine->expects($this->atLeastOnce())->method('domReady'); $this->Js->TestJsEngine->expects($this->atLeastOnce())->method('domReady');
$result = $this->Js->writeBuffer(array('onDomReady' => true, 'cache' => false, 'clear' => false)); $result = $this->Js->writeBuffer(array('onDomReady' => true, 'cache' => false, 'clear' => false));
@ -326,7 +326,7 @@ class JsHelperTest extends CakeTestCase {
$expected = array( $expected = array(
'script' => array('type' => 'text/javascript', 'src' => 'preg:/(.)*\.js/'), 'script' => array('type' => 'text/javascript', 'src' => 'preg:/(.)*\.js/'),
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
preg_match('/src="(.*\.js)"/', $result, $filename); preg_match('/src="(.*\.js)"/', $result, $filename);
$this->assertTrue(file_exists(WWW_ROOT . $filename[1])); $this->assertTrue(file_exists(WWW_ROOT . $filename[1]));
$contents = file_get_contents(WWW_ROOT . $filename[1]); $contents = file_get_contents(WWW_ROOT . $filename[1]);
@ -363,7 +363,7 @@ class JsHelperTest extends CakeTestCase {
'test link', 'test link',
'/a' '/a'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
} }
/** /**
@ -400,7 +400,7 @@ class JsHelperTest extends CakeTestCase {
'test link »', 'test link »',
'/a' '/a'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
} }
/** /**
@ -419,7 +419,7 @@ class JsHelperTest extends CakeTestCase {
'test link', 'test link',
'/a' '/a'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
} }
/** /**
@ -451,7 +451,7 @@ class JsHelperTest extends CakeTestCase {
$this->cDataEnd, $this->cDataEnd,
'/script' '/script'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
} }
/** /**
@ -482,7 +482,7 @@ class JsHelperTest extends CakeTestCase {
'-event handler-', '-event handler-',
'/script' '/script'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
} }
/** /**
@ -521,7 +521,7 @@ class JsHelperTest extends CakeTestCase {
'input' => array('type' => 'submit', 'id' => $options['id'], 'value' => 'Save', 'style' => 'margin: 0'), 'input' => array('type' => 'submit', 'id' => $options['id'], 'value' => 'Save', 'style' => 'margin: 0'),
'/div' '/div'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
} }
/** /**
@ -567,7 +567,7 @@ class JsHelperTest extends CakeTestCase {
'input' => array('type' => 'submit', 'id' => $options['id'], 'value' => 'Save'), 'input' => array('type' => 'submit', 'id' => $options['id'], 'value' => 'Save'),
'/div' '/div'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
} }
/** /**
@ -589,11 +589,11 @@ class JsHelperTest extends CakeTestCase {
$this->Js->TestJsEngine->expects($this->at(2)) $this->Js->TestJsEngine->expects($this->at(2))
->method('request') ->method('request')
->will($this->returnValue('ajax-code')); ->will($this->returnValue('ajax-code'));
$this->Js->TestJsEngine->expects($this->at(3)) $this->Js->TestJsEngine->expects($this->at(3))
->method('event') ->method('event')
->will($this->returnValue('event-handler')); ->will($this->returnValue('event-handler'));
$params = array( $params = array(
'update' => $options['update'], 'data' => 'serialize-code', 'update' => $options['update'], 'data' => 'serialize-code',
'method' => 'post', 'dataExpression' => true, 'buffer' => false 'method' => 'post', 'dataExpression' => true, 'buffer' => false
@ -612,7 +612,7 @@ class JsHelperTest extends CakeTestCase {
'event-handler', 'event-handler',
'/script' '/script'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
} }
/** /**
@ -623,7 +623,7 @@ class JsHelperTest extends CakeTestCase {
function testObjectPassThrough() { function testObjectPassThrough() {
$result = $this->Js->object(array('one' => 'first', 'two' => 'second')); $result = $this->Js->object(array('one' => 'first', 'two' => 'second'));
$expected = '{"one":"first","two":"second"}'; $expected = '{"one":"first","two":"second"}';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -635,7 +635,7 @@ class JsHelperTest extends CakeTestCase {
function testValuePassThrough() { function testValuePassThrough() {
$result = $this->Js->value('string "quote"', true); $result = $this->Js->value('string "quote"', true);
$expected = '"string \"quote\""'; $expected = '"string \"quote\""';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -718,27 +718,27 @@ class JsBaseEngineTest extends CakeTestCase {
function testEscaping() { function testEscaping() {
$result = $this->JsEngine->escape(''); $result = $this->JsEngine->escape('');
$expected = ''; $expected = '';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->JsEngine->escape('CakePHP' . "\n" . 'Rapid Development Framework'); $result = $this->JsEngine->escape('CakePHP' . "\n" . 'Rapid Development Framework');
$expected = 'CakePHP\\nRapid Development Framework'; $expected = 'CakePHP\\nRapid Development Framework';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->JsEngine->escape('CakePHP' . "\r\n" . 'Rapid Development Framework' . "\r" . 'For PHP'); $result = $this->JsEngine->escape('CakePHP' . "\r\n" . 'Rapid Development Framework' . "\r" . 'For PHP');
$expected = 'CakePHP\\r\\nRapid Development Framework\\rFor PHP'; $expected = 'CakePHP\\r\\nRapid Development Framework\\rFor PHP';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->JsEngine->escape('CakePHP: "Rapid Development Framework"'); $result = $this->JsEngine->escape('CakePHP: "Rapid Development Framework"');
$expected = 'CakePHP: \\"Rapid Development Framework\\"'; $expected = 'CakePHP: \\"Rapid Development Framework\\"';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->JsEngine->escape("CakePHP: 'Rapid Development Framework'"); $result = $this->JsEngine->escape("CakePHP: 'Rapid Development Framework'");
$expected = "CakePHP: 'Rapid Development Framework'"; $expected = "CakePHP: 'Rapid Development Framework'";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->JsEngine->escape('my \\"string\\"'); $result = $this->JsEngine->escape('my \\"string\\"');
$expected = 'my \\\\\\"string\\\\\\"'; $expected = 'my \\\\\\"string\\\\\\"';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -749,11 +749,11 @@ class JsBaseEngineTest extends CakeTestCase {
function testPrompt() { function testPrompt() {
$result = $this->JsEngine->prompt('Hey, hey you', 'hi!'); $result = $this->JsEngine->prompt('Hey, hey you', 'hi!');
$expected = 'prompt("Hey, hey you", "hi!");'; $expected = 'prompt("Hey, hey you", "hi!");';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->JsEngine->prompt('"Hey"', '"hi"'); $result = $this->JsEngine->prompt('"Hey"', '"hi"');
$expected = 'prompt("\"Hey\"", "\"hi\"");'; $expected = 'prompt("\"Hey\"", "\"hi\"");';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -764,11 +764,11 @@ class JsBaseEngineTest extends CakeTestCase {
function testAlert() { function testAlert() {
$result = $this->JsEngine->alert('Hey there'); $result = $this->JsEngine->alert('Hey there');
$expected = 'alert("Hey there");'; $expected = 'alert("Hey there");';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->JsEngine->alert('"Hey"'); $result = $this->JsEngine->alert('"Hey"');
$expected = 'alert("\"Hey\"");'; $expected = 'alert("\"Hey\"");';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -779,11 +779,11 @@ class JsBaseEngineTest extends CakeTestCase {
function testConfirm() { function testConfirm() {
$result = $this->JsEngine->confirm('Are you sure?'); $result = $this->JsEngine->confirm('Are you sure?');
$expected = 'confirm("Are you sure?");'; $expected = 'confirm("Are you sure?");';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->JsEngine->confirm('"Are you sure?"'); $result = $this->JsEngine->confirm('"Are you sure?"');
$expected = 'confirm("\"Are you sure?\"");'; $expected = 'confirm("\"Are you sure?\"");';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -794,7 +794,7 @@ class JsBaseEngineTest extends CakeTestCase {
function testRedirect() { function testRedirect() {
$result = $this->JsEngine->redirect(array('controller' => 'posts', 'action' => 'view', 1)); $result = $this->JsEngine->redirect(array('controller' => 'posts', 'action' => 'view', 1));
$expected = 'window.location = "/posts/view/1";'; $expected = 'window.location = "/posts/view/1";';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -807,17 +807,17 @@ class JsBaseEngineTest extends CakeTestCase {
$object = array('title' => 'New thing', 'indexes' => array(5, 6, 7, 8)); $object = array('title' => 'New thing', 'indexes' => array(5, 6, 7, 8));
$result = $this->JsEngine->object($object); $result = $this->JsEngine->object($object);
$expected = '{"title":"New thing","indexes":[5,6,7,8]}'; $expected = '{"title":"New thing","indexes":[5,6,7,8]}';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$object = new JsEncodingObject(); $object = new JsEncodingObject();
$object->title = 'New thing'; $object->title = 'New thing';
$object->indexes = array(5,6,7,8); $object->indexes = array(5,6,7,8);
$result = $this->JsEngine->object($object); $result = $this->JsEngine->object($object);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->JsEngine->object(array('default' => 0)); $result = $this->JsEngine->object(array('default' => 0));
$expected = '{"default":0}'; $expected = '{"default":0}';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->JsEngine->object(array( $result = $this->JsEngine->object(array(
'2007' => array( '2007' => array(
@ -838,11 +838,11 @@ class JsBaseEngineTest extends CakeTestCase {
) )
)); ));
$expected = '{"2007":{"Spring":{"1":{"id":1,"name":"Josh"},"2":{"id":2,"name":"Becky"}},"Fall":{"1":{"id":1,"name":"Josh"},"2":{"id":2,"name":"Becky"}}},"2006":{"Spring":{"1":{"id":1,"name":"Josh"},"2":{"id":2,"name":"Becky"}},"Fall":{"1":{"id":1,"name":"Josh"},"2":{"id":2,"name":"Becky"}}}}'; $expected = '{"2007":{"Spring":{"1":{"id":1,"name":"Josh"},"2":{"id":2,"name":"Becky"}},"Fall":{"1":{"id":1,"name":"Josh"},"2":{"id":2,"name":"Becky"}}},"2006":{"Spring":{"1":{"id":1,"name":"Josh"},"2":{"id":2,"name":"Becky"}},"Fall":{"1":{"id":1,"name":"Josh"},"2":{"id":2,"name":"Becky"}}}}';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
foreach (array('true' => true, 'false' => false, 'null' => null) as $expected => $data) { foreach (array('true' => true, 'false' => false, 'null' => null) as $expected => $data) {
$result = $this->JsEngine->object($data); $result = $this->JsEngine->object($data);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
$object = array('title' => 'New thing', 'indexes' => array(5, 6, 7, 8), 'object' => array('inner' => array('value' => 1))); $object = array('title' => 'New thing', 'indexes' => array(5, 6, 7, 8), 'object' => array('inner' => array('value' => 1)));
@ -883,11 +883,11 @@ class JsBaseEngineTest extends CakeTestCase {
$result = $JsEngine->testParseOptions(array('url' => '/posts/view/1', 'key' => 1)); $result = $JsEngine->testParseOptions(array('url' => '/posts/view/1', 'key' => 1));
$expected = 'key:1, url:"\\/posts\\/view\\/1"'; $expected = 'key:1, url:"\\/posts\\/view\\/1"';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $JsEngine->testParseOptions(array('url' => '/posts/view/1', 'success' => 'doSuccess'), array('success')); $result = $JsEngine->testParseOptions(array('url' => '/posts/view/1', 'success' => 'doSuccess'), array('success'));
$expected = 'success:doSuccess, url:"\\/posts\\/view\\/1"'; $expected = 'success:doSuccess, url:"\\/posts\\/view\\/1"';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
} }

View file

@ -88,15 +88,15 @@ class MooEngineHelperTest extends CakeTestCase {
$this->Moo->get('#myLink'); $this->Moo->get('#myLink');
$result = $this->Moo->event('click', 'doClick', array('wrap' => false)); $result = $this->Moo->event('click', 'doClick', array('wrap' => false));
$expected = '$("myLink").addEvent("click", doClick);'; $expected = '$("myLink").addEvent("click", doClick);';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Moo->event('click', 'this.setStyle("display", "");', array('stop' => false)); $result = $this->Moo->event('click', 'this.setStyle("display", "");', array('stop' => false));
$expected = '$("myLink").addEvent("click", function (event) {this.setStyle("display", "");});'; $expected = '$("myLink").addEvent("click", function (event) {this.setStyle("display", "");});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Moo->event('click', 'this.setStyle("display", "none");'); $result = $this->Moo->event('click', 'this.setStyle("display", "none");');
$expected = "\$(\"myLink\").addEvent(\"click\", function (event) {event.stop();\nthis.setStyle(\"display\", \"none\");});"; $expected = "\$(\"myLink\").addEvent(\"click\", function (event) {event.stop();\nthis.setStyle(\"display\", \"none\");});";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
* test dom ready event creation * test dom ready event creation
@ -106,7 +106,7 @@ class MooEngineHelperTest extends CakeTestCase {
function testDomReady() { function testDomReady() {
$result = $this->Moo->domReady('foo.name = "bar";'); $result = $this->Moo->domReady('foo.name = "bar";');
$expected = 'window.addEvent("domready", function (event) {foo.name = "bar";});'; $expected = 'window.addEvent("domready", function (event) {foo.name = "bar";});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
* test Each method * test Each method
@ -117,7 +117,7 @@ class MooEngineHelperTest extends CakeTestCase {
$this->Moo->get('#foo'); $this->Moo->get('#foo');
$result = $this->Moo->each('item.setStyle("display", "none");'); $result = $this->Moo->each('item.setStyle("display", "none");');
$expected = '$("foo").each(function (item, index) {item.setStyle("display", "none");});'; $expected = '$("foo").each(function (item, index) {item.setStyle("display", "none");});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
* test Effect generation * test Effect generation
@ -128,35 +128,35 @@ class MooEngineHelperTest extends CakeTestCase {
$this->Moo->get('#foo'); $this->Moo->get('#foo');
$result = $this->Moo->effect('show'); $result = $this->Moo->effect('show');
$expected = '$("foo").setStyle("display", "");'; $expected = '$("foo").setStyle("display", "");';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Moo->effect('hide'); $result = $this->Moo->effect('hide');
$expected = '$("foo").setStyle("display", "none");'; $expected = '$("foo").setStyle("display", "none");';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Moo->effect('fadeIn'); $result = $this->Moo->effect('fadeIn');
$expected = '$("foo").fade("in");'; $expected = '$("foo").fade("in");';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Moo->effect('fadeOut'); $result = $this->Moo->effect('fadeOut');
$expected = '$("foo").fade("out");'; $expected = '$("foo").fade("out");';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Moo->effect('slideIn'); $result = $this->Moo->effect('slideIn');
$expected = '$("foo").slide("in");'; $expected = '$("foo").slide("in");';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Moo->effect('slideOut'); $result = $this->Moo->effect('slideOut');
$expected = '$("foo").slide("out");'; $expected = '$("foo").slide("out");';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Moo->effect('slideOut', array('speed' => 'fast')); $result = $this->Moo->effect('slideOut', array('speed' => 'fast'));
$expected = '$("foo").set("slide", {duration:"short"}).slide("out");'; $expected = '$("foo").set("slide", {duration:"short"}).slide("out");';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Moo->effect('slideOut', array('speed' => 'slow')); $result = $this->Moo->effect('slideOut', array('speed' => 'slow'));
$expected = '$("foo").set("slide", {duration:"long"}).slide("out");'; $expected = '$("foo").set("slide", {duration:"long"}).slide("out");';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
* Test Request Generation * Test Request Generation
@ -166,11 +166,11 @@ class MooEngineHelperTest extends CakeTestCase {
function testRequest() { function testRequest() {
$result = $this->Moo->request(array('controller' => 'posts', 'action' => 'view', 1)); $result = $this->Moo->request(array('controller' => 'posts', 'action' => 'view', 1));
$expected = 'var jsRequest = new Request({url:"\\/posts\\/view\\/1"}).send();'; $expected = 'var jsRequest = new Request({url:"\\/posts\\/view\\/1"}).send();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Moo->request('/posts/view/1', array('update' => 'content')); $result = $this->Moo->request('/posts/view/1', array('update' => 'content'));
$expected = 'var jsRequest = new Request.HTML({update:"content", url:"\\/posts\\/view\\/1"}).send();'; $expected = 'var jsRequest = new Request.HTML({update:"content", url:"\\/posts\\/view\\/1"}).send();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Moo->request('/people/edit/1', array( $result = $this->Moo->request('/people/edit/1', array(
'method' => 'post', 'method' => 'post',
@ -181,7 +181,7 @@ class MooEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = 'var jsRequest = new Request.JSON({method:"post", onComplete:doSuccess, onFailure:handleError, url:"\\/people\\/edit\\/1"}).send({"name":"jim","height":"185cm"});'; $expected = 'var jsRequest = new Request.JSON({method:"post", onComplete:doSuccess, onFailure:handleError, url:"\\/people\\/edit\\/1"}).send({"name":"jim","height":"185cm"});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Moo->request('/people/edit/1', array( $result = $this->Moo->request('/people/edit/1', array(
'method' => 'post', 'method' => 'post',
@ -190,7 +190,7 @@ class MooEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = 'var jsRequest = new Request.HTML({method:"post", onComplete:doSuccess, update:"update-zone", url:"\\/people\\/edit\\/1"}).send();'; $expected = 'var jsRequest = new Request.HTML({method:"post", onComplete:doSuccess, update:"update-zone", url:"\\/people\\/edit\\/1"}).send();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Moo->request('/people/edit/1', array( $result = $this->Moo->request('/people/edit/1', array(
'method' => 'post', 'method' => 'post',
@ -202,7 +202,7 @@ class MooEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = 'var jsRequest = new Request.HTML({method:"post", onComplete:doComplete, onFailure:doFailure, onRequest:doBefore, onSuccess:doSuccess, update:"update-zone", url:"\\/people\\/edit\\/1"}).send();'; $expected = 'var jsRequest = new Request.HTML({method:"post", onComplete:doComplete, onFailure:doFailure, onRequest:doBefore, onSuccess:doSuccess, update:"update-zone", url:"\\/people\\/edit\\/1"}).send();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Moo->request('/people/edit/1', array( $result = $this->Moo->request('/people/edit/1', array(
'method' => 'post', 'method' => 'post',
@ -216,7 +216,7 @@ class MooEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = 'var jsRequest = new Request.HTML({method:"post", onComplete:doComplete, onFailure:doFailure, onRequest:doBefore, onSuccess:doSuccess, update:"update-zone", url:"\\/people\\/edit\\/1"}).send($("foo").toQueryString());'; $expected = 'var jsRequest = new Request.HTML({method:"post", onComplete:doComplete, onFailure:doFailure, onRequest:doBefore, onSuccess:doSuccess, update:"update-zone", url:"\\/people\\/edit\\/1"}).send($("foo").toQueryString());';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Moo->request('/people/edit/1', array( $result = $this->Moo->request('/people/edit/1', array(
'method' => 'post', 'method' => 'post',
@ -226,7 +226,7 @@ class MooEngineHelperTest extends CakeTestCase {
'update' => '#update-zone', 'update' => '#update-zone',
)); ));
$expected = 'var jsRequest = new Request.HTML({method:"post", onComplete:function () {doComplete}, onRequest:function () {doBefore}, onSuccess:function (responseText, responseXML) {doSuccess}, update:"update-zone", url:"\\/people\\/edit\\/1"}).send();'; $expected = 'var jsRequest = new Request.HTML({method:"post", onComplete:function () {doComplete}, onRequest:function () {doBefore}, onSuccess:function (responseText, responseXML) {doSuccess}, update:"update-zone", url:"\\/people\\/edit\\/1"}).send();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
* test sortable list generation * test sortable list generation
@ -244,7 +244,7 @@ class MooEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = 'var jsSortable = new Sortables($("myList"), {constrain:"parent", onComplete:onStop, onSort:onSort, onStart:onStart, snap:5});'; $expected = 'var jsSortable = new Sortables($("myList"), {constrain:"parent", onComplete:onStop, onSort:onSort, onStart:onStart, snap:5});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
* test drag() method * test drag() method
@ -261,7 +261,7 @@ class MooEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = '$("drag-me").makeDraggable({onComplete:onStop, onDrag:onDrag, onStart:onStart, snap:[10,10]});'; $expected = '$("drag-me").makeDraggable({onComplete:onStop, onDrag:onDrag, onStart:onStart, snap:[10,10]});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
* test drop() method * test drop() method
@ -285,7 +285,7 @@ class MooEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = '$("my-drag").makeDraggable({droppables:$("drop-me"), onDrop:onDrop, onEnter:onHover, onLeave:onLeave});'; $expected = '$("my-drag").makeDraggable({droppables:$("drop-me"), onDrop:onDrop, onEnter:onHover, onLeave:onLeave});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertEqual($this->Moo->selection, '$("drop-me")'); $this->assertEqual($this->Moo->selection, '$("drop-me")');
$result = $this->Moo->drop(array( $result = $this->Moo->drop(array(
@ -295,7 +295,7 @@ class MooEngineHelperTest extends CakeTestCase {
'drag' => '#my-drag', 'drag' => '#my-drag',
)); ));
$expected = '$("my-drag").makeDraggable({droppables:$("drop-me"), onDrop:function (element, droppable, event) {onDrop}, onEnter:function (element, droppable) {onHover}, onLeave:function (element, droppable) {onLeave}});'; $expected = '$("my-drag").makeDraggable({droppables:$("drop-me"), onDrop:function (element, droppable, event) {onDrop}, onEnter:function (element, droppable) {onHover}, onLeave:function (element, droppable) {onLeave}});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
* test slider generation * test slider generation
@ -312,7 +312,7 @@ class MooEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = 'var jsSlider = new Slider($("slider"), $("my-handle"), {mode:"horizontal", onChange:onChange, onComplete:onComplete});'; $expected = 'var jsSlider = new Slider($("slider"), $("my-handle"), {mode:"horizontal", onChange:onChange, onComplete:onComplete});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertEqual($this->Moo->selection, '$("slider")'); $this->assertEqual($this->Moo->selection, '$("slider")');
$this->Moo->get('#slider'); $this->Moo->get('#slider');
@ -326,7 +326,7 @@ class MooEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = 'var jsSlider = new Slider($("slider"), $("my-handle"), {mode:"horizontal", onChange:onChange, onComplete:onComplete, range:[10,40]});'; $expected = 'var jsSlider = new Slider($("slider"), $("my-handle"), {mode:"horizontal", onChange:onChange, onComplete:onComplete, range:[10,40]});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Moo->get('#slider'); $this->Moo->get('#slider');
$result = $this->Moo->slider(array( $result = $this->Moo->slider(array(
@ -336,7 +336,7 @@ class MooEngineHelperTest extends CakeTestCase {
'direction' => 'horizontal', 'direction' => 'horizontal',
)); ));
$expected = 'var jsSlider = new Slider($("slider"), $("my-handle"), {mode:"horizontal", onChange:function (step) {change;}, onComplete:function (event) {complete;}});'; $expected = 'var jsSlider = new Slider($("slider"), $("my-handle"), {mode:"horizontal", onChange:function (step) {change;}, onComplete:function (event) {complete;}});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
* test the serializeForm implementation. * test the serializeForm implementation.
@ -347,18 +347,18 @@ class MooEngineHelperTest extends CakeTestCase {
$this->Moo->get('#element'); $this->Moo->get('#element');
$result = $this->Moo->serializeForm(array('isForm' => true)); $result = $this->Moo->serializeForm(array('isForm' => true));
$expected = '$("element").toQueryString();'; $expected = '$("element").toQueryString();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Moo->serializeForm(array('isForm' => true, 'inline' => true)); $result = $this->Moo->serializeForm(array('isForm' => true, 'inline' => true));
$expected = '$("element").toQueryString()'; $expected = '$("element").toQueryString()';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Moo->serializeForm(array('isForm' => false)); $result = $this->Moo->serializeForm(array('isForm' => false));
$expected = '$($("element").form).toQueryString();'; $expected = '$($("element").form).toQueryString();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Moo->serializeForm(array('isForm' => false, 'inline' => true)); $result = $this->Moo->serializeForm(array('isForm' => false, 'inline' => true));
$expected = '$($("element").form).toQueryString()'; $expected = '$($("element").form).toQueryString()';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
} }

View file

@ -133,39 +133,39 @@ class NumberHelperTest extends CakeTestCase {
$result = $this->Number->currency(1, null, array('wholeSymbol' => '$ ')); $result = $this->Number->currency(1, null, array('wholeSymbol' => '$ '));
$expected = '$ 1.00'; $expected = '$ 1.00';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Number->currency(1, null, array('wholeSymbol' => ' $', 'wholePosition' => 'after')); $result = $this->Number->currency(1, null, array('wholeSymbol' => ' $', 'wholePosition' => 'after'));
$expected = '1.00 $'; $expected = '1.00 $';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Number->currency(.2, null, array('wholeSymbol' => ' $', 'wholePosition' => 'after', 'fractionSymbol' => 'cents')); $result = $this->Number->currency(.2, null, array('wholeSymbol' => ' $', 'wholePosition' => 'after', 'fractionSymbol' => 'cents'));
$expected = '20cents'; $expected = '20cents';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Number->currency(.2, null, array('wholeSymbol' => ' $', 'wholePosition' => 'after', 'fractionSymbol' => 'cents', 'fractionPosition' => 'before')); $result = $this->Number->currency(.2, null, array('wholeSymbol' => ' $', 'wholePosition' => 'after', 'fractionSymbol' => 'cents', 'fractionPosition' => 'before'));
$expected = 'cents20'; $expected = 'cents20';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Number->currency(311, 'USD', array('wholePosition' => 'after')); $result = $this->Number->currency(311, 'USD', array('wholePosition' => 'after'));
$expected = '311.00$'; $expected = '311.00$';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Number->currency(.2, 'EUR'); $result = $this->Number->currency(.2, 'EUR');
$expected = '&#8364;0,20'; $expected = '&#8364;0,20';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Number->currency(12, null, array('wholeSymbol' => ' dollars', 'wholePosition' => 'after', 'fractionSymbol' => ' cents', 'fractionPosition' => 'after')); $result = $this->Number->currency(12, null, array('wholeSymbol' => ' dollars', 'wholePosition' => 'after', 'fractionSymbol' => ' cents', 'fractionPosition' => 'after'));
$expected = '12.00 dollars'; $expected = '12.00 dollars';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Number->currency(.12, null, array('wholeSymbol' => ' dollars', 'wholePosition' => 'after', 'fractionSymbol' => ' cents', 'fractionPosition' => 'after')); $result = $this->Number->currency(.12, null, array('wholeSymbol' => ' dollars', 'wholePosition' => 'after', 'fractionSymbol' => ' cents', 'fractionPosition' => 'after'));
$expected = '12 cents'; $expected = '12 cents';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Number->currency(.5, null, array('fractionSymbol' => false, 'fractionPosition' => 'before', 'wholeSymbol' => '$')); $result = $this->Number->currency(.5, null, array('fractionSymbol' => false, 'fractionPosition' => 'before', 'wholeSymbol' => '$'));
$expected = '$0.50'; $expected = '$0.50';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -381,7 +381,7 @@ class NumberHelperTest extends CakeTestCase {
$result = $this->Number->currency('0.35', 'GBP'); $result = $this->Number->currency('0.35', 'GBP');
$expected = '35p'; $expected = '35p';
$this->assertEqual($expected, $result); $this->assertEqual($expected, $result);
$result = $this->Number->currency('0.35', 'EUR'); $result = $this->Number->currency('0.35', 'EUR');
$expected = '&#8364;0,35'; $expected = '&#8364;0,35';
$this->assertEqual($expected, $result); $this->assertEqual($expected, $result);
@ -460,18 +460,18 @@ class NumberHelperTest extends CakeTestCase {
function testToPercentage() { function testToPercentage() {
$result = $this->Number->toPercentage(45, 0); $result = $this->Number->toPercentage(45, 0);
$expected = '45%'; $expected = '45%';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Number->toPercentage(45, 2); $result = $this->Number->toPercentage(45, 2);
$expected = '45.00%'; $expected = '45.00%';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Number->toPercentage(0, 0); $result = $this->Number->toPercentage(0, 0);
$expected = '0%'; $expected = '0%';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Number->toPercentage(0, 4); $result = $this->Number->toPercentage(0, 4);
$expected = '0.0000%'; $expected = '0.0000%';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -87,15 +87,15 @@ class PrototypeEngineHelperTest extends CakeTestCase {
$this->Proto->get('#myLink'); $this->Proto->get('#myLink');
$result = $this->Proto->event('click', 'doClick', array('wrap' => false)); $result = $this->Proto->event('click', 'doClick', array('wrap' => false));
$expected = '$("myLink").observe("click", doClick);'; $expected = '$("myLink").observe("click", doClick);';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->event('click', 'Element.hide(this);', array('stop' => false)); $result = $this->Proto->event('click', 'Element.hide(this);', array('stop' => false));
$expected = '$("myLink").observe("click", function (event) {Element.hide(this);});'; $expected = '$("myLink").observe("click", function (event) {Element.hide(this);});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->event('click', 'Element.hide(this);'); $result = $this->Proto->event('click', 'Element.hide(this);');
$expected = "\$(\"myLink\").observe(\"click\", function (event) {event.stop();\nElement.hide(this);});"; $expected = "\$(\"myLink\").observe(\"click\", function (event) {event.stop();\nElement.hide(this);});";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -106,7 +106,7 @@ class PrototypeEngineHelperTest extends CakeTestCase {
function testDomReady() { function testDomReady() {
$result = $this->Proto->domReady('foo.name = "bar";'); $result = $this->Proto->domReady('foo.name = "bar";');
$expected = 'document.observe("dom:loaded", function (event) {foo.name = "bar";});'; $expected = 'document.observe("dom:loaded", function (event) {foo.name = "bar";});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -118,7 +118,7 @@ class PrototypeEngineHelperTest extends CakeTestCase {
$this->Proto->get('#foo li'); $this->Proto->get('#foo li');
$result = $this->Proto->each('item.hide();'); $result = $this->Proto->each('item.hide();');
$expected = '$$("#foo li").each(function (item, index) {item.hide();});'; $expected = '$$("#foo li").each(function (item, index) {item.hide();});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -130,51 +130,51 @@ class PrototypeEngineHelperTest extends CakeTestCase {
$this->Proto->get('#foo'); $this->Proto->get('#foo');
$result = $this->Proto->effect('show'); $result = $this->Proto->effect('show');
$expected = '$("foo").show();'; $expected = '$("foo").show();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->effect('hide'); $result = $this->Proto->effect('hide');
$expected = '$("foo").hide();'; $expected = '$("foo").hide();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->effect('fadeIn'); $result = $this->Proto->effect('fadeIn');
$expected = '$("foo").appear();'; $expected = '$("foo").appear();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->effect('fadeIn', array('speed' => 'fast')); $result = $this->Proto->effect('fadeIn', array('speed' => 'fast'));
$expected = '$("foo").appear({duration:0.50000000000});'; $expected = '$("foo").appear({duration:0.50000000000});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->effect('fadeIn', array('speed' => 'slow')); $result = $this->Proto->effect('fadeIn', array('speed' => 'slow'));
$expected = '$("foo").appear({duration:2});'; $expected = '$("foo").appear({duration:2});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->effect('fadeOut'); $result = $this->Proto->effect('fadeOut');
$expected = '$("foo").fade();'; $expected = '$("foo").fade();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->effect('fadeOut', array('speed' => 'fast')); $result = $this->Proto->effect('fadeOut', array('speed' => 'fast'));
$expected = '$("foo").fade({duration:0.50000000000});'; $expected = '$("foo").fade({duration:0.50000000000});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->effect('fadeOut', array('speed' => 'slow')); $result = $this->Proto->effect('fadeOut', array('speed' => 'slow'));
$expected = '$("foo").fade({duration:2});'; $expected = '$("foo").fade({duration:2});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->effect('slideIn'); $result = $this->Proto->effect('slideIn');
$expected = 'Effect.slideDown($("foo"));'; $expected = 'Effect.slideDown($("foo"));';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->effect('slideOut'); $result = $this->Proto->effect('slideOut');
$expected = 'Effect.slideUp($("foo"));'; $expected = 'Effect.slideUp($("foo"));';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->effect('slideOut', array('speed' => 'fast')); $result = $this->Proto->effect('slideOut', array('speed' => 'fast'));
$expected = 'Effect.slideUp($("foo"), {duration:0.50000000000});'; $expected = 'Effect.slideUp($("foo"), {duration:0.50000000000});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->effect('slideOut', array('speed' => 'slow')); $result = $this->Proto->effect('slideOut', array('speed' => 'slow'));
$expected = 'Effect.slideUp($("foo"), {duration:2});'; $expected = 'Effect.slideUp($("foo"), {duration:2});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -185,7 +185,7 @@ class PrototypeEngineHelperTest extends CakeTestCase {
function testRequest() { function testRequest() {
$result = $this->Proto->request(array('controller' => 'posts', 'action' => 'view', 1)); $result = $this->Proto->request(array('controller' => 'posts', 'action' => 'view', 1));
$expected = 'var jsRequest = new Ajax.Request("/posts/view/1");'; $expected = 'var jsRequest = new Ajax.Request("/posts/view/1");';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->request('/posts/view/1', array( $result = $this->Proto->request('/posts/view/1', array(
'method' => 'post', 'method' => 'post',
@ -197,11 +197,11 @@ class PrototypeEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = 'var jsRequest = new Ajax.Request("/posts/view/1", {method:"post", onComplete:doComplete, onCreate:doBefore, onFailure:doError, onSuccess:doSuccess, parameters:{"name":"jim","height":"185cm"}});'; $expected = 'var jsRequest = new Ajax.Request("/posts/view/1", {method:"post", onComplete:doComplete, onCreate:doBefore, onFailure:doError, onSuccess:doSuccess, parameters:{"name":"jim","height":"185cm"}});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->request('/posts/view/1', array('update' => 'content')); $result = $this->Proto->request('/posts/view/1', array('update' => 'content'));
$expected = 'var jsRequest = new Ajax.Updater("content", "/posts/view/1");'; $expected = 'var jsRequest = new Ajax.Updater("content", "/posts/view/1");';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->request('/people/edit/1', array( $result = $this->Proto->request('/people/edit/1', array(
'method' => 'post', 'method' => 'post',
@ -210,7 +210,7 @@ class PrototypeEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = 'var jsRequest = new Ajax.Updater("update-zone", "/people/edit/1", {method:"post", onComplete:doSuccess});'; $expected = 'var jsRequest = new Ajax.Updater("update-zone", "/people/edit/1", {method:"post", onComplete:doSuccess});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->request('/people/edit/1', array( $result = $this->Proto->request('/people/edit/1', array(
'method' => 'post', 'method' => 'post',
@ -221,7 +221,7 @@ class PrototypeEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = 'var jsRequest = new Ajax.Request("/people/edit/1", {method:"post", onComplete:doSuccess, onFailure:handleError, parameters:{"name":"jim","height":"185cm"}});'; $expected = 'var jsRequest = new Ajax.Request("/people/edit/1", {method:"post", onComplete:doSuccess, onFailure:handleError, parameters:{"name":"jim","height":"185cm"}});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->request('/people/edit/1', array( $result = $this->Proto->request('/people/edit/1', array(
'method' => 'post', 'method' => 'post',
@ -233,7 +233,7 @@ class PrototypeEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = 'var jsRequest = new Ajax.Request("/people/edit/1", {method:"post", onComplete:doSuccess, onFailure:handleError, parameters:$("element").serialize()});'; $expected = 'var jsRequest = new Ajax.Request("/people/edit/1", {method:"post", onComplete:doSuccess, onFailure:handleError, parameters:$("element").serialize()});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->request('/people/edit/1', array( $result = $this->Proto->request('/people/edit/1', array(
'method' => 'post', 'method' => 'post',
@ -243,7 +243,7 @@ class PrototypeEngineHelperTest extends CakeTestCase {
'error' => 'handleError();', 'error' => 'handleError();',
)); ));
$expected = 'var jsRequest = new Ajax.Request("/people/edit/1", {method:"post", onComplete:function (transport) {doComplete();}, onCreate:function (transport) {doBefore();}, onFailure:function (response, jsonHeader) {handleError();}, onSuccess:function (response, jsonHeader) {doSuccess();}});'; $expected = 'var jsRequest = new Ajax.Request("/people/edit/1", {method:"post", onComplete:function (transport) {doComplete();}, onCreate:function (transport) {doBefore();}, onFailure:function (response, jsonHeader) {handleError();}, onSuccess:function (response, jsonHeader) {doSuccess();}});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->request('/people/edit/1', array( $result = $this->Proto->request('/people/edit/1', array(
'async' => false, 'async' => false,
@ -254,7 +254,7 @@ class PrototypeEngineHelperTest extends CakeTestCase {
'error' => 'handleError();', 'error' => 'handleError();',
)); ));
$expected = 'var jsRequest = new Ajax.Request("/people/edit/1", {asynchronous:false, method:"post", onComplete:function (transport) {doComplete();}, onCreate:function (transport) {doBefore();}, onFailure:function (response, jsonHeader) {handleError();}, onSuccess:function (response, jsonHeader) {doSuccess();}});'; $expected = 'var jsRequest = new Ajax.Request("/people/edit/1", {asynchronous:false, method:"post", onComplete:function (transport) {doComplete();}, onCreate:function (transport) {doBefore();}, onFailure:function (response, jsonHeader) {handleError();}, onSuccess:function (response, jsonHeader) {doSuccess();}});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Proto->get('#submit'); $this->Proto->get('#submit');
$result = $this->Proto->request('/users/login', array( $result = $this->Proto->request('/users/login', array(
@ -281,7 +281,7 @@ class PrototypeEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = 'var jsSortable = Sortable.create($("myList"), {onChange:onSort, onUpdate:onComplete});'; $expected = 'var jsSortable = Sortable.create($("myList"), {onChange:onSort, onUpdate:onComplete});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -300,7 +300,7 @@ class PrototypeEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = 'var jsDrag = new Draggable($("element"), {onDrag:onDrag, onEnd:onStop, onStart:onStart, snap:[10,10]});'; $expected = 'var jsDrag = new Draggable($("element"), {onDrag:onDrag, onEnd:onStop, onStart:onStart, snap:[10,10]});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Proto->get('div.dragger'); $this->Proto->get('div.dragger');
$result = $this->Proto->drag(array( $result = $this->Proto->drag(array(
@ -311,7 +311,7 @@ class PrototypeEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = '$$("div.dragger").each(function (item, index) {new Draggable(item, {onDrag:onDrag, onEnd:onStop, onStart:onStart, snap:[10,10]});});'; $expected = '$$("div.dragger").each(function (item, index) {new Draggable(item, {onDrag:onDrag, onEnd:onStop, onStart:onStart, snap:[10,10]});});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -328,7 +328,7 @@ class PrototypeEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = 'Droppables.add($("element"), {accept:".drag-me", onDrop:onDrop, onHover:onHover});'; $expected = 'Droppables.add($("element"), {accept:".drag-me", onDrop:onDrop, onHover:onHover});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -347,7 +347,7 @@ class PrototypeEngineHelperTest extends CakeTestCase {
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = 'var jsSlider = new Control.Slider($("handle"), $("element"), {axis:"horizontal", onChange:onComplete, onSlide:onChange, sliderValue:4});'; $expected = 'var jsSlider = new Control.Slider($("handle"), $("element"), {axis:"horizontal", onChange:onComplete, onSlide:onChange, sliderValue:4});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Proto->get('#element'); $this->Proto->get('#element');
$result = $this->Proto->slider(array( $result = $this->Proto->slider(array(
@ -359,7 +359,7 @@ class PrototypeEngineHelperTest extends CakeTestCase {
'max' => 100 'max' => 100
)); ));
$expected = 'var jsSlider = new Control.Slider($("handle"), $("element"), {onChange:function (value) {complete();}, onSlide:function (value) {change();}, range:$R(10,100), sliderValue:4});'; $expected = 'var jsSlider = new Control.Slider($("handle"), $("element"), {onChange:function (value) {complete();}, onSlide:function (value) {change();}, range:$R(10,100), sliderValue:4});';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -371,18 +371,18 @@ class PrototypeEngineHelperTest extends CakeTestCase {
$this->Proto->get('#element'); $this->Proto->get('#element');
$result = $this->Proto->serializeForm(array('isForm' => true)); $result = $this->Proto->serializeForm(array('isForm' => true));
$expected = '$("element").serialize();'; $expected = '$("element").serialize();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->serializeForm(array('isForm' => true, 'inline' => true)); $result = $this->Proto->serializeForm(array('isForm' => true, 'inline' => true));
$expected = '$("element").serialize()'; $expected = '$("element").serialize()';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->serializeForm(array('isForm' => false)); $result = $this->Proto->serializeForm(array('isForm' => false));
$expected = '$($("element").form).serialize();'; $expected = '$($("element").form).serialize();';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Proto->serializeForm(array('isForm' => false, 'inline' => true)); $result = $this->Proto->serializeForm(array('isForm' => false, 'inline' => true));
$expected = '$($("element").form).serialize()'; $expected = '$($("element").form).serialize()';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
} }

View file

@ -64,7 +64,7 @@ class RssHelperTest extends CakeTestCase {
'version' => '2.0' 'version' => '2.0'
) )
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Rss->document(null, 'content'); $result = $this->Rss->document(null, 'content');
$expected = array( $expected = array(
@ -73,7 +73,7 @@ class RssHelperTest extends CakeTestCase {
), ),
'content' 'content'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Rss->document(array('contrived' => 'parameter'), 'content'); $result = $this->Rss->document(array('contrived' => 'parameter'), 'content');
$expected = array( $expected = array(
@ -83,7 +83,7 @@ class RssHelperTest extends CakeTestCase {
), ),
'content' 'content'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
} }
/** /**
@ -113,7 +113,7 @@ class RssHelperTest extends CakeTestCase {
'content', 'content',
'/channel' '/channel'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
} }
/** /**
@ -163,7 +163,7 @@ class RssHelperTest extends CakeTestCase {
'content-here', 'content-here',
'/channel', '/channel',
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
} }
function testChannelElementAttributes() { function testChannelElementAttributes() {
@ -205,7 +205,7 @@ class RssHelperTest extends CakeTestCase {
'content-here', 'content-here',
'/channel', '/channel',
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
} }
/** /**
@ -242,11 +242,11 @@ class RssHelperTest extends CakeTestCase {
'<description', 'description3', '/description', '<description', 'description3', '/description',
'/item' '/item'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$result = $this->Rss->items(array()); $result = $this->Rss->items(array());
$expected = ''; $expected = '';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -278,7 +278,7 @@ class RssHelperTest extends CakeTestCase {
'/guid', '/guid',
'/item' '/item'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$item = array( $item = array(
'title' => 'My Title', 'title' => 'My Title',
@ -308,7 +308,7 @@ class RssHelperTest extends CakeTestCase {
'/guid', '/guid',
'/item' '/item'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$item = array( $item = array(
'title' => 'My Title & more' 'title' => 'My Title & more'
@ -319,7 +319,7 @@ class RssHelperTest extends CakeTestCase {
'<title', 'My Title &amp; more', '/title', '<title', 'My Title &amp; more', '/title',
'/item' '/item'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$item = array( $item = array(
'title' => 'Foo bar', 'title' => 'Foo bar',
@ -353,7 +353,7 @@ class RssHelperTest extends CakeTestCase {
'/guid', '/guid',
'/item' '/item'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
} }
/** /**
@ -377,7 +377,7 @@ class RssHelperTest extends CakeTestCase {
'/title', '/title',
'/item' '/item'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$item = array( $item = array(
'category' => array( 'category' => array(
@ -394,7 +394,7 @@ class RssHelperTest extends CakeTestCase {
'/category', '/category',
'/item' '/item'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$item = array( $item = array(
'category' => array( 'category' => array(
@ -420,7 +420,7 @@ class RssHelperTest extends CakeTestCase {
'/category', '/category',
'/item' '/item'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
$item = array( $item = array(
'title' => array( 'title' => array(
@ -476,7 +476,7 @@ class RssHelperTest extends CakeTestCase {
'/category', '/category',
'/item' '/item'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
} }
/** /**
@ -514,6 +514,6 @@ class RssHelperTest extends CakeTestCase {
), ),
'/item' '/item'
); );
$this->assertTags($result, $expected); $this->assertTags($expected, $result);
} }
} }

View file

@ -124,12 +124,12 @@ class SessionHelperTest extends CakeTestCase {
function testFlash() { function testFlash() {
$result = $this->Session->flash('flash'); $result = $this->Session->flash('flash');
$expected = '<div id="flashMessage" class="message">This is a calling</div>'; $expected = '<div id="flashMessage" class="message">This is a calling</div>';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertFalse($this->Session->check('Message.flash')); $this->assertFalse($this->Session->check('Message.flash'));
$expected = '<div id="classyMessage" class="positive">Recorded</div>'; $expected = '<div id="classyMessage" class="positive">Recorded</div>';
$result = $this->Session->flash('classy'); $result = $this->Session->flash('classy');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
App::build(array( App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS) 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
@ -137,12 +137,12 @@ class SessionHelperTest extends CakeTestCase {
$result = $this->Session->flash('notification'); $result = $this->Session->flash('notification');
$result = str_replace("\r\n", "\n", $result); $result = str_replace("\r\n", "\n", $result);
$expected = "<div id=\"notificationLayout\">\n\t<h1>Alert!</h1>\n\t<h3>Notice!</h3>\n\t<p>This is a test of the emergency broadcasting system</p>\n</div>"; $expected = "<div id=\"notificationLayout\">\n\t<h1>Alert!</h1>\n\t<h3>Notice!</h3>\n\t<p>This is a test of the emergency broadcasting system</p>\n</div>";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertFalse($this->Session->check('Message.notification')); $this->assertFalse($this->Session->check('Message.notification'));
$result = $this->Session->flash('bare'); $result = $this->Session->flash('bare');
$expected = 'Bare message'; $expected = 'Bare message';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertFalse($this->Session->check('Message.bare')); $this->assertFalse($this->Session->check('Message.bare'));
} }
@ -154,7 +154,7 @@ class SessionHelperTest extends CakeTestCase {
function testFlashAttributes() { function testFlashAttributes() {
$result = $this->Session->flash('flash', array('params' => array('class' => 'test-message'))); $result = $this->Session->flash('flash', array('params' => array('class' => 'test-message')));
$expected = '<div id="flashMessage" class="test-message">This is a calling</div>'; $expected = '<div id="flashMessage" class="test-message">This is a calling</div>';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->assertFalse($this->Session->check('Message.flash')); $this->assertFalse($this->Session->check('Message.flash'));
} }

View file

@ -112,7 +112,7 @@ class TextHelperTest extends CakeTestCase {
$expected = 'Ich <b>saß</b> in einem <b>Café</b> am <b>Übergang</b>'; $expected = 'Ich <b>saß</b> in einem <b>Café</b> am <b>Übergang</b>';
$phrases = array('saß', 'café', 'übergang'); $phrases = array('saß', 'café', 'übergang');
$result = $this->Text->highlight($text, $phrases, array('format' => '<b>\1</b>')); $result = $this->Text->highlight($text, $phrases, array('format' => '<b>\1</b>'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -205,32 +205,32 @@ class TextHelperTest extends CakeTestCase {
$text = 'This is a test text with URL http://www.cakephp.org'; $text = 'This is a test text with URL http://www.cakephp.org';
$expected = 'This is a test text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a>'; $expected = 'This is a test text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a>';
$result = $this->Text->autoLink($text); $result = $this->Text->autoLink($text);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$text = 'This is a test text with URL http://www.cakephp.org and some more text'; $text = 'This is a test text with URL http://www.cakephp.org and some more text';
$expected = 'This is a test text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a> and some more text'; $expected = 'This is a test text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a> and some more text';
$result = $this->Text->autoLink($text); $result = $this->Text->autoLink($text);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$text = "This is a test text with URL http://www.cakephp.org\tand some more text"; $text = "This is a test text with URL http://www.cakephp.org\tand some more text";
$expected = "This is a test text with URL <a href=\"http://www.cakephp.org\">http://www.cakephp.org</a>\tand some more text"; $expected = "This is a test text with URL <a href=\"http://www.cakephp.org\">http://www.cakephp.org</a>\tand some more text";
$result = $this->Text->autoLink($text); $result = $this->Text->autoLink($text);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$text = 'This is a test text with URL http://www.cakephp.org(and some more text)'; $text = 'This is a test text with URL http://www.cakephp.org(and some more text)';
$expected = 'This is a test text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a>(and some more text)'; $expected = 'This is a test text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a>(and some more text)';
$result = $this->Text->autoLink($text); $result = $this->Text->autoLink($text);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$text = 'This is a test text with URL http://www.cakephp.org'; $text = 'This is a test text with URL http://www.cakephp.org';
$expected = 'This is a test text with URL <a href="http://www.cakephp.org" class="link">http://www.cakephp.org</a>'; $expected = 'This is a test text with URL <a href="http://www.cakephp.org" class="link">http://www.cakephp.org</a>';
$result = $this->Text->autoLink($text, array('class'=>'link')); $result = $this->Text->autoLink($text, array('class'=>'link'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$text = 'This is a test text with URL http://www.cakephp.org'; $text = 'This is a test text with URL http://www.cakephp.org';
$expected = 'This is a test text with URL <a href="http://www.cakephp.org" class="link" id="MyLink">http://www.cakephp.org</a>'; $expected = 'This is a test text with URL <a href="http://www.cakephp.org" class="link" id="MyLink">http://www.cakephp.org</a>';
$result = $this->Text->autoLink($text, array('class'=>'link', 'id'=>'MyLink')); $result = $this->Text->autoLink($text, array('class'=>'link', 'id'=>'MyLink'));
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -274,12 +274,12 @@ class TextHelperTest extends CakeTestCase {
$expected = 'Text with a url <a href="http://www.cot.ag/cuIb2Q">www.cot.ag/cuIb2Q</a> and more'; $expected = 'Text with a url <a href="http://www.cot.ag/cuIb2Q">www.cot.ag/cuIb2Q</a> and more';
$result = $this->Text->autoLinkUrls($text); $result = $this->Text->autoLinkUrls($text);
$this->assertEqual($expected, $result); $this->assertEqual($expected, $result);
$text = 'Text with a url http://www.does--not--work.com and more'; $text = 'Text with a url http://www.does--not--work.com and more';
$expected = 'Text with a url <a href="http://www.does--not--work.com">http://www.does--not--work.com</a> and more'; $expected = 'Text with a url <a href="http://www.does--not--work.com">http://www.does--not--work.com</a> and more';
$result = $this->Text->autoLinkUrls($text); $result = $this->Text->autoLinkUrls($text);
$this->assertEqual($expected, $result); $this->assertEqual($expected, $result);
$text = 'Text with a url http://www.not--work.com and more'; $text = 'Text with a url http://www.not--work.com and more';
$expected = 'Text with a url <a href="http://www.not--work.com">http://www.not--work.com</a> and more'; $expected = 'Text with a url <a href="http://www.not--work.com">http://www.not--work.com</a> and more';
$result = $this->Text->autoLinkUrls($text); $result = $this->Text->autoLinkUrls($text);
@ -302,7 +302,7 @@ class TextHelperTest extends CakeTestCase {
$expected = 'Text with <a href="mailto:email@example.com"\s*>email@example.com</a> address'; $expected = 'Text with <a href="mailto:email@example.com"\s*>email@example.com</a> address';
$result = $this->Text->autoLinkEmails($text); $result = $this->Text->autoLinkEmails($text);
$this->assertPattern('#^' . $expected . '$#', $result); $this->assertPattern('#^' . $expected . '$#', $result);
$text = "Text with o'hare._-bob@example.com address"; $text = "Text with o'hare._-bob@example.com address";
$expected = 'Text with <a href="mailto:o&#039;hare._-bob@example.com">o&#039;hare._-bob@example.com</a> address'; $expected = 'Text with <a href="mailto:o&#039;hare._-bob@example.com">o&#039;hare._-bob@example.com</a> address';
$result = $this->Text->autoLinkEmails($text); $result = $this->Text->autoLinkEmails($text);
@ -427,7 +427,7 @@ class TextHelperTest extends CakeTestCase {
$result = $this->Text->toList(array( 'name1' => 'Dusty', 'name2' => 'Lucky')); $result = $this->Text->toList(array( 'name1' => 'Dusty', 'name2' => 'Lucky'));
$this->assertEqual($result, 'Dusty and Lucky'); $this->assertEqual($result, 'Dusty and Lucky');
$result = $this->Text->toList(array( 'test_0' => 'banana', 'test_1' => 'apple', 'test_2' => 'lemon')); $result = $this->Text->toList(array( 'test_0' => 'banana', 'test_1' => 'apple', 'test_2' => 'lemon'));
$this->assertEqual($result, 'banana, apple and lemon'); $this->assertEqual($result, 'banana, apple and lemon');
} }

View file

@ -622,7 +622,7 @@ class TimeHelperTest extends CakeTestCase {
$expected = time(); $expected = time();
$result = $this->Time->fromString(time(), $yourTimezone); $result = $this->Time->fromString(time(), $yourTimezone);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -640,12 +640,12 @@ class TimeHelperTest extends CakeTestCase {
$result = $this->Time->fromString('+1 hour'); $result = $this->Time->fromString('+1 hour');
$expected = strtotime('+1 hour'); $expected = strtotime('+1 hour');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$timezone = date('Z', time()); $timezone = date('Z', time());
$result = $this->Time->fromString('+1 hour', $timezone); $result = $this->Time->fromString('+1 hour', $timezone);
$expected = $this->Time->convert(strtotime('+1 hour'), $timezone); $expected = $this->Time->convert(strtotime('+1 hour'), $timezone);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -663,79 +663,79 @@ class TimeHelperTest extends CakeTestCase {
$result = $this->Time->convertSpecifiers('%a', $time); $result = $this->Time->convertSpecifiers('%a', $time);
$expected = 'jue'; $expected = 'jue';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Time->convertSpecifiers('%A', $time); $result = $this->Time->convertSpecifiers('%A', $time);
$expected = 'jueves'; $expected = 'jueves';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Time->convertSpecifiers('%c', $time); $result = $this->Time->convertSpecifiers('%c', $time);
$expected = 'jue %d ene %Y %H:%M:%S %Z'; $expected = 'jue %d ene %Y %H:%M:%S %Z';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Time->convertSpecifiers('%C', $time); $result = $this->Time->convertSpecifiers('%C', $time);
$expected = '20'; $expected = '20';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Time->convertSpecifiers('%D', $time); $result = $this->Time->convertSpecifiers('%D', $time);
$expected = '%m/%d/%y'; $expected = '%m/%d/%y';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Time->convertSpecifiers('%b', $time); $result = $this->Time->convertSpecifiers('%b', $time);
$expected = 'ene'; $expected = 'ene';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Time->convertSpecifiers('%h', $time); $result = $this->Time->convertSpecifiers('%h', $time);
$expected = 'ene'; $expected = 'ene';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Time->convertSpecifiers('%B', $time); $result = $this->Time->convertSpecifiers('%B', $time);
$expected = 'enero'; $expected = 'enero';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Time->convertSpecifiers('%n', $time); $result = $this->Time->convertSpecifiers('%n', $time);
$expected = "\n"; $expected = "\n";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Time->convertSpecifiers('%n', $time); $result = $this->Time->convertSpecifiers('%n', $time);
$expected = "\n"; $expected = "\n";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Time->convertSpecifiers('%p', $time); $result = $this->Time->convertSpecifiers('%p', $time);
$expected = 'AM'; $expected = 'AM';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Time->convertSpecifiers('%P', $time); $result = $this->Time->convertSpecifiers('%P', $time);
$expected = 'am'; $expected = 'am';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Time->convertSpecifiers('%r', $time); $result = $this->Time->convertSpecifiers('%r', $time);
$expected = '%I:%M:%S AM'; $expected = '%I:%M:%S AM';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Time->convertSpecifiers('%R', $time); $result = $this->Time->convertSpecifiers('%R', $time);
$expected = '11:43'; $expected = '11:43';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Time->convertSpecifiers('%t', $time); $result = $this->Time->convertSpecifiers('%t', $time);
$expected = "\t"; $expected = "\t";
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Time->convertSpecifiers('%T', $time); $result = $this->Time->convertSpecifiers('%T', $time);
$expected = '%H:%M:%S'; $expected = '%H:%M:%S';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Time->convertSpecifiers('%u', $time); $result = $this->Time->convertSpecifiers('%u', $time);
$expected = 4; $expected = 4;
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Time->convertSpecifiers('%x', $time); $result = $this->Time->convertSpecifiers('%x', $time);
$expected = '%d/%m/%y'; $expected = '%d/%m/%y';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Time->convertSpecifiers('%X', $time); $result = $this->Time->convertSpecifiers('%X', $time);
$expected = '%H:%M:%S'; $expected = '%H:%M:%S';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -750,11 +750,11 @@ class TimeHelperTest extends CakeTestCase {
$time = strtotime('Thu Jan 14 11:43:39 2010'); $time = strtotime('Thu Jan 14 11:43:39 2010');
$result = $this->Time->convertSpecifiers('%e', $time); $result = $this->Time->convertSpecifiers('%e', $time);
$expected = '14'; $expected = '14';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Time->convertSpecifiers('%e', strtotime('2011-01-01')); $result = $this->Time->convertSpecifiers('%e', strtotime('2011-01-01'));
$expected = ' 1'; $expected = ' 1';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**
@ -772,19 +772,19 @@ class TimeHelperTest extends CakeTestCase {
$result = $this->Time->i18nFormat($time); $result = $this->Time->i18nFormat($time);
$expected = '14/01/10'; $expected = '14/01/10';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Time->i18nFormat($time, '%c'); $result = $this->Time->i18nFormat($time, '%c');
$expected = 'jue 14 ene 2010 13:59:28 ' . strftime('%Z', $time); $expected = 'jue 14 ene 2010 13:59:28 ' . strftime('%Z', $time);
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Time->i18nFormat($time, 'Time is %r, and date is %x'); $result = $this->Time->i18nFormat($time, 'Time is %r, and date is %x');
$expected = 'Time is 01:59:28 PM, and date is 14/01/10'; $expected = 'Time is 01:59:28 PM, and date is 14/01/10';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Time->i18nFormat('invalid date', '%x', 'Date invalid'); $result = $this->Time->i18nFormat('invalid date', '%x', 'Date invalid');
$expected = 'Date invalid'; $expected = 'Date invalid';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
} }
/** /**

View file

@ -648,7 +648,7 @@ class HelperTest extends CakeTestCase {
} }
} }
$expected = array('what', 'how', 'how', 'what', 'how', 'how'); $expected = array('what', 'how', 'how', 'what', 'how', 'how');
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Helper->request->data['HelperTestComment']['5']['id'] = 'ok'; $this->Helper->request->data['HelperTestComment']['5']['id'] = 'ok';
$result = $this->Helper->value('HelperTestComment.5.id'); $result = $this->Helper->value('HelperTestComment.5.id');
@ -754,7 +754,7 @@ class HelperTest extends CakeTestCase {
$this->Helper->request->webroot = '/'; $this->Helper->request->webroot = '/';
$result = $this->Helper->webroot('/img/cake.power.gif'); $result = $this->Helper->webroot('/img/cake.power.gif');
$expected = '/img/cake.power.gif'; $expected = '/img/cake.power.gif';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$this->Helper->theme = 'test_theme'; $this->Helper->theme = 'test_theme';
@ -764,30 +764,30 @@ class HelperTest extends CakeTestCase {
$result = $this->Helper->webroot('/img/cake.power.gif'); $result = $this->Helper->webroot('/img/cake.power.gif');
$expected = '/theme/test_theme/img/cake.power.gif'; $expected = '/theme/test_theme/img/cake.power.gif';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Helper->webroot('/img/test.jpg'); $result = $this->Helper->webroot('/img/test.jpg');
$expected = '/theme/test_theme/img/test.jpg'; $expected = '/theme/test_theme/img/test.jpg';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$webRoot = Configure::read('App.www_root'); $webRoot = Configure::read('App.www_root');
Configure::write('App.www_root', CAKE . 'Test' . DS . 'test_app' . DS . 'webroot' . DS); Configure::write('App.www_root', CAKE . 'Test' . DS . 'test_app' . DS . 'webroot' . DS);
$result = $this->Helper->webroot('/img/cake.power.gif'); $result = $this->Helper->webroot('/img/cake.power.gif');
$expected = '/theme/test_theme/img/cake.power.gif'; $expected = '/theme/test_theme/img/cake.power.gif';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Helper->webroot('/img/test.jpg'); $result = $this->Helper->webroot('/img/test.jpg');
$expected = '/theme/test_theme/img/test.jpg'; $expected = '/theme/test_theme/img/test.jpg';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Helper->webroot('/img/cake.icon.gif'); $result = $this->Helper->webroot('/img/cake.icon.gif');
$expected = '/img/cake.icon.gif'; $expected = '/img/cake.icon.gif';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
$result = $this->Helper->webroot('/img/cake.icon.gif?some=param'); $result = $this->Helper->webroot('/img/cake.icon.gif?some=param');
$expected = '/img/cake.icon.gif?some=param'; $expected = '/img/cake.icon.gif?some=param';
$this->assertEqual($result, $expected); $this->assertEqual($expected, $result);
Configure::write('App.www_root', $webRoot); Configure::write('App.www_root', $webRoot);
} }