/** * @depends testDelete * @depends testCreateFromFile */ public function testRetrieve() { $manager = new FileSystemFileManager(); $mFile = $manager->createFromFile(self::samplesDir() . 'datatypes/file/raw/text.txt', 'text/plain', 'newname.txt'); $mFile = $manager->retrieve($mFile->getIdentifier()); $this->assertEquals('text/plain', $mFile->getMimeType()); $this->assertEquals('newname.txt', $mFile->getFilename()); $this->assertEquals('I contain some text...', $mFile->getData()); $manager->delete($mFile); }
public function testFile() { $fManager = new FileSystemFileManager(); $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); $file1 = $fManager->createFromData('Some text', 'text/plain'); $file2 = $fManager->createFromData('Some text', 'text/plain'); $operands[] = $file1; $operands[] = $file2; $processor = new MatchProcessor($expression, $operands); $this->assertTrue($processor->process()->getValue()); $fManager->delete($file1); $fManager->delete($file2); $operands->reset(); $file1 = $fManager->createFromData('Some text', 'text/plain'); $file2 = $fManager->createFromData('Other text', 'text/plain'); $operands[] = $file1; $operands[] = $file2; $this->assertFalse($processor->process()->getValue()); $fManager->delete($file1); $fManager->delete($file2); }
public function unmarshallFileProvider() { $returnValue = array(); $samples = self::samplesDir(); $fileManager = new FileSystemFileManager(); $file = $fileManager->retrieve($samples . 'datatypes/file/files_2.txt'); $returnValue[] = array($file, '{ "base" : { "file" : { "mime" : "text\\/html", "data" : ' . json_encode(base64_encode('<img src="/qtism/img.png"/>')) . ' } } }'); $file = $fileManager->retrieve($samples . 'datatypes/file/text-plain_text_data.txt'); $returnValue[] = array($file, '{ "base" : { "file" : { "mime" : "text\\/plain", "data" : ' . json_encode(base64_encode('Some text...')) . ', "name" : "text.txt" } } }'); $originalfile = $samples . 'datatypes/file/raw/image.png'; $filepath = $samples . 'datatypes/file/image-png_noname_data.png'; $file = $fileManager->retrieve($filepath); $returnValue[] = array($file, '{ "base" : { "file" : { "mime" : "image\\/png", "data" : ' . json_encode(base64_encode(file_get_contents($originalfile))) . ' } } }'); return $returnValue; }