2007-02-26 12:58:02 +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
|
|
|
|
*/
|
2007-07-08 01:17:57 +00:00
|
|
|
require_once CAKE.'app_helper.php';
|
|
|
|
uses('class_registry', 'controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper',
|
|
|
|
'view'.DS.'helpers'.DS.'html', 'view'.DS.'helpers'.DS.'form');
|
2007-02-26 12:58:02 +00:00
|
|
|
|
2007-03-06 08:48:45 +00:00
|
|
|
class TheHtmlTestController extends Controller {
|
2007-02-26 12:58:02 +00:00
|
|
|
var $name = 'TheTest';
|
|
|
|
var $uses = null;
|
2007-03-06 08:48:45 +00:00
|
|
|
}
|
2007-02-26 12:58:02 +00:00
|
|
|
|
|
|
|
class HtmlHelperTest extends UnitTestCase {
|
|
|
|
var $html = null;
|
2007-07-06 04:31:45 +00:00
|
|
|
|
2007-02-26 12:58:02 +00:00
|
|
|
function setUp() {
|
2007-04-06 19:12:15 +00:00
|
|
|
$this->Html =& new HtmlHelper();
|
|
|
|
$view =& new View(new TheHtmlTestController());
|
2007-02-26 12:58:02 +00:00
|
|
|
ClassRegistry::addObject('view', $view);
|
|
|
|
}
|
2007-07-06 04:31:45 +00:00
|
|
|
|
2007-04-28 07:42:54 +00:00
|
|
|
function testLinkEscape() {
|
|
|
|
$result = $this->Html->link('Next >', '#');
|
|
|
|
$expected = '/^<a href="#"\s+>Next ><\/a>$/';
|
2007-07-06 04:31:45 +00:00
|
|
|
|
2007-04-28 07:42:54 +00:00
|
|
|
$this->assertPattern($expected, $result);
|
2007-07-06 04:31:45 +00:00
|
|
|
|
2007-04-28 07:42:54 +00:00
|
|
|
$result = $this->Html->link('Next >', '#', array('escape' => false));
|
|
|
|
$expected = '/^<a href="#"\s+>Next ><\/a>$/';
|
2007-07-06 04:31:45 +00:00
|
|
|
|
2007-04-28 07:42:54 +00:00
|
|
|
$this->assertPattern($expected, $result);
|
|
|
|
}
|
2007-07-06 04:31:45 +00:00
|
|
|
|
2007-04-06 19:12:15 +00:00
|
|
|
function testImageLink() {
|
|
|
|
$result = $this->Html->link($this->Html->image('test.gif'), '#', array(), false, false, false);
|
|
|
|
$expected = '/^<a href="#"\s+><img\s+src="img\/test.gif"\s+alt=""\s+\/><\/a>$/';
|
2007-07-06 04:31:45 +00:00
|
|
|
|
2007-04-06 19:12:15 +00:00
|
|
|
$this->assertPattern($expected, $result);
|
|
|
|
}
|
2007-07-06 04:31:45 +00:00
|
|
|
|
2007-05-24 22:50:20 +00:00
|
|
|
function testStyle() {
|
|
|
|
$result = $this->Html->style(array('display'=> 'none', 'margin'=>'10px'));
|
|
|
|
$expected = 'style="display:none; margin:10px;"';
|
|
|
|
$this->assertEqual($expected, $result);
|
2007-07-06 04:31:45 +00:00
|
|
|
|
2007-05-24 22:50:20 +00:00
|
|
|
$result = $this->Html->style(array('display'=> 'none', 'margin'=>'10px'), false);
|
|
|
|
$expected = "display:none;\nmargin:10px;";
|
|
|
|
$this->assertEqual($expected, $result);
|
2007-07-06 04:31:45 +00:00
|
|
|
|
2007-05-24 22:50:20 +00:00
|
|
|
}
|
2007-03-08 00:44:25 +00:00
|
|
|
|
2007-02-26 12:58:02 +00:00
|
|
|
function tearDown() {
|
2007-03-16 14:58:19 +00:00
|
|
|
unset($this->Html);
|
2007-02-26 12:58:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|