@@ -472,26 +472,63 @@ function testTrailingWhitespace() {
472
472
}
473
473
474
474
/**
475
- * @expectedException Sabberworm\CSS\Parsing\UnexpectedTokenException
476
- */
475
+ * @expectedException \ Sabberworm\CSS\Parsing\UnexpectedTokenException
476
+ */
477
477
function testCharsetFailure1 () {
478
478
$ this ->parsedStructureForFile ('-charset-after-rule ' , Settings::create ()->withLenientParsing (false ));
479
479
}
480
480
481
481
/**
482
- * @expectedException Sabberworm\CSS\Parsing\UnexpectedTokenException
483
- */
482
+ * @expectedException \ Sabberworm\CSS\Parsing\UnexpectedTokenException
483
+ */
484
484
function testCharsetFailure2 () {
485
485
$ this ->parsedStructureForFile ('-charset-in-block ' , Settings::create ()->withLenientParsing (false ));
486
486
}
487
487
488
488
/**
489
- * @expectedException Sabberworm\CSS\Parsing\SourceException
490
- */
489
+ * @expectedException \ Sabberworm\CSS\Parsing\SourceException
490
+ */
491
491
function testUnopenedClosingBracketFailure () {
492
492
$ this ->parsedStructureForFile ('unopened-close-brackets ' , Settings::create ()->withLenientParsing (false ));
493
493
}
494
494
495
+ /**
496
+ * Ensure that a missing property value raises an exception.
497
+ *
498
+ * @expectedException \Sabberworm\CSS\Parsing\UnexpectedTokenException
499
+ * @covers \Sabberworm\CSS\Value\Value::parseValue()
500
+ */
501
+ function testMissingPropertyValueStrict () {
502
+ $ this ->parsedStructureForFile ('missing-property-value ' , Settings::create ()->withLenientParsing (false ));
503
+ }
504
+
505
+ /**
506
+ * Ensure that a missing property value is ignored when in lenient parsing mode.
507
+ *
508
+ * @covers \Sabberworm\CSS\Value\Value::parseValue()
509
+ */
510
+ function testMissingPropertyValueLenient () {
511
+ $ parsed = $ this ->parsedStructureForFile ('missing-property-value ' , Settings::create ()->withLenientParsing (true ));
512
+ $ rulesets = $ parsed ->getAllRuleSets ();
513
+ $ this ->assertCount ( 1 , $ rulesets );
514
+ $ block = $ rulesets [0 ];
515
+ $ this ->assertTrue ( $ block instanceof DeclarationBlock );
516
+ $ this ->assertEquals ( array ( 'div ' ), $ block ->getSelectors () );
517
+ $ rules = $ block ->getRules ();
518
+ $ this ->assertCount ( 1 , $ rules );
519
+ $ rule = $ rules [0 ];
520
+ $ this ->assertEquals ( 'display ' , $ rule ->getRule () );
521
+ $ this ->assertEquals ( 'inline-block ' , $ rule ->getValue () );
522
+ }
523
+
524
+ /**
525
+ * Parse structure for file.
526
+ *
527
+ * @param string $sFileName Filename.
528
+ * @param null|obJeCt $oSettings Settings.
529
+ *
530
+ * @return CSSList\Document Parsed document.
531
+ */
495
532
function parsedStructureForFile ($ sFileName , $ oSettings = null ) {
496
533
$ sFile = dirname (__FILE__ ) . '/../../files ' . DIRECTORY_SEPARATOR . "$ sFileName.css " ;
497
534
$ oParser = new Parser (file_get_contents ($ sFile ), $ oSettings );
0 commit comments