You are here

public function FileTest::testFile_deleteChunks in One Click Upload 7.2

* @covers ::deleteChunks

File

flowphp/test/Unit/FileTest.php, line 204

Class

FileTest
File unit tests

Namespace

Unit

Code

public function testFile_deleteChunks() {

  //// Setup test
  $this->requestArr['flowTotalChunks'] = 4;
  $fileInfo = new \ArrayObject();
  $request = new Request($this->requestArr, $fileInfo);
  $file = new File($this->config, $request);
  $chunkPrefix = sha1($request
    ->getIdentifier()) . '_';
  $firstChunk = vfsStream::newFile($chunkPrefix . 1);
  $this->vfs
    ->addChild($firstChunk);
  $secondChunk = vfsStream::newFile($chunkPrefix . 3);
  $this->vfs
    ->addChild($secondChunk);
  $thirdChunk = vfsStream::newFile('other');
  $this->vfs
    ->addChild($thirdChunk);

  //// Actual test
  $this
    ->assertTrue(file_exists($firstChunk
    ->url()));
  $this
    ->assertTrue(file_exists($secondChunk
    ->url()));
  $this
    ->assertTrue(file_exists($thirdChunk
    ->url()));
  $file
    ->deleteChunks();
  $this
    ->assertFalse(file_exists($firstChunk
    ->url()));
  $this
    ->assertFalse(file_exists($secondChunk
    ->url()));
  $this
    ->assertTrue(file_exists($thirdChunk
    ->url()));
}