Index: tests/ZendX/JQuery/View/jQueryTest.php =================================================================== --- tests/ZendX/JQuery/View/jQueryTest.php (revision 24400) +++ tests/ZendX/JQuery/View/jQueryTest.php (working copy) @@ -15,19 +15,19 @@ * @category ZendX * @package ZendX_JQuery * @subpackage View - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ -require_once "jQueryTestCase.php"; +require_once 'jQueryTestCase.php'; class ZendX_JQuery_View_jQueryTest extends ZendX_JQuery_View_jQueryTestCase { public function testHelperSuccessfulCallForward() { - $jquery = new ZendX_JQuery_View_Helper_JQuery; - $jquery->addJavascript('alert();'); + $jquery = new ZendX_JQuery_View_Helper_JQuery; + $jquery->addJavascript('alert();'); } /** @@ -35,15 +35,15 @@ */ public function testHelperFailingCallForward() { - $jquery = new ZendX_JQuery_View_Helper_JQuery(); - $jquery->addAsdf(); + $jquery = new ZendX_JQuery_View_Helper_JQuery(); + $jquery->addAsdf(); } - public function testShouldCallHelperWithoutExceptions() - { - $jquery = $this->view->jQuery(); - $this->assertTrue($jquery instanceof ZendX_JQuery_View_Helper_JQuery_Container); - } + public function testShouldCallHelperWithoutExceptions() + { + $jquery = $this->view->jQuery(); + $this->assertTrue($jquery instanceof ZendX_JQuery_View_Helper_JQuery_Container); + } public function testShouldAllowSpecifyingJQueryVersion() { @@ -53,8 +53,8 @@ public function testShouldUseDefaultSupportedVersionWhenNotSpecifiedOtherwise() { - $this->assertEquals(ZendX_JQuery::DEFAULT_JQUERY_VERSION, $this->jquery->getVersion()); - $this->assertEquals(ZendX_JQuery::DEFAULT_JQUERY_VERSION, $this->jquery->getCdnVersion()); + $this->assertEquals(ZendX_JQuery::DEFAULT_JQUERY_VERSION, $this->jquery->getVersion()); + $this->assertEquals(ZendX_JQuery::DEFAULT_JQUERY_VERSION, $this->jquery->getCdnVersion()); } /** @@ -64,25 +64,25 @@ */ public function testUsingCdnShouldNotEnableHelperAnymore() { - $this->jquery->setCdnVersion(); - $this->assertFalse($this->jquery->isEnabled()); + $this->jquery->setCdnVersion(); + $this->assertFalse($this->jquery->isEnabled()); } public function testShouldBeNotEnabledByDefault() { - $this->assertFalse($this->jquery->isEnabled()); + $this->assertFalse($this->jquery->isEnabled()); } public function testUsingLocalPath() { - $this->jquery->setLocalPath("/js/jquery.min.js"); - $this->assertFalse($this->jquery->useCDN()); - $this->assertFalse($this->jquery->isEnabled()); - $this->assertTrue($this->jquery->useLocalPath()); - $this->assertContains("/js/jquery.min.js", $this->jquery->getLocalPath()); + $this->jquery->setLocalPath('/js/jquery.min.js'); + $this->assertFalse($this->jquery->useCDN()); + $this->assertFalse($this->jquery->isEnabled()); + $this->assertTrue($this->jquery->useLocalPath()); + $this->assertContains('/js/jquery.min.js', $this->jquery->getLocalPath()); - $render = $this->jquery->__toString(); - $this->assertNotContains("/js/jquery.min.js", $render); + $render = $this->jquery->__toString(); + $this->assertNotContains('/js/jquery.min.js', $render); } public function testUiDisabledDefault() @@ -108,92 +108,92 @@ $this->jquery->uiEnable(); $render = $this->jquery->__toString(); - $this->assertContains("jquery-ui", $render); + $this->assertContains('jquery-ui', $render); $this->assertContains($this->jquery->getUiCdnVersion(), $render); } public function testShouldAllowSetUiVersion() { - $this->jquery->setUiVersion("1.5.1"); - $this->assertContains("1.5.1", $this->jquery->getUiVersion()); + $this->jquery->setUiVersion('1.5.1'); + $this->assertContains('1.5.1', $this->jquery->getUiVersion()); } public function testShouldAllowSetLocalUiPath() { - $this->jquery->setUiLocalPath("/js/jquery-ui.min.js"); + $this->jquery->setUiLocalPath('/js/jquery-ui.min.js'); $this->assertTrue($this->jquery->useUiLocal()); $this->assertFalse($this->jquery->useUiCdn()); - $this->assertContains("/js/jquery-ui.min.js", $this->jquery->getUiPath()); + $this->assertContains('/js/jquery-ui.min.js', $this->jquery->getUiPath()); } public function testNoConflictShouldBeDisabledDefault() { - $this->assertFalse(ZendX_JQuery_View_Helper_JQuery::getNoConflictMode()); + $this->assertFalse(ZendX_JQuery_View_Helper_JQuery::getNoConflictMode()); } public function testUsingNoConflictMode() { - ZendX_JQuery_View_Helper_JQuery::enableNoConflictMode(); - $this->jquery->setCDNVersion("1.2.6"); + ZendX_JQuery_View_Helper_JQuery::enableNoConflictMode(); + $this->jquery->setCDNVersion('1.2.6'); $this->jquery->enable(); - $render = $this->jquery->__toString(); + $render = $this->jquery->__toString(); - $this->assertContains('var $j = jQuery.noConflict();', $render); + $this->assertContains('var $j = jQuery.noConflict();', $render); } public function testDefaultRenderModeShouldIncludeAllBlocks() { - $this->assertEquals(ZendX_JQuery::RENDER_ALL, $this->jquery->getRenderMode()); + $this->assertEquals(ZendX_JQuery::RENDER_ALL, $this->jquery->getRenderMode()); } public function testShouldAllowSettingRenderMode() { - $this->jquery->setRenderMode(1); - $this->assertEquals(1, $this->jquery->getRenderMode()); - $this->jquery->setRenderMode(2); - $this->assertEquals(2, $this->jquery->getRenderMode()); - $this->jquery->setRenderMode(4); - $this->assertEquals(4, $this->jquery->getRenderMode()); + $this->jquery->setRenderMode(1); + $this->assertEquals(1, $this->jquery->getRenderMode()); + $this->jquery->setRenderMode(2); + $this->assertEquals(2, $this->jquery->getRenderMode()); + $this->jquery->setRenderMode(4); + $this->assertEquals(4, $this->jquery->getRenderMode()); } public function testShouldAllowUsingAddOnLoadStack() { - $this->jquery->addOnLoad('$(document).alert();'); - $this->assertEquals(array('$(document).alert();'), $this->jquery->getOnLoadActions()); + $this->jquery->addOnLoad('$(document).alert();'); + $this->assertEquals(array('$(document).alert();'), $this->jquery->getOnLoadActions()); } public function testShouldAllowStackingMultipleOnLoad() { - $this->jquery->addOnLoad("1"); - $this->jquery->addOnLoad("2"); - $this->assertEquals(2, count($this->jquery->getOnLoadActions())); + $this->jquery->addOnLoad('1'); + $this->jquery->addOnLoad('2'); + $this->assertEquals(2, count($this->jquery->getOnLoadActions())); } public function testAddOnLoadEnablesJQuery() { $this->assertFalse($this->jquery->isEnabled()); - $this->jquery->addOnLoad("1"); + $this->jquery->addOnLoad('1'); $this->assertTrue($this->jquery->isEnabled()); } public function testShouldAllowCaptureOnLoad() { - $this->jquery->onLoadCaptureStart(); - echo '$(document).alert();'; - $this->jquery->onLoadCaptureEnd(); - $this->assertEquals(array('$(document).alert();'), $this->jquery->getOnLoadActions()); + $this->jquery->onLoadCaptureStart(); + echo '$(document).alert();'; + $this->jquery->onLoadCaptureEnd(); + $this->assertEquals(array('$(document).alert();'), $this->jquery->getOnLoadActions()); } public function testShouldAllowCaptureJavascript() { - $this->jquery->javascriptCaptureStart(); - echo '$(document).alert();'; - $this->jquery->javascriptCaptureEnd(); - $this->assertEquals(array('$(document).alert();'), $this->jquery->getJavascript()); + $this->jquery->javascriptCaptureStart(); + echo '$(document).alert();'; + $this->jquery->javascriptCaptureEnd(); + $this->assertEquals(array('$(document).alert();'), $this->jquery->getJavascript()); - $this->jquery->clearJavascript(); - $this->assertEquals(array(), $this->jquery->getJavascript()); + $this->jquery->clearJavascript(); + $this->assertEquals(array(), $this->jquery->getJavascript()); } /** @@ -201,8 +201,8 @@ */ public function testShouldDisallowNestingCapturesWithException() { - $this->jquery->javascriptCaptureStart(); - $this->jquery->javascriptCaptureStart(); + $this->jquery->javascriptCaptureStart(); + $this->jquery->javascriptCaptureStart(); } /** @@ -210,145 +210,145 @@ */ public function testShouldDisallowNestingCapturesWithException2() { - $this->jquery->onLoadCaptureStart(); - $this->jquery->onLoadCaptureStart(); + $this->jquery->onLoadCaptureStart(); + $this->jquery->onLoadCaptureStart(); - $this->setExpectedException('Zend_Exception'); + $this->setExpectedException('Zend_Exception'); } public function testAddJavascriptFiles() { - $this->jquery->addJavascriptFile('/js/test.js'); - $this->jquery->addJavascriptFile('/js/test2.js'); - $this->jquery->addJavascriptFile('http://example.com/test3.js'); + $this->jquery->addJavascriptFile('/js/test.js'); + $this->jquery->addJavascriptFile('/js/test2.js'); + $this->jquery->addJavascriptFile('http://example.com/test3.js'); - $this->assertEquals(array('/js/test.js', '/js/test2.js', 'http://example.com/test3.js'), $this->jquery->getJavascriptFiles()); + $this->assertEquals(array('/js/test.js', '/js/test2.js', 'http://example.com/test3.js'), $this->jquery->getJavascriptFiles()); } public function testAddedJavascriptFilesCanBeCleared() { - $this->jquery->addJavascriptFile('/js/test.js'); - $this->jquery->addJavascriptFile('/js/test2.js'); - $this->jquery->addJavascriptFile('http://example.com/test3.js'); + $this->jquery->addJavascriptFile('/js/test.js'); + $this->jquery->addJavascriptFile('/js/test2.js'); + $this->jquery->addJavascriptFile('http://example.com/test3.js'); - $this->jquery->clearJavascriptFiles(); - $this->assertEquals(array(), $this->jquery->getJavascriptFiles()); + $this->jquery->clearJavascriptFiles(); + $this->assertEquals(array(), $this->jquery->getJavascriptFiles()); } public function testAddedJavascriptFilesRender() { - $this->jquery->addJavascriptFile('/js/test.js'); - $this->jquery->addJavascriptFile('/js/test2.js'); - $this->jquery->addJavascriptFile('http://example.com/test3.js'); + $this->jquery->addJavascriptFile('/js/test.js'); + $this->jquery->addJavascriptFile('/js/test2.js'); + $this->jquery->addJavascriptFile('http://example.com/test3.js'); $this->jquery->enable(); - $render = $this->jquery->__toString(); - $this->assertContains('src="/js/test.js"', $render); - $this->assertContains('src="/js/test2.js"', $render); - $this->assertContains('src="http://example.com/test3.js', $render); + $render = $this->jquery->__toString(); + $this->assertContains('src="/js/test.js"', $render); + $this->assertContains('src="/js/test2.js"', $render); + $this->assertContains('src="http://example.com/test3.js', $render); } public function testAddStylesheet() { - $this->jquery->addStylesheet('test.css'); - $this->jquery->addStylesheet('test2.css'); + $this->jquery->addStylesheet('test.css'); + $this->jquery->addStylesheet('test2.css'); - $this->assertEquals(array('test.css', 'test2.css'), $this->jquery->getStylesheets()); + $this->assertEquals(array('test.css', 'test2.css'), $this->jquery->getStylesheets()); } public function testShouldRenderNothingOnDisable() { - $this->jquery->setCDNVersion("1.2.6"); - $this->jquery->addJavascriptFile("test.js"); - $this->jquery->disable(); - $this->assertEquals(strlen(''), strlen($this->jquery->__toString())); + $this->jquery->setCDNVersion('1.2.6'); + $this->jquery->addJavascriptFile('test.js'); + $this->jquery->disable(); + $this->assertEquals(strlen(''), strlen($this->jquery->__toString())); } public function testShouldAllowBasicSetupWithCDN() { $this->jquery->enable(); - $this->jquery->setCDNVersion("1.2.3"); - $this->jquery->addJavascriptFile("test.js"); + $this->jquery->setCDNVersion('1.2.3'); + $this->jquery->addJavascriptFile('test.js'); - $render = $this->jquery->__toString(); + $render = $this->jquery->__toString(); - $this->assertTrue($this->jquery->useCDN()); - $this->assertContains('jquery.min.js', $render); - $this->assertContains('1.2.3', $render); - $this->assertContains('test.js', $render); - $this->assertContains('