You are here

public function UploaderTest::testUploader_pruneChunks in One Click Upload 7.2

* @covers ::pruneChunks

File

flowphp/test/Unit/UploaderTest.php, line 38

Class

UploaderTest
Uploader unit tests

Namespace

Unit

Code

public function testUploader_pruneChunks() {

  //// Setup test
  $newDir = vfsStream::newDirectory('1');
  $newDir
    ->lastModified(time() - 31);
  $newDir
    ->lastModified(time());
  $fileFirst = vfsStream::newFile('file31');
  $fileFirst
    ->lastModified(time() - 31);
  $fileSecond = vfsStream::newFile('random_file');
  $fileSecond
    ->lastModified(time() - 30);
  $upDir = vfsStream::newFile('..');
  $this->vfs
    ->addChild($newDir);
  $this->vfs
    ->addChild($fileFirst);
  $this->vfs
    ->addChild($fileSecond);
  $this->vfs
    ->addChild($upDir);

  //// Actual test
  Uploader::pruneChunks($this->vfs
    ->url(), 30);
  $this
    ->assertTrue(file_exists($newDir
    ->url()));
  $this
    ->assertFalse(file_exists($fileFirst
    ->url()));
  $this
    ->assertTrue(file_exists($fileSecond
    ->url()));
}