cvs: pear /HTML_CSS/tests HTML_CSS_TestSuite_Standard.php
| From: | Laurent Laville | Date: | Sun, 13 Jan 2008 17:01:15 +0000 |
| Subject: | cvs: pear /HTML_CSS/tests HTML_CSS_TestSuite_Standard.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-50283@lists.php.net to get a copy of this message | ||
farell Sun Jan 13 17:01:15 2008 UTC
Modified files:
/pear/HTML_CSS/tests HTML_CSS_TestSuite_Standard.php
Log:
complete UnitTests with At-Rules API functions
http://cvs.php.net/viewvc.cgi/pear/HTML_CSS/tests/HTML_CSS_TestSuite_Standard.php?r1=1.7&r2=1.8&diff_format=u
Index: pear/HTML_CSS/tests/HTML_CSS_TestSuite_Standard.php
diff -u pear/HTML_CSS/tests/HTML_CSS_TestSuite_Standard.php:1.7
pear/HTML_CSS/tests/HTML_CSS_TestSuite_Standard.php:1.8
--- pear/HTML_CSS/tests/HTML_CSS_TestSuite_Standard.php:1.7 Tue Jan 1 15:48:59 2008
+++ pear/HTML_CSS/tests/HTML_CSS_TestSuite_Standard.php Sun Jan 13 17:01:15 2008
@@ -8,7 +8,7 @@
* @package HTML_CSS
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.opensource.org/licenses/bsd-license.php
BSD
- * @version CVS: $Id: HTML_CSS_TestSuite_Standard.php,v 1.7 2008/01/01 15:48:59 farell Exp $
+ * @version CVS: $Id: HTML_CSS_TestSuite_Standard.php,v 1.8 2008/01/13 17:01:15 farell Exp $
* @link http://pear.php.net/package/HTML_CSS
* @since File available since Release 1.4.0
*/
@@ -817,7 +817,187 @@
// find all selectors that set the color property
$style2 = $this->css->grepStyle('/./', '/^color$/');
$this->assertSame($gs, $style2, 'search for pattern 2 does not match');
+ }
+
+ /**
+ * Tests building/removing CSS simple At-Rule
+ * "@charset, @import and @namespace"
+ *
+ * @return void
+ */
+ public function testSimpleAtRule()
+ {
+ $this->css->setStyle('html', 'height', '100%');
+
+ $e = $this->css->createAtRule('@charset', '"UTF-8"');
+ $msg = PEAR::isError($e) ? $e->getMessage() : null;
+ $this->assertFalse(PEAR::isError($e), $msg);
+
+ $e = $this->css->createAtRule('@import', 'url("foo.css")
screen, print');
+ $msg = PEAR::isError($e) ? $e->getMessage() : null;
+ $this->assertFalse(PEAR::isError($e), $msg);
+
+ $e = $this->css->createAtRule('@namespace',
+ 'foo url("http://www.example.com/")');
+ $msg = PEAR::isError($e) ? $e->getMessage() : null;
+ $this->assertFalse(PEAR::isError($e), $msg);
+
+ $gs = array('@charset' =>
+ array('"UTF-8"' => ''),
+ '@import' =>
+ array('url("foo.css") screen, print' => ''),
+ '@namespace' =>
+ array('foo url("http://www.example.com/")' => ''),
+ 'html' =>
+ array('height' => '100%'));
+ $def = $this->css->toArray();
+ $this->assertSame($gs, $def, 'array output does not match');
+ $e = $this->css->unsetAtRule('@CharSet');
+ $msg = PEAR::isError($e) ? $e->getMessage() : null;
+ $this->assertFalse(PEAR::isError($e), $msg);
+
+ unset($gs['@charset']);
+ $def = $this->css->toArray();
+ $this->assertSame($gs, $def, 'array clean does not match');
+ }
+
+ /**
+ * Tests conditional/informative At-Rules
+ * "@media, @page, @font-face"
+ *
+ * @return void
+ */
+ public function testAtRuleStyle()
+ {
+ $this->css->setStyle('html', 'height', '100%');
+
+ $e = $this->css->setAtRuleStyle('@media',
+ 'screen', '', 'color', 'green');
+ $msg = PEAR::isError($e) ? $e->getMessage() : null;
+ $this->assertFalse(PEAR::isError($e), $msg);
+
+ $e = $this->css->setAtRuleStyle('@media',
+ 'screen', '', 'background-color',
'yellow');
+ $msg = PEAR::isError($e) ? $e->getMessage() : null;
+ $this->assertFalse(PEAR::isError($e), $msg);
+
+ $e = $this->css->setAtRuleStyle('@media',
+ 'print', 'blockquote', 'font-size',
'16pt');
+ $msg = PEAR::isError($e) ? $e->getMessage() : null;
+ $this->assertFalse(PEAR::isError($e), $msg);
+
+ $e = $this->css->setAtRuleStyle('@page',
+ ':first', '', 'size', '3in 8in');
+ $msg = PEAR::isError($e) ? $e->getMessage() : null;
+ $this->assertFalse(PEAR::isError($e), $msg);
+
+ $e = $this->css->setAtRuleStyle('@font-face',
+ '', '', 'font-family', 'dreamy');
+ $msg = PEAR::isError($e) ? $e->getMessage() : null;
+ $this->assertFalse(PEAR::isError($e), $msg);
+
+ $e = $this->css->setAtRuleStyle('@font-face',
+ '', '', 'font-weight', 'bold');
+ $msg = PEAR::isError($e) ? $e->getMessage() : null;
+ $this->assertFalse(PEAR::isError($e), $msg);
+
+ $e = $this->css->setAtRuleStyle('@font-face',
+ '', '', 'src',
'url(http://www.example.com/font.eot)');
+ $msg = PEAR::isError($e) ? $e->getMessage() : null;
+ $this->assertFalse(PEAR::isError($e), $msg);
+
+ $gs = array('@media' => array(
+ 'screen' => array(
+ '' => array('color' => 'green',
+ 'background-color' => 'yellow'),
+ ),
+ 'print' => array(
+ 'blockquote' => array('font-size' =>
'16pt'),
+ )
+ ),
+ '@page' => array(
+ ':first' => array(
+ '' => array('size' => '3in 8in'),
+ )
+ ),
+ '@font-face' => array(
+ '' => array(
+ '' => array('font-family' => 'dreamy',
+ 'font-weight' => 'bold',
+ 'src' =>
'url(http://www.example.com/font.eot)')
+ )
+ ),
+ 'html' => array('height' => '100%'));
+ $def = $this->css->toArray();
+ $this->assertSame($gs, $def, 'array does not match');
+ }
+
+ /**
+ * Tests parsing CSS string that contains At-Rules
+ *
+ * @return void
+ */
+ public function testParseAtRuleString()
+ {
+ $strcss = <<<EOD
+@media screen { color: green; background-color: yellow; }
+@media print {
+ blockquote { font-size: 16pt; font-weight: bold; }
+}
+html { height: 100%; }
+@page thin:first { size: 3in 8in }
+@font-face {
+ font-family: dreamy;
+ font-weight: bold;
+ src: url(http://www.example.com/font.eot);
+}
+EOD;
+
+ $e = $this->css->parseString($strcss);
+ $msg = PEAR::isError($e) ? $e->getMessage() : null;
+ $this->assertFalse(PEAR::isError($e), $msg);
+
+ $gs = array('@media' => array(
+ 'screen' => array(
+ '' => array('color' => 'green',
+ 'background-color' => 'yellow'),
+ ),
+ 'print' => array(
+ 'blockquote' => array('font-size' =>
'16pt',
+ 'font-weight' => 'bold'),
+ )
+ ),
+ '@page' => array(
+ 'thin:first' => array(
+ '' => array('size' => '3in 8in'),
+ )
+ ),
+ '@font-face' => array(
+ '' => array(
+ '' => array('font-family' => 'dreamy',
+ 'font-weight' => 'bold',
+ 'src' =>
'url(http://www.example.com/font.eot)')
+ )
+ ),
+ 'html' => array('height' => '100%'));
+ $def = $this->css->toArray();
+ $this->assertSame($gs, $def, 'array does not match');
+ }
+
+ /**
+ * Tests list of supported At-Rules by API 1.5.0
+ *
+ * @return void
+ */
+ public function testGetAtRulesList()
+ {
+ $expected = array('@charset', '@font-face',
+ '@import', '@media', '@page',
'@namespace');
+ $atRules = $this->css->getAtRulesList();
+ sort($atRules);
+ sort($expected);
+ $this->assertSame($atRules, $expected, 'unexpected At-Rules list');
}
}