/** * execute tests * * @param string $action * @param Charcoal_IEventContext $context * * @return boolean */ public function test($action, $context) { $action = us($action); // temp file component /** @var Charcoal_TempFileComponent $tf */ $tf = $context->getComponent('temp_file@:charcoal:file'); switch ($action) { case "create": $file = $tf->create("test"); $this->assertTrue($file->exists()); $this->assertTrue($file->canRead()); $this->assertEquals("test", $file->getContents()); return TRUE; case "get_contents": $temp_file = new Charcoal_File(CHARCOAL_TMP_DIR . '/tmpfile.txt'); $temp_file->putContents("test"); $tf->setFile($temp_file); $this->assertEquals("test", $tf->getContents()); return TRUE; case "put_contents": $temp_file = new Charcoal_File(CHARCOAL_TMP_DIR . '/tmpfile.txt'); $tf->setFile($temp_file); $tf->putContents("cat"); $this->assertTrue($temp_file->exists()); $this->assertTrue($temp_file->canRead()); $this->assertEquals("cat", $temp_file->getContents()); return TRUE; } return FALSE; }