cvs: pear /HTML_CSS/tests HTML_CSS_TestCase_bug1066.php HTML_CSS_TestCase_bug1072.php HTML_CSS_TestCase_bug1084.php HTML_CSS_TestCase_bug725.php
HTML_CSS_TestCase_bug998.php testsuite.php

From: Date: Fri, 21 May 2004 12:07:02 +0000
Subject: cvs: pear /HTML_CSS/tests HTML_CSS_TestCase_bug1066.php HTML_CSS_TestCase_bug1072.php HTML_CSS_TestCase_bug1084.php HTML_CSS_TestCase_bug725.php
HTML_CSS_TestCase_bug998.php testsuite.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-19731@lists.php.net to get a copy of this message
farell Fri May 21 08:07:02 2004 EDT Added files: /pear/HTML_CSS/tests HTML_CSS_TestCase_bug1066.php HTML_CSS_TestCase_bug1072.php HTML_CSS_TestCase_bug1084.php HTML_CSS_TestCase_bug725.php HTML_CSS_TestCase_bug998.php Modified files: /pear/HTML_CSS/tests testsuite.php Log: added 5 new testcases for all known bugs

http://cvs.php.net/diff.php/pear/HTML_CSS/tests/testsuite.php?r1=1.3&r2=1.4&ty=u Index: pear/HTML_CSS/tests/testsuite.php diff -u pear/HTML_CSS/tests/testsuite.php:1.3 pear/HTML_CSS/tests/testsuite.php:1.4 --- pear/HTML_CSS/tests/testsuite.php:1.3 Sat Apr 10 11:24:18 2004 +++ pear/HTML_CSS/tests/testsuite.php Fri May 21 08:07:02 2004 @@ -3,7 +3,7 @@ /** * HTML output for PHPUnit suite tests. * - * @version $Id: testsuite.php,v 1.3 2004/04/10 15:24:18 farell Exp $ + * @version $Id: testsuite.php,v 1.4 2004/05/21 12:07:02 farell Exp $ * @author Laurent Laville <pear@laurent-laville.org> * @package HTML_CSS */ @@ -53,6 +53,11 @@ 'HTML_CSS_TestCase_removeGroupSelector', 'HTML_CSS_TestCase_getStyle', 'HTML_CSS_TestCase_setSameStyle', + 'HTML_CSS_TestCase_bug725', + 'HTML_CSS_TestCase_bug998', + 'HTML_CSS_TestCase_bug1066', + 'HTML_CSS_TestCase_bug1072', + 'HTML_CSS_TestCase_bug1084', ); $suite = new PHPUnit_TestSuite(); http://cvs.php.net/co.php/pear/HTML_CSS/tests/HTML_CSS_TestCase_bug1066.php?r=1.1&p=1 Index: pear/HTML_CSS/tests/HTML_CSS_TestCase_bug1066.php +++ pear/HTML_CSS/tests/HTML_CSS_TestCase_bug1066.php <?php /** * API Unit tests for HTML_CSS package. * * @version $Id: HTML_CSS_TestCase_bug1066.php,v 1.1 2004/05/21 12:07:02 farell Exp $ * @author Laurent Laville <pear@laurent-laville.org> * @package HTML_CSS */ class HTML_CSS_TestCase_bug1066 extends PHPUnit_TestCase { /** * A CSS object * @var object */ var $stylesheet; function HTML_CSS_TestCase_bug1066($name) { $this->PHPUnit_TestCase($name); } function setUp() { error_reporting(E_ALL & ~E_NOTICE); $logger['display_errors'] = 'off'; // don't use PEAR::Log display driver $logger['msgCallback'] = array(&$this, '_msgCallback'); // remove file&line context in error message $logger['pushCallback'] = array(&$this, '_pushCallback'); // don't die when an exception is thrown $attrs = array(); $this->stylesheet = new HTML_CSS($attrs, $logger); $strcss = ' html { display: block; /* 8 spaces after colon */ } '; $this->stylesheet->parseString($strcss); } function tearDown() { unset($this->stylesheet); } function _stripWhitespace($str) { return preg_replace('/\\s+/', '', $str); } function _methodExists($name) { if (substr(PHP_VERSION,0,1) < '5') { $n = strtolower($name); } else { $n = $name; } if (in_array($n, get_class_methods($this->stylesheet))) { return true; } $this->assertTrue(false, 'method '. $name . ' not implemented in ' . get_class($this->stylesheet)); return false; } function _msgCallback(&$stack, $err) { $message = call_user_func_array(array(&$stack, 'getErrorMessage'), array(&$stack, $err, '%__msg%')); return $message; } function _pushCallback($err) { // don't die if the error is an exception (as default callback) } function _getResult() { $s = &PEAR_ErrorStack::singleton('HTML_CSS'); if ($s->hasErrors()) { $err = $s->pop(); $this->assertTrue(false, $err['message']); } else { $this->assertTrue(true); } } function raiseError($code, $level, $params, $msg) { $err = PEAR_ErrorStack::staticPush($this->stylesheet->_package, $code, $level, $params, $msg, false, null); return $err; } /** * BUG#1066 Values are not trimmed * */ function test_bug1066() { if (!$this->_methodExists('toArray')) { return; } $css = $this->stylesheet->toArray(); if ($css['html']['display'] != 'block') { $this->raiseError(1066,'error', array(), 'parseString incorrectly reads attribute values with spaces after colon'); } $this->_getResult(); } } ?> http://cvs.php.net/co.php/pear/HTML_CSS/tests/HTML_CSS_TestCase_bug1072.php?r=1.1&p=1 Index: pear/HTML_CSS/tests/HTML_CSS_TestCase_bug1072.php +++ pear/HTML_CSS/tests/HTML_CSS_TestCase_bug1072.php <?php /** * API Unit tests for HTML_CSS package. * * @version $Id: HTML_CSS_TestCase_bug1072.php,v 1.1 2004/05/21 12:07:02 farell Exp $ * @author Laurent Laville <pear@laurent-laville.org> * @package HTML_CSS */ class HTML_CSS_TestCase_bug1072 extends PHPUnit_TestCase { /** * A CSS object * @var object */ var $stylesheet; function HTML_CSS_TestCase_bug1072($name) { $this->PHPUnit_TestCase($name); } function setUp() { error_reporting(E_ALL & ~E_NOTICE); $logger['display_errors'] = 'off'; // don't use PEAR::Log display driver $logger['msgCallback'] = array(&$this, '_msgCallback'); // remove file&line context in error message $logger['pushCallback'] = array(&$this, '_pushCallback'); // don't die when an exception is thrown $attrs = array(); $this->stylesheet = new HTML_CSS($attrs, $logger); $strcss = ' p { font-family: Arial; } p { font-family: Courier; } p, td { font-family: Times; } td p { font-family: Comic; } '; $this->stylesheet->parseString($strcss); } function tearDown() { unset($this->stylesheet); } function _stripWhitespace($str) { return preg_replace('/\\s+/', '', $str); } function _methodExists($name) { if (substr(PHP_VERSION,0,1) < '5') { $n = strtolower($name); } else { $n = $name; } if (in_array($n, get_class_methods($this->stylesheet))) { return true; } $this->assertTrue(false, 'method '. $name . ' not implemented in ' . get_class($this->stylesheet)); return false; } function _msgCallback(&$stack, $err) { $message = call_user_func_array(array(&$stack, 'getErrorMessage'), array(&$stack, $err, '%__msg%')); return $message; } function _pushCallback($err) { // don't die if the error is an exception (as default callback) } function _getResult() { $s = &PEAR_ErrorStack::singleton('HTML_CSS'); if ($s->hasErrors()) { $err = $s->pop(); $this->assertTrue(false, $err['message']); } else { $this->assertTrue(true); } } function raiseError($code, $level, $params, $msg) { $err = PEAR_ErrorStack::staticPush($this->stylesheet->_package, $code, $level, $params, $msg, false, null); return $err; } /** * BUG#1072 HTML_CSS Not cascading properties * */ function test_bug1072() { if (!$this->_methodExists('getStyle')) { return; } $font = $this->stylesheet->getStyle('p', 'font-family'); if ($font != 'Times') { $this->raiseError(1072,'error', array(), 'HTML_CSS is not cascading style when a "selector" is part of a group'); } $this->_getResult(); } } ?> http://cvs.php.net/co.php/pear/HTML_CSS/tests/HTML_CSS_TestCase_bug1084.php?r=1.1&p=1 Index: pear/HTML_CSS/tests/HTML_CSS_TestCase_bug1084.php +++ pear/HTML_CSS/tests/HTML_CSS_TestCase_bug1084.php <?php /** * API Unit tests for HTML_CSS package. * * @version $Id: HTML_CSS_TestCase_bug1084.php,v 1.1 2004/05/21 12:07:02 farell Exp $ * @author Laurent Laville <pear@laurent-laville.org> * @package HTML_CSS */ class HTML_CSS_TestCase_bug1084 extends PHPUnit_TestCase { /** * A CSS object * @var object */ var $stylesheet; function HTML_CSS_TestCase_bug1084($name) { $this->PHPUnit_TestCase($name); } function setUp() { error_reporting(E_ALL & ~E_NOTICE); $logger['display_errors'] = 'off'; // don't use PEAR::Log display driver $logger['msgCallback'] = array(&$this, '_msgCallback'); // remove file&line context in error message $logger['pushCallback'] = array(&$this, '_pushCallback'); // don't die when an exception is thrown $attrs = array(); $this->stylesheet = new HTML_CSS($attrs, $logger); } function tearDown() { unset($this->stylesheet); } function _stripWhitespace($str) { return preg_replace('/\\s+/', '', $str); } function _methodExists($name) { if (substr(PHP_VERSION,0,1) < '5') { $n = strtolower($name); } else { $n = $name; } if (in_array($n, get_class_methods($this->stylesheet))) { return true; } $this->assertTrue(false, 'method '. $name . ' not implemented in ' . get_class($this->stylesheet)); return false; } function _msgCallback(&$stack, $err) { $message = call_user_func_array(array(&$stack, 'getErrorMessage'), array(&$stack, $err, '%__msg%')); return $message; } function _pushCallback($err) { // don't die if the error is an exception (as default callback) } function _getResult() { $s = &PEAR_ErrorStack::singleton('HTML_CSS'); if ($s->hasErrors()) { $err = $s->pop(); $this->assertTrue(false, $err['message']); } else { $this->assertTrue(true); } } function raiseError($code, $level, $params, $msg) { $err = PEAR_ErrorStack::staticPush($this->stylesheet->_package, $code, $level, $params, $msg, false, null); return $err; } /** * BUG#1084 parseSelectors incorrectly assumes selector structure * */ function test_bug1084() { if (!$this->_methodExists('parseSelectors')) { return; } $sa = '#heading .shortname'; $a = $this->stylesheet->parseSelectors($sa); if ($a != $sa) { $this->raiseError(1084,'error', array('selector' => $sa), 'parseSelectors incorrectly assumes selector structure "%selector%"'); } $this->_getResult(); $sb = '#heading .icon'; $b = $this->stylesheet->parseSelectors($sb); if ($b != $sb) { $this->raiseError(1084,'error', array('selector' => $sb), 'parseSelectors incorrectly assumes selector structure "%selector%"'); } $this->_getResult(); $sc = '#heading .icon img'; $c = $this->stylesheet->parseSelectors($sc); if ($c != $sc) { $this->raiseError(1084,'error', array('selector' => $sc), 'parseSelectors incorrectly assumes selector structure "%selector%"'); } $this->_getResult(); } } ?> http://cvs.php.net/co.php/pear/HTML_CSS/tests/HTML_CSS_TestCase_bug725.php?r=1.1&p=1 Index: pear/HTML_CSS/tests/HTML_CSS_TestCase_bug725.php +++ pear/HTML_CSS/tests/HTML_CSS_TestCase_bug725.php <?php /** * API Unit tests for HTML_CSS package. * * @version $Id: HTML_CSS_TestCase_bug725.php,v 1.1 2004/05/21 12:07:02 farell Exp $ * @author Laurent Laville <pear@laurent-laville.org> * @package HTML_CSS */ class HTML_CSS_TestCase_bug725 extends PHPUnit_TestCase { /** * A CSS object * @var object */ var $stylesheet; function HTML_CSS_TestCase_bug725($name) { $this->PHPUnit_TestCase($name); } function setUp() { error_reporting(E_ALL & ~E_NOTICE); $logger['display_errors'] = 'off'; // don't use PEAR::Log display driver $logger['msgCallback'] = array(&$this, '_msgCallback'); // remove file&line context in error message $logger['pushCallback'] = array(&$this, '_pushCallback'); // don't die when an exception is thrown $attrs = array(); $this->stylesheet = new HTML_CSS($attrs, $logger); $strcss = " body td { /* 3 spaces between body and td */ margin: 20px; padding: 20px; border: 0; color: #444; }"; $this->stylesheet->parseString($strcss); } function tearDown() { unset($this->stylesheet); } function _stripWhitespace($str) { return preg_replace('/\\s+/', '', $str); } function _methodExists($name) { if (substr(PHP_VERSION,0,1) < '5') { $n = strtolower($name); } else { $n = $name; } if (in_array($n, get_class_methods($this->stylesheet))) { return true; } $this->assertTrue(false, 'method '. $name . ' not implemented in ' . get_class($this->stylesheet)); return false; } function _msgCallback(&$stack, $err) { $message = call_user_func_array(array(&$stack, 'getErrorMessage'), array(&$stack, $err, '%__msg%')); return $message; } function _pushCallback($err) { // don't die if the error is an exception (as default callback) } function _getResult() { $s = &PEAR_ErrorStack::singleton('HTML_CSS'); if ($s->hasErrors()) { $err = $s->pop(); $this->assertTrue(false, $err['message']); } else { $this->assertTrue(true); } } function raiseError($code, $level, $params, $msg) { $err = PEAR_ErrorStack::staticPush($this->stylesheet->_package, $code, $level, $params, $msg, false, null); return $err; } /** * BUG#725 differs hierarchy elements with difference in spaces between * * - setStyle should change the "body td" not add an other one */ function test_bug725() { if (!$this->_methodExists('setStyle')) { return; } if (!$this->_methodExists('toArray')) { return; } $style = 'body td '; $this->stylesheet->setStyle($style,'margin',0); $css = $this->stylesheet->toArray(); if (count($css) > 1) { $this->raiseError(725,'error', array('selector' => $style), 'setStyle should change the "%selector%" not add an other one'); } $this->_getResult(); } } ?> http://cvs.php.net/co.php/pear/HTML_CSS/tests/HTML_CSS_TestCase_bug998.php?r=1.1&p=1 Index: pear/HTML_CSS/tests/HTML_CSS_TestCase_bug998.php +++ pear/HTML_CSS/tests/HTML_CSS_TestCase_bug998.php <?php /** * API Unit tests for HTML_CSS package. * * @version $Id: HTML_CSS_TestCase_bug998.php,v 1.1 2004/05/21 12:07:02 farell Exp $ * @author Laurent Laville <pear@laurent-laville.org> * @package HTML_CSS */ class HTML_CSS_TestCase_bug998 extends PHPUnit_TestCase { /** * A CSS object * @var object */ var $stylesheet; function HTML_CSS_TestCase_bug998($name) { $this->PHPUnit_TestCase($name); } function setUp() { error_reporting(E_ALL & ~E_NOTICE); $logger['display_errors'] = 'off'; // don't use PEAR::Log display driver $logger['msgCallback'] = array(&$this, '_msgCallback'); // remove file&line context in error message $logger['pushCallback'] = array(&$this, '_pushCallback'); // don't die when an exception is thrown $attrs = array(); $this->stylesheet = new HTML_CSS($attrs, $logger); $strcss = ' sec { display: none; } month:before { content: "-"; } year:before { content: "-"; } min:before { content: ":"; } sec:before { content: ":"; } '; $this->stylesheet->parseString($strcss); } function tearDown() { unset($this->stylesheet); } function _stripWhitespace($str) { return preg_replace('/\\s+/', '', $str); } function _methodExists($name) { if (substr(PHP_VERSION,0,1) < '5') { $n = strtolower($name); } else { $n = $name; } if (in_array($n, get_class_methods($this->stylesheet))) { return true; } $this->assertTrue(false, 'method '. $name . ' not implemented in ' . get_class($this->stylesheet)); return false; } function _msgCallback(&$stack, $err) { $message = call_user_func_array(array(&$stack, 'getErrorMessage'), array(&$stack, $err, '%__msg%')); return $message; } function _pushCallback($err) { // don't die if the error is an exception (as default callback) } function _getResult() { $s = &PEAR_ErrorStack::singleton('HTML_CSS'); if ($s->hasErrors()) { $err = $s->pop(); $this->assertTrue(false, $err['message']); } else { $this->assertTrue(true); } } function raiseError($code, $level, $params, $msg) { $err = PEAR_ErrorStack::staticPush($this->stylesheet->_package, $code, $level, $params, $msg, false, null); return $err; } /** * BUG#998 parseString incorrectly reads attribute values with colons in * * When parsing in some CSS like: * * .sec { display: none; } * .month:before { content: "-"; } * .year:before { content: "-"; } * .min:before { content: ":"; } * .sec:before { content: ":"; } * * the resulting array should be: * * [.sec] => Array ( [display] => none ) * [.month:before] => Array ( [content] => "-" ) * [.year:before] => Array ( [content] => "-" ) * [.min:before] => Array ( [content] => ":" ) * [.sec:before] => Array ( [content] => ":" ) */ function test_bug998() { if (!$this->_methodExists('toArray')) { return; } $css = $this->stylesheet->toArray(); if ($css['.min:before']['content'] != '":"') { $this->raiseError(998,'error', array(), 'parseString incorrectly reads attribute values with colons in'); } $this->_getResult(); } } ?>
« previous php.pear.cvs (#19731) next »