PHP Classes

File: tests/CssManagerTest.php

Recommend this page to a friend!
  Classes of Daniel Takahashi   PHP CSS manager   tests/CssManagerTest.php   Download  
File: tests/CssManagerTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: PHP CSS manager
Parse and regenerate CSS stylesheets from arrays
Author: By
Last change:
Date: 9 years ago
Size: 1,513 bytes
 

Contents

Class file image Download
<?php

namespace danielarbex\tests;

use
danielarbex\CssManager;
use
PHPUnit_Framework_TestCase;

class
CssManagerTest extends PHPUnit_Framework_TestCase
{
    public function
testLoadCss()
    {
       
$cssManager = new CssManager();

       
$cssContent = file_get_contents(__DIR__ . '/css/css.css');
       
$cssManager->loadCss($cssContent);

       
$this->assertNotEmpty($cssManager->css);
    }

    public function
testCssToArray()
    {
       
$cssManager = new CssManager();

       
$cssContent = file_get_contents(__DIR__ . '/css/css.css');
       
$cssManager->loadCss($cssContent)
                   ->
cssToArray();

       
$this->assertArraySubset(['width' => ' 100%'], $cssManager->parsed['main']['.class_name']);
    }

    public function
testChangeProperty()
    {
       
$cssManager = new CssManager();

       
$cssContent = file_get_contents(__DIR__ . '/css/css.css');
       
$cssManager->loadCss($cssContent)
                   ->
cssToArray();

       
$cssManager->parsed['main']['.class_name']['float'] = ' left';

       
$this->assertArraySubset(['width' => ' 100%', 'float' => ' left'], $cssManager->parsed['main']['.class_name']);
    }

    public function
testArrayToCss()
    {
       
$cssManager = new CssManager();

       
$cssContent = file_get_contents(__DIR__ . '/css/css.css');
       
$actual = $cssManager->loadCss($cssContent)
                             ->
cssToArray()
                             ->
arrayToCss();

       
$this->assertNotEmpty($actual);
    }
}