class JsCollectionOptimizerTest in Flysystem 8
@coversDefaultClass \Drupal\flysystem\Asset\JsCollectionOptimizer @group flysystem
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\flysystem\Unit\Asset\JsCollectionOptimizerTest
 
 
Expanded class hierarchy of JsCollectionOptimizerTest
File
- tests/
src/ Unit/ Asset/ JsCollectionOptimizerTest.php, line 20  
Namespace
Drupal\Tests\flysystem\Unit\AssetView source
class JsCollectionOptimizerTest extends UnitTestCase {
  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp();
    if (!defined('REQUEST_TIME')) {
      define('REQUEST_TIME', time());
    }
    vfsStream::setup('flysystem');
    if (file_exists('vfs://flysystem/test.js')) {
      unlink('vfs://flysystem/test.js');
    }
  }
  /**
   * {@inheritdoc}
   */
  public function tearDown() {
    if (file_exists('vfs://flysystem/test.js')) {
      unlink('vfs://flysystem/test.js');
    }
    parent::tearDown();
  }
  /**
   * @covers \Drupal\flysystem\Asset\JsCollectionOptimizer
   * @covers \Drupal\flysystem\Asset\CssCollectionOptimizer
   */
  public function test() {
    file_put_contents('vfs://flysystem/test.js', 'asdfasdf');
    touch('vfs://flysystem/test.js', REQUEST_TIME - 1000);
    $container = new ContainerBuilder();
    $container
      ->set('config.factory', $this
      ->getConfigFactoryStub([
      'system.performance' => [
        'stale_file_threshold' => 0,
      ],
    ]));
    \Drupal::setContainer($container);
    $grouper = $this
      ->prophesize(AssetCollectionGrouperInterface::class);
    $dumper = new AssetDumper();
    $state = $this
      ->getMock(StateInterface::class);
    $optimizer = new JsCollectionOptimizer($grouper
      ->reveal(), new JsOptimizer(), $dumper, $state);
    $optimizer
      ->deleteAll();
    $this
      ->assertFalse(file_exists('vfs://flysystem/test.js'));
    file_put_contents('vfs://flysystem/test.js', 'asdfasdf');
    touch('vfs://flysystem/test.js', REQUEST_TIME - 1000);
    $optimizer = new CssCollectionOptimizer($grouper
      ->reveal(), new CssOptimizer(), $dumper, $state);
    $optimizer
      ->deleteAll();
    $this
      ->assertFalse(file_exists('vfs://flysystem/test.js'));
  }
}Members
| 
            Name | 
                  Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| 
            JsCollectionOptimizerTest:: | 
                  public | function | 
            Overrides UnitTestCase:: | 
                  |
| 
            JsCollectionOptimizerTest:: | 
                  public | function | ||
| 
            JsCollectionOptimizerTest:: | 
                  public | function | @covers \Drupal\flysystem\Asset\JsCollectionOptimizer @covers \Drupal\flysystem\Asset\CssCollectionOptimizer | |
| 
            PhpunitCompatibilityTrait:: | 
                  public | function | Returns a mock object for the specified class using the available method. | |
| 
            PhpunitCompatibilityTrait:: | 
                  public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
| 
            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 | Mocks a block with a block plugin. | 1 | 
| 
            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. |