You are here

public function FileTest::testFile_save_preProcess in One Click Upload 7.2

* @covers ::save

File

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

Class

FileTest
File unit tests

Namespace

Unit

Code

public function testFile_save_preProcess() {

  //// Setup test
  $this->requestArr['flowTotalChunks'] = 1;
  $this->requestArr['flowTotalSize'] = 10;
  $processCalled = false;
  $process = function ($chunk) use (&$processCalled) {
    $processCalled = true;
  };
  $this->config
    ->setPreprocessCallback($process);
  $request = new Request($this->requestArr);
  $file = new File($this->config, $request);
  $chunkPrefix = sha1($request
    ->getIdentifier()) . '_';
  $chunk = vfsStream::newFile($chunkPrefix . '1', 0777);
  $chunk
    ->setContent('1234567890');
  $this->vfs
    ->addChild($chunk);
  $filePath = $this->vfs
    ->url() . DIRECTORY_SEPARATOR . 'file';

  //// Actual test
  $this
    ->assertTrue($file
    ->save($filePath));
  $this
    ->assertTrue(file_exists($filePath));
  $this
    ->assertEquals($request
    ->getTotalSize(), filesize($filePath));
  $this
    ->assertTrue($processCalled);
}