Shortening notation in Session test, removing debug data from HtmlHelper test

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4621 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-03-16 14:58:19 +00:00
parent de7423e4b6
commit fb7c56024c
2 changed files with 23 additions and 31 deletions

View file

@ -1,5 +1,5 @@
<?php
/* SVN FILE: $Id: $ */
/* SVN FILE: $Id$ */
/**
* Short description for file.
*
@ -21,9 +21,9 @@
* @package test_suite
* @subpackage test_suite.cases.app
* @since CakePHP Test Suite v 1.0.0.0
* @version $Revision: $
* @modifiedby $LastChangedBy: $
* @lastmodified $Date: $
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
require_once LIBS.'session.php';
@ -42,47 +42,38 @@ class SessionTest extends UnitTestCase {
function testCheck() {
$this->Session->write('SessionTestCase', 'value');
$result = $this->Session->check('SessionTestCase');
$this->assertEqual($result, true);
$this->assertTrue($this->Session->check('SessionTestCase'));
$result = $this->Session->check('NotExistingSessionTestCase');
$this->assertEqual($result, false);
$this->assertFalse($this->Session->check('NotExistingSessionTestCase'), false);
}
function testCheckingSavedEmpty() {
$this->Session->write('SessionTestCase', 0);
$result = $this->Session->check('SessionTestCase');
$this->assertEqual($result, true);
$this->assertTrue($this->Session->check('SessionTestCase'));
$this->Session->write('SessionTestCase', '0');
$result = $this->Session->check('SessionTestCase');
$this->assertEqual($result, true);
$this->assertTrue($this->Session->check('SessionTestCase'));
$this->Session->write('SessionTestCase', false);
$result = $this->Session->check('SessionTestCase');
$this->assertEqual($result, true);
$this->assertTrue($this->Session->check('SessionTestCase'));
$this->Session->write('SessionTestCase', null);
$result = $this->Session->check('SessionTestCase');
$this->assertEqual($result, null);
$this->assertFalse($this->Session->check('SessionTestCase'));
}
function testReadingSavedEmpty() {
$this->Session->write('SessionTestCase', 0);
$result = $this->Session->read('SessionTestCase');
$this->assertEqual($result, 0);
$this->assertEqual($this->Session->read('SessionTestCase'), 0);
$this->Session->write('SessionTestCase', '0');
$result = $this->Session->read('SessionTestCase');
$this->assertEqual($result, '0');
$this->assertEqual($this->Session->read('SessionTestCase'), '0');
$this->assertFalse($this->Session->read('SessionTestCase') === 0);
$this->Session->write('SessionTestCase', false);
$result = $this->Session->read('SessionTestCase');
$this->assertEqual($result, false);
$this->assertFalse($this->Session->read('SessionTestCase'));
$this->Session->write('SessionTestCase', null);
$result = $this->Session->read('SessionTestCase');
$this->assertEqual($result, null);
$this->assertEqual($this->Session->read('SessionTestCase'), null);
}
function tearDown() {

View file

@ -42,29 +42,30 @@ class HtmlHelperTest extends UnitTestCase {
var $html = null;
function setUp() {
$this->html = new HtmlHelper();
$this->Html = new HtmlHelper();
$view = new View(new TheHtmlTestController());
ClassRegistry::addObject('view', $view);
}
function testSelectTag() {
@$result = $this->html->selectTag('Model/field', array());
@$result = $this->Html->selectTag('Model/field', array());
$this->assertPattern('/^<select [^<>]+>\n<option [^<>]+>/', $result);
$this->assertPattern('/<option value="" ><\/option>/', $result);
$this->assertPattern('/<\/select>$/', $result);
$this->assertPattern('/<select[^<>]+name="data\[Model\]\[field\]"[^<>]*>/', $result);
$this->assertPattern('/<select[^<>]+id="ModelField"[^<>]*>/', $result);
$this->html->data = array('Model' => array('field' => 'value'));
@$result = $this->html->selectTag('Model/field', array('value' => 'good', 'other' => 'bad'));
$this->Html->data = array('Model' => array('field' => 'value'));
@$result = $this->Html->selectTag('Model/field', array('value' => 'good', 'other' => 'bad'));
$this->assertPattern('/option value=""/', $result);
$this->assertPattern('/option value="value"/', $result);
$this->assertPattern('/option value="other"/', $result);
debug($result, true);
$this->assertPattern('/<\/option>\s+<option/', $result);
$this->assertPattern('/<\/option>\s+<\/select>/', $result);
}
function tearDown() {
unset($this->html);
unset($this->Html);
}
}
?>