-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into decouple-invalidation-from-save
Conflicts: src/mongo/Config.class.php src/mongo/base/DriverBase.class.php src/mongo/delegates/MongoTripodSearchIndexer.class.php src/mongo/delegates/Tables.class.php src/mongo/delegates/Updates.class.php src/mongo/delegates/Views.class.php src/mongo/queue/MongoTripodQueue.class.php src/mongo/util/IndexUtils.class.php test/unit/mongo/MongoTripodTablesTest.php test/unit/mongo/MongoTripodTestBase.php
- Loading branch information
Showing
3 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1264,6 +1264,71 @@ public function testDataLoadedInConfiguredDataSource() | |
} | ||
} | ||
|
||
public function testTransactionLogIsWrittenToCorrectDBAndCollection() | ||
{ | ||
$storeName = 'tripod_php_testing'; | ||
$newConfig = \Tripod\Mongo\Config::getConfig(); | ||
$newConfig['transaction_log']['database'] = 'tripod_php_testing_transaction_log'; | ||
$newConfig['transaction_log']['collection'] = 'transaction_log'; | ||
|
||
\Tripod\Mongo\Config::setConfig($newConfig); | ||
|
||
$config = \Tripod\Mongo\Config::getInstance(); | ||
|
||
// Clear out any old data | ||
$tlogDB = $config->getTransactionLogDatabase(); | ||
$tlogDB->drop(); | ||
|
||
|
||
// Make sure the dbs do not exist | ||
$transactionConnInfo = $newConfig['data_sources'][$newConfig['transaction_log']['data_source']]; | ||
$options = isset($transactionConnInfo['replicaSet']) && !empty($transactionConnInfo['replicaSet']) ? array('replicaSet' => $transactionConnInfo['replicaSet']): array(); | ||
$transactionMongo = new MongoClient($transactionConnInfo['connection'], $options); | ||
$transactionDbInfo = $transactionMongo->listDBs(); | ||
foreach($transactionDbInfo['databases'] as $db){ | ||
$this->assertNotEquals($db['name'], $newConfig['transaction_log']['database'], $newConfig['queue']['database']); | ||
} | ||
$tqueuesConnInfo = $newConfig['data_sources'][$newConfig['transaction_log']['data_source']]; | ||
$options = isset($tqueuesConnInfo['replicaSet']) && !empty($tqueuesConnInfo['replicaSet']) ? array('replicaSet' => $tqueuesConnInfo['replicaSet']): array(); | ||
$queuesMongo = new MongoClient($tqueuesConnInfo['connection'], $options); | ||
$queuesDbInfo = $queuesMongo->listDBs(); | ||
foreach($queuesDbInfo['databases'] as $db){ | ||
$this->assertNotEquals($db['name'], $newConfig['transaction_log']['database'], $newConfig['queue']['database']); | ||
} | ||
|
||
// Start adding some data | ||
$this->tripod = new \Tripod\Mongo\Driver('CBD_testing', $storeName, array(OP_ASYNC=>array(OP_VIEWS=>true,OP_TABLES=>false,OP_SEARCH=>false))); | ||
$this->loadBaseDataViaTripod(); | ||
|
||
$graph = new \Tripod\Mongo\MongoGraph(); | ||
$subject = 'http://example.com/' . uniqid(); | ||
$labeller = new \Tripod\Mongo\Labeller(); | ||
$graph->add_resource_triple($subject, RDF_TYPE, $labeller->qname_to_uri('foaf:Person')); | ||
$graph->add_literal_triple($subject, FOAF_NAME, "Anne Example"); | ||
$this->tripod->saveChanges(new \Tripod\ExtendedGraph(), $graph); | ||
|
||
$newGraph = $this->tripod->describeResource($subject); | ||
$newGraph->add_literal_triple($subject, $labeller->qname_to_uri('foaf:email'), '[email protected]'); | ||
$this->tripod->saveChanges($graph, $newGraph); | ||
|
||
// Make sure the dbs do now exist | ||
$transactionDbInfo = $transactionMongo->listDBs(); | ||
$transactionDbExists = false; | ||
foreach($transactionDbInfo['databases'] as $db){ | ||
if($db['name'] === $newConfig['transaction_log']['database']){ | ||
$transactionDbExists = true; | ||
} | ||
} | ||
$this->assertTrue($transactionDbExists); | ||
|
||
// Make sure the data in the dbs look right | ||
$transactionColletion = $transactionMongo->selectCollection($newConfig['transaction_log']['database'], $newConfig['transaction_log']['collection']); | ||
$transactionCount = $transactionColletion->count(); | ||
$transactionExampleDocument = $transactionColletion->findOne(); | ||
$this->assertEquals(18, $transactionCount); | ||
$this->assertContains('transaction_', $transactionExampleDocument["_id"]); | ||
} | ||
|
||
public function testComputedFieldSpecValidationInvalidFunction() | ||
{ | ||
$newConfig = \Tripod\Mongo\Config::getConfig(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters