コード例 #1
0
 protected function setUp()
 {
     parent::setup();
     //Mongo::setPoolSize(200);
     $this->tripodTransactionLog = new \Tripod\Mongo\TransactionLog();
     $this->tripodTransactionLog->purgeAllTransactions();
     // Stub ouf 'addToElastic' search to prevent writes into Elastic Search happening by default.
     $this->tripod = $this->getMock('\\Tripod\\Mongo\\Driver', array('addToSearchIndexQueue'), array('CBD_testing', 'tripod_php_testing', array('defaultContext' => 'http://talisaspire.com/')));
     $this->tripod->expects($this->any())->method('addToSearchIndexQueue');
     $this->getTripodCollection($this->tripod)->drop();
     $this->tripod->setTransactionLog($this->tripodTransactionLog);
     $this->loadResourceDataViaTripod();
 }
コード例 #2
0
 protected function setUp()
 {
     parent::setup();
     $this->tripodTransactionLog = new \Tripod\Mongo\TransactionLog();
     $this->tripodTransactionLog->purgeAllTransactions();
     // Stub ouf 'addToElastic' search to prevent writes into Elastic Search happening by default.
     $this->tripod = $this->getMock('\\Tripod\\Mongo\\Driver', array('validateGraphCardinality'), array('CBD_testing', 'tripod_php_testing', array('defaultContext' => 'http://talisaspire.com/')));
     $this->tripod->expects($this->any())->method('addToSearchIndexQueue');
     $this->getTripodCollection($this->tripod)->drop();
     // Lock collection no longer available from Tripod, so drop it manually
     \Tripod\Mongo\Config::getInstance()->getCollectionForLocks($this->tripod->getStoreName())->drop();
     $this->tripod->setTransactionLog($this->tripodTransactionLog);
     $this->loadResourceDataViaTripod();
 }
コード例 #3
0
 public function testTransactionsLoggedCorrectlyFromMultipleTripods()
 {
     // Create two tripods onto different collection/dbname and make them use the same transaction log
     $tripod1 = $this->getMock('\\Tripod\\Mongo\\Driver', array('generateViewsAndSearchDocumentsForResources'), array('CBD_testing', 'tripod_php_testing'));
     $tripod1->expects($this->any())->method('generateViewsAndSearchDocumentsForResources');
     $this->getTripodCollection($tripod1)->drop();
     $tripod1->setTransactionLog($this->tripodTransactionLog);
     $tripod2 = $this->getMock('\\Tripod\\Mongo\\Driver', array('generateViewsAndSearchDocumentsForResources'), array('CBD_testing_2', 'tripod_php_testing'));
     $tripod2->expects($this->any())->method('generateViewsAndSearchDocumentsForResources');
     $this->getTripodCollection($tripod2)->drop();
     $tripod2->setTransactionLog($this->tripodTransactionLog);
     $uri = 'http://example.com/resources/1';
     $g = new \Tripod\Mongo\MongoGraph();
     $g->add_literal_triple($uri, $g->qname_to_uri('searchterms:title'), "Some title");
     $g->add_literal_triple($uri, $g->qname_to_uri('searchterms:author'), "Some author");
     // save entity using both tripods ( creates same doc in two different collections )
     $tripod1->saveChanges(new \Tripod\ExtendedGraph(), $g, 'http://talisaspire.com/');
     $tripod2->saveChanges(new \Tripod\ExtendedGraph(), $g, 'http://talisaspire.com/');
     // assert the document is in both collections
     $this->assertDocumentVersion(array("r" => $uri, "c" => "http://talisaspire.com/"), 0, true, $tripod1);
     $this->assertDocumentVersion(array("r" => $uri, "c" => "http://talisaspire.com/"), 0, true, $tripod2);
     // assert the transaction log contains two transactions
     $this->assertEquals(2, $this->tripodTransactionLog->getTotalTransactionCount());
     // change one of the documents
     $oG = new \Tripod\Mongo\MongoGraph();
     $oG->add_literal_triple($uri, $g->qname_to_uri('searchterms:title'), "Some title");
     $nG = new \Tripod\Mongo\MongoGraph();
     $nG->add_literal_triple($uri, $g->qname_to_uri('searchterms:title'), "Changed title");
     $tripod1->saveChanges($oG, $nG, 'http://talisaspire.com/');
     // assert the documents and transaction count
     $this->assertDocumentVersion(array("r" => $uri, "c" => "http://talisaspire.com/"), 1, true, $tripod1);
     $this->assertDocumentVersion(array("r" => $uri, "c" => "http://talisaspire.com/"), 0, true, $tripod2);
     $this->assertEquals(3, $this->tripodTransactionLog->getTotalTransactionCount());
 }
コード例 #4
0
 protected function setUp()
 {
     parent::setup();
     $this->tripodTransactionLog = new \Tripod\Mongo\TransactionLog();
     $this->tripodTransactionLog->purgeAllTransactions();
     $this->labeller = new \Tripod\Mongo\Labeller();
     // Stub out 'addToElastic' search to prevent writes into Elastic Search happening by default.
     $tripod = $this->getMock('\\Tripod\\Mongo\\Driver', array('addToSearchIndexQueue'), array('CBD_testing', 'tripod_php_testing', array('defaultContext' => 'http://talisaspire.com/')));
     $tripod->expects($this->any())->method('addToSearchIndexQueue');
     /** @var $tripod \Tripod\Mongo\Driver */
     \Tripod\Mongo\Config::getInstance()->getCollectionForCBD('tripod_php_testing', 'CBD_testing')->drop();
     // Lock collection no longer available from Driver, so drop it manually
     \Tripod\Mongo\Config::getInstance()->getCollectionForLocks('tripod_php_testing')->drop();
     $tripod->setTransactionLog($this->tripodTransactionLog);
     $this->tripod = $tripod;
 }
コード例 #5
0
 /**
  * @param mixed $_id
  * @param Collection|null $collection
  * @param bool $fromTransactionLog
  * @return array|null
  */
 protected function getDocument($_id, $collection = null, $fromTransactionLog = false)
 {
     if ($fromTransactionLog == true) {
         return $this->tripodTransactionLog->getTransaction($_id);
     }
     if ($collection == NULL) {
         return $this->getTripodCollection($this->tripod)->findOne(array("_id" => $_id));
     } elseif ($collection instanceof \Tripod\Mongo\Driver) {
         return $this->getTripodCollection($collection)->findOne(array("_id" => $_id));
     } else {
         return $collection->findOne(array("_id" => $_id));
     }
 }