/** * Tests the compressor can output compressed HTML * * @param string $html The HTML string to test * * @dataProvider validHtmlProvider */ public function testCompressorCanRenderCompressedHtml($html) { Compressor::enable(); $compressor = new Compressor($html); ob_start(); $compressor->render(); $output = ob_get_clean(); $regexp = '#^<script src="/js/compressor/[0-9a-z]{24,25}_[0-9a-z]{24,25}.js"></script><link href="/css/compressor/[0-9a-z]{24,25}_[0-9a-z]{24,25}.css" rel="stylesheet">$#'; $this->assertRegExp($regexp, $output); }
<?php require_once '../vendor/autoload.php'; use RelishMedia\Compressor; // Change this to your web server root define('COMPRESSOR_ROOT', dirname(dirname(__DIR__))); // Path to assets dir, relative to `COMPRESSOR_ROOT` define('COMPRESSOR_URL', '/compressor/examples/'); ?> <head> <?php Compressor::start(); ?> <link rel="stylesheet" href="/compressor/examples/css/file1.css"> <link rel="stylesheet" href="/compressor/examples/css/file2.css"> <script src="/compressor/examples/js/file1.js"></script> <script src="/compressor/examples/js/file2.js"></script> <?php Compressor::stop(); ?> </head>