2007-02-06 17:18:23 +00:00
|
|
|
<?php
|
|
|
|
/* SVN FILE: $Id$ */
|
|
|
|
/**
|
|
|
|
* Short description for file.
|
|
|
|
*
|
|
|
|
* Long description for file
|
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
|
|
|
* CakePHP Test Suite <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
|
|
|
* Copyright (c) 2006, Larry E. Masters Shorewood, IL. 60431
|
|
|
|
* Author(s): Larry E. Masters aka PhpNut <phpnut@gmail.com>
|
|
|
|
*
|
|
|
|
* Licensed under The Open Group Test Suite License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
|
|
|
* @filesource
|
|
|
|
* @author Larry E. Masters aka PhpNut <phpnut@gmail.com>
|
|
|
|
* @copyright Copyright (c) 2006, Larry E. Masters Shorewood, IL. 60431
|
|
|
|
* @link http://www.phpnut.com/projects/
|
|
|
|
* @package test_suite
|
|
|
|
* @subpackage test_suite.cases.app
|
|
|
|
* @since CakePHP Test Suite v 1.0.0.0
|
|
|
|
* @version $Revision$
|
|
|
|
* @modifiedby $LastChangedBy$
|
|
|
|
* @lastmodified $Date$
|
|
|
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
|
|
|
*/
|
|
|
|
require_once LIBS.'../app_helper.php';
|
|
|
|
require_once LIBS.DS.'view'.DS.'helper.php';
|
|
|
|
require_once LIBS.DS.'view'.DS.'helpers'.DS.'html.php';
|
|
|
|
require_once LIBS.DS.'view'.DS.'helpers'.DS.'form.php';
|
|
|
|
require_once LIBS.DS.'view'.DS.'helpers'.DS.'javascript.php';
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package test_suite
|
|
|
|
* @subpackage test_suite.cases.libs
|
|
|
|
* @since CakePHP Test Suite v 1.0.0.0
|
|
|
|
*/
|
|
|
|
class JavascriptTest extends UnitTestCase {
|
|
|
|
|
|
|
|
function setUp() {
|
|
|
|
$this->js = new JavascriptHelper();
|
|
|
|
$this->js->Html = new HtmlHelper();
|
|
|
|
$this->js->Form = new FormHelper();
|
|
|
|
}
|
|
|
|
|
2007-03-15 16:37:46 +00:00
|
|
|
function testLink() {
|
|
|
|
$result = $this->js->link('script.js');
|
|
|
|
$expected = '<script type="text/javascript" src="js/script.js"></script>';
|
|
|
|
$this->assertEqual($result, $expected, "Error creating link, expected '{$expected}', got '{$result}'.");
|
|
|
|
|
|
|
|
$result = $this->js->link('script');
|
|
|
|
$expected = '<script type="text/javascript" src="js/script.js"></script>';
|
|
|
|
$this->assertEqual($result, $expected, "Error creating link, expected '{$expected}', got '{$result}'.");
|
|
|
|
|
|
|
|
$result = $this->js->link('scriptaculous.js?load=effects');
|
|
|
|
$expected = '<script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>';
|
|
|
|
$this->assertEqual($result, $expected, "Error creating link, expected '{$expected}', got '{$result}'.");
|
|
|
|
|
|
|
|
$result = $this->js->link('jquery-1.1.2');
|
|
|
|
$expected = '<script type="text/javascript" src="js/jquery-1.1.2.js"></script>';
|
|
|
|
$this->assertEqual($result, $expected, "Error creating link, expected '{$expected}', got '{$result}'.");
|
|
|
|
}
|
|
|
|
|
2007-02-06 17:18:23 +00:00
|
|
|
function testObjectGeneration() {
|
|
|
|
$object = array('title' => 'New thing', 'indexes' => array(5, 6, 7, 8));
|
|
|
|
|
|
|
|
$result = $this->js->object($object);
|
|
|
|
$expected = '{"title":"New thing", "indexes":[5, 6, 7, 8]}';
|
|
|
|
$this->assertEqual($result, $expected, "Error generating JavaScript object, expected '{$expected}', got '{$result}'.");
|
|
|
|
}
|
|
|
|
|
|
|
|
function tearDown() {
|
|
|
|
unset($this->js);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|