예제 #1
0
<?php

/**
 * PhpCss Demo: Scan CSS Selector with comments
 * 
 * This Demo loads a CSS Selector with comments into the Scanner
 * 
 */
/* Setup Demo Environment */
require_once 'inc/setup.php';
print "PhpCss Demo: CSS Selector with Comments\n\n";
$css = 'body/* comment */ .class';
printf("CSS Selector '%s' (%d)\n", $css, strlen($css));
$tokens = array();
$status = new PhpCssScannerStatusComment();
$status = new PhpCssScannerStatusSelector();
$scanner = new PhpCssScanner($status);
$offset = $scanner->scan($tokens, $css);
printf("Tokens: %d; Offset: %d\n", count($tokens), $offset);
$i = 0;
foreach ($tokens as $token) {
    printf(" #%d: %s\n", ++$i, $token);
}
예제 #2
0
 /**
  * This is more an integration test, but it fits in here....
  * @covers stdClass
  * @dataProvider selectorsDataProvider
  */
 public function testScannerWithSelectors($string, $expected)
 {
     $scanner = new PhpCssScanner(new PhpCssScannerStatusSelector());
     $tokens = array();
     $scanner->scan($tokens, $string);
     $this->assertTokenListEqualsStringList($expected, $tokens);
 }