class S3fsCssOptimizerTest in S3 File System 4.0.x
Same name and namespace in other branches
- 8.3 tests/src/Unit/S3fsCssOptimizerTest.php \Drupal\Tests\s3fs\Unit\S3fsCssOptimizerTest
Tests the S3fsCssOptimizer.
@group s3fs
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, PhpUnitCompatibilityTrait, PhpUnitWarnings
- class \Drupal\Tests\s3fs\Unit\S3fsCssOptimizerTest
Expanded class hierarchy of S3fsCssOptimizerTest
File
- tests/
src/ Unit/ S3fsCssOptimizerTest.php, line 15
Namespace
Drupal\Tests\s3fs\UnitView source
class S3fsCssOptimizerTest extends UnitTestCase {
/**
* Test general asset link re-writing.
*/
public function testRewriteUri() {
$configFactory = $this
->getConfigFactoryStub([
's3fs.settings' => [
'use_https' => FALSE,
'use_cssjs_host' => FALSE,
'cssjs_host' => '',
],
]);
$cssOptimizer = new S3fsCssOptimizer($configFactory);
$cssOptimizer->rewriteFileURIBasePath = '';
$this
->assertEquals('url(//www.example.org/test/file.txt)', $cssOptimizer
->rewriteFileURI([
'',
'/test/file.txt',
]));
$this
->assertEquals('url(//www.example.org/test/file.txt)', $cssOptimizer
->rewriteFileURI([
'',
'/core/../test/file.txt',
]));
$this
->assertEquals('url(//www.example.org/test/file.txt)', $cssOptimizer
->rewriteFileURI([
'',
'/core/data/../../test/file.txt',
]));
}
/**
* Test asset links generated using HTTPS://.
*/
public function testRewriteUriAlwaysHttps() {
$configFactory = $this
->getConfigFactoryStub([
's3fs.settings' => [
'use_https' => TRUE,
'use_cssjs_host' => FALSE,
'cssjs_host' => '',
],
]);
$cssOptimizer = new S3fsCssOptimizer($configFactory);
$cssOptimizer->rewriteFileURIBasePath = '';
$this
->assertEquals('url(https://www.example.org/test/file.txt)', $cssOptimizer
->rewriteFileURI([
'',
'/test/file.txt',
]));
}
/**
* Test asset links with custom host.
*/
public function testRewriteUriCustomCssHost() {
$configFactory = $this
->getConfigFactoryStub([
's3fs.settings' => [
'use_https' => FALSE,
'use_cssjs_host' => TRUE,
'cssjs_host' => 'test.example.org',
],
]);
$cssOptimizer = new S3fsCssOptimizer($configFactory);
$cssOptimizer->rewriteFileURIBasePath = '';
$this
->assertEquals('url(//test.example.org/test/file.txt)', $cssOptimizer
->rewriteFileURI([
'',
'/test/file.txt',
]));
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PhpUnitWarnings:: |
private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | |
PhpUnitWarnings:: |
public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | |
S3fsCssOptimizerTest:: |
public | function | Test general asset link re-writing. | |
S3fsCssOptimizerTest:: |
public | function | Test asset links generated using HTTPS://. | |
S3fsCssOptimizerTest:: |
public | function | Test asset links with custom host. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
UnitTestCase:: |
protected | function | 308 | |
UnitTestCase:: |
public static | function |