public function testProcess() { $cacheDir = self::$kernel->getContainer()->getParameter('kernel.cache_dir'); $tempDir = sprintf('%s/uploads', $cacheDir); $sourcePath = sprintf('%s/../Resources/upload/test.txt', __DIR__); $this->assertFileExists($sourcePath); $handler = new UploadHandler($tempDir); $upload = new UploadEntity(); $upload->setFile(new File($sourcePath)); $handler->process($upload); $this->assertNull($upload->getFile()); $this->assertNotNull($upload->getRelPath()); $path = sprintf('%s/%s', $tempDir, $upload->getRelPath()); $this->assertFileExists($path); $this->assertRegExp('/^uploads\\/foo\\/bar\\/test_[0-9a-z]{7}\\.txt$/', $upload->getRelPath()); }
/** * @param object $object */ protected function handleObjectPre($object) { if ($object instanceof UploadInterface) { $this->uploadHandler->process($object); } }