예제 #1
0
 public function testOverrideDocument()
 {
     $mgr = new AfsDocumentManager();
     $mgr->add_document(new AfsDocument('foo'), 'bar');
     $this->assertTrue($mgr->has_document());
     $this->assertEquals(count($mgr->get_documents()), 1);
     $mgr->add_document(new AfsDocument('baz'), 'bar');
     $this->assertTrue($mgr->has_document());
     $this->assertEquals(count($mgr->get_documents()), 1);
     $docs = $mgr->get_documents();
     $filename = reset($docs)->get_filename();
     $this->assertEquals(file_get_contents($filename), 'baz');
 }
예제 #2
0
 /** @brief Upload one or more documents through document manager.
  *
  * @param $mgr [in] document manager (see @a AfsDocumentManager).
  * @param $comment [in] comment associated to this action (default=null).
  * @return command result (see @a AfsPafUploadReply).
  *
  * @exception InvalidArgumentException when no document is being sent.
  * @exception Exception when error occured while initializing or executing
  *            request.
  */
 public function upload_docs(AfsDocumentManager $mgr, $comment = null, $paf_mode = PaFMode::Incremental)
 {
     $this->paf_mode = $paf_mode;
     if (!$mgr->has_document()) {
         throw new InvalidArgumentException('No document to be sent');
     }
     $version = $this->get_bo_version();
     $context = new AfsPafConnectorContext($version, $mgr, $comment, $paf_mode);
     return new AfsPafUploadReply(json_decode($this->query($context)));
 }