Fixing tests for php4 compat.

This commit is contained in:
mark_story 2009-04-06 21:24:14 -04:00
parent 34f67cc897
commit c6c7630d8f
3 changed files with 26 additions and 16 deletions

View file

@ -68,15 +68,16 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
* @return void
**/
function testEvent() {
$result = $this->Jquery->get('#myLink')->event('click', 'doClick', array('wrap' => false));
$this->Jquery->get('#myLink');
$result = $this->Jquery->event('click', 'doClick', array('wrap' => false));
$expected = '$("#myLink").bind("click", doClick);';
$this->assertEqual($result, $expected);
$result = $this->Jquery->get('#myLink')->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();});';
$this->assertEqual($result, $expected);
$result = $this->Jquery->get('#myLink')->event('click', '$(this).hide();');
$result = $this->Jquery->event('click', '$(this).hide();');
$expected = '$("#myLink").bind("click", function (event) {$(this).hide();'."\n".'return false;});';
$this->assertEqual($result, $expected);
}
@ -96,7 +97,8 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
* @return void
**/
function testEach() {
$result = $this->Jquery->get('#foo')->each('$(this).hide();');
$this->Jquery->get('#foo');
$result = $this->Jquery->each('$(this).hide();');
$expected = '$("#foo").each(function () {$(this).hide();});';
$this->assertEqual($result, $expected);
}
@ -106,7 +108,8 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
* @return void
**/
function testEffect() {
$result = $this->Jquery->get('#foo')->effect('show');
$this->Jquery->get('#foo');
$result = $this->Jquery->effect('show');
$expected = '$("#foo").show();';
$this->assertEqual($result, $expected);
@ -170,7 +173,8 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
* @return void
**/
function testSortable() {
$result = $this->Jquery->get('#myList')->sortable(array(
$this->Jquery->get('#myList');
$result = $this->Jquery->sortable(array(
'distance' => 5,
'containment' => 'parent',
'start' => 'onStart',

View file

@ -76,15 +76,16 @@ class MooEngineHelperTestCase extends CakeTestCase {
* @return void
**/
function testEvent() {
$result = $this->Moo->get('#myLink')->event('click', 'doClick', array('wrap' => false));
$this->Moo->get('#myLink');
$result = $this->Moo->event('click', 'doClick', array('wrap' => false));
$expected = '$("myLink").addEvent("click", doClick);';
$this->assertEqual($result, $expected);
$result = $this->Moo->get('#myLink')->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", "");});';
$this->assertEqual($result, $expected);
$result = $this->Moo->get('#myLink')->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\");});";
$this->assertEqual($result, $expected);
}
@ -104,7 +105,8 @@ class MooEngineHelperTestCase extends CakeTestCase {
* @return void
**/
function testEach() {
$result = $this->Moo->get('#foo')->each('item.setStyle("display", "none");');
$this->Moo->get('#foo');
$result = $this->Moo->each('item.setStyle("display", "none");');
$expected = '$("foo").each(function (item, index) {item.setStyle("display", "none");});';
$this->assertEqual($result, $expected);
}
@ -114,7 +116,8 @@ class MooEngineHelperTestCase extends CakeTestCase {
* @return void
**/
function testEffect() {
$result = $this->Moo->get('#foo')->effect('show');
$this->Moo->get('#foo');
$result = $this->Moo->effect('show');
$expected = '$("foo").setStyle("display", "");';
$this->assertEqual($result, $expected);
@ -196,7 +199,8 @@ class MooEngineHelperTestCase extends CakeTestCase {
* @return void
**/
function testSortable() {
$result = $this->Moo->get('#myList')->sortable(array(
$this->Moo->get('#myList');
$result = $this->Moo->sortable(array(
'distance' => 5,
'containment' => 'parent',
'start' => 'onStart',

View file

@ -76,15 +76,16 @@ class PrototypeEngineHelperTestCase extends CakeTestCase {
* @return void
**/
function testEvent() {
$result = $this->Proto->get('#myLink')->event('click', 'doClick', array('wrap' => false));
$this->Proto->get('#myLink');
$result = $this->Proto->event('click', 'doClick', array('wrap' => false));
$expected = '$("myLink").observe("click", doClick);';
$this->assertEqual($result, $expected);
$result = $this->Proto->get('#myLink')->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);});';
$this->assertEqual($result, $expected);
$result = $this->Proto->get('#myLink')->event('click', 'Element.hide(this);');
$result = $this->Proto->event('click', 'Element.hide(this);');
$expected = "\$(\"myLink\").observe(\"click\", function (event) {event.stop();\nElement.hide(this);});";
$this->assertEqual($result, $expected);
}
@ -104,7 +105,8 @@ class PrototypeEngineHelperTestCase extends CakeTestCase {
* @return void
**/
function testEach() {
$result = $this->Proto->get('#foo li')->each('item.hide();');
$this->Proto->get('#foo li');
$result = $this->Proto->each('item.hide();');
$expected = '$$("#foo li").each(function (item, index) {item.hide();});';
$this->assertEqual($result, $expected);
}