Skip to content

Commit

Permalink
Fixing tests for php4 compat.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Apr 7, 2009
1 parent 34f67cc commit c6c7630
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
16 changes: 10 additions & 6 deletions cake/tests/cases/libs/view/helpers/jquery_engine.test.php
Expand Up @@ -68,15 +68,16 @@ function testSelector() {
* @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);
}
Expand All @@ -96,7 +97,8 @@ function testDomReady() {
* @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);
}
Expand All @@ -106,7 +108,8 @@ function testEach() {
* @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);

Expand Down Expand Up @@ -170,7 +173,8 @@ function testRequest() {
* @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',
Expand Down
16 changes: 10 additions & 6 deletions cake/tests/cases/libs/view/helpers/mootools_engine.test.php
Expand Up @@ -76,15 +76,16 @@ function testSelector() {
* @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);
}
Expand All @@ -104,7 +105,8 @@ function testDomReady() {
* @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);
}
Expand All @@ -114,7 +116,8 @@ function testEach() {
* @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);

Expand Down Expand Up @@ -196,7 +199,8 @@ function testRequest() {
* @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',
Expand Down
10 changes: 6 additions & 4 deletions cake/tests/cases/libs/view/helpers/prototype_engine.test.php
Expand Up @@ -76,15 +76,16 @@ function testSelector() {
* @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);
}
Expand All @@ -104,7 +105,8 @@ function testDomReady() {
* @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);
}
Expand Down

0 comments on commit c6c7630

Please sign in to comment.