Skip to content

Commit

Permalink
Reference fix for PHP 7.0 (#120)
Browse files Browse the repository at this point in the history
* Updated pass by reference

* Updated refs

* Fixed further issues with reference

* Bumped mongo

* Updated config

* Updated config

* Updated test

* Updated connection string
  • Loading branch information
rgubby authored Jul 18, 2017
1 parent 52363de commit fc29337
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
11 changes: 7 additions & 4 deletions src/classes/ExtendedGraph.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,8 @@ public function add_rdf($rdf, $base='') {
if(!empty($errors)){
$this->parser_errors[]=$errors;
}
$this->_add_arc2_triple_list($parser->getTriples());
$triples = $parser->getTriples();
$this->_add_arc2_triple_list($triples);
unset($parser);
}
}
Expand All @@ -608,7 +609,8 @@ public function add_rdfxml($rdfxml, $base='') {
/** @var \ARC2_RDFXMLParser $parser */
$parser = \ARC2::getRDFXMLParser();
$parser->parse($base, $rdfxml );
$this->_add_arc2_triple_list($parser->getTriples());
$triples = $parser->getTriples();
$this->_add_arc2_triple_list($triples);
unset($parser);
}
}
Expand Down Expand Up @@ -666,7 +668,8 @@ public function add_rdfa($html, $base='') {
$parser = \ARC2::getSemHTMLParser();
$parser->parse($base, $html );
$parser->extractRDF('rdfa');
$this->_add_arc2_triple_list($parser->getTriples());
$triples = $parser->getTriples();
$this->_add_arc2_triple_list($triples);
unset($parser);
}
}
Expand Down Expand Up @@ -1872,4 +1875,4 @@ public function from_graph(ExtendedGraph $graph) {
$this->add_graph($graph);
}
}
}
}
10 changes: 5 additions & 5 deletions test/unit/mongo/MongoTripodConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,15 @@ public function testCardinality()

public function testGetConnectionString()
{
$this->assertEquals("mongodb://localhost",\Tripod\Mongo\Config::getInstance()->getConnStr("tripod_php_testing"));
$this->assertEquals("mongodb://localhost:27017/",\Tripod\Mongo\Config::getInstance()->getConnStr("tripod_php_testing"));
}

public function testGetConnectionStringThrowsException()
{
$this->setExpectedException(
'\Tripod\Exceptions\ConfigException',
'Database notexists does not exist in configuration');
$this->assertEquals("mongodb://localhost",\Tripod\Mongo\Config::getInstance()->getConnStr("notexists"));
$this->assertEquals("mongodb://localhost:27017/",\Tripod\Mongo\Config::getInstance()->getConnStr("notexists"));
}

public function testGetConnectionStringForReplicaSet(){
Expand Down Expand Up @@ -1709,7 +1709,7 @@ public function testMongoConnectionNoExceptions()
$mockConfig->loadConfig(json_decode(file_get_contents(dirname(__FILE__).'/data/config.json'), true));
$mockConfig->expects($this->exactly(1))
->method('getMongoClient')
->with('mongodb://localhost?connectTimeoutMS=20000')
->with('mongodb://localhost:27017/?connectTimeoutMS=20000')
->will($this->returnCallback(
function()
{
Expand All @@ -1728,7 +1728,7 @@ public function testMongoConnectionExceptionThrown()
$mockConfig->loadConfig(json_decode(file_get_contents(dirname(__FILE__).'/data/config.json'), true));
$mockConfig->expects($this->exactly(30))
->method('getMongoClient')
->with('mongodb://localhost?connectTimeoutMS=20000')
->with('mongodb://localhost:27017/?connectTimeoutMS=20000')
->will($this->throwException(new ConnectionTimeoutException('Exception thrown when connecting to Mongo')));

$mockConfig->getDatabase('tripod_php_testing', 'rs1', ReadPreference::RP_SECONDARY_PREFERRED);
Expand All @@ -1739,7 +1739,7 @@ public function testMongoConnectionNoExceptionThrownWhenConnectionThrowsSomeExce
$mockConfig->loadConfig(json_decode(file_get_contents(dirname(__FILE__).'/data/config.json'), true));
$mockConfig->expects($this->exactly(5))
->method('getMongoClient')
->with('mongodb://localhost?connectTimeoutMS=20000')
->with('mongodb://localhost:27017/?connectTimeoutMS=20000')
->will($this->onConsecutiveCalls(
$this->throwException(new ConnectionTimeoutException('Exception thrown when connecting to Mongo')),
$this->throwException(new ConnectionTimeoutException('Exception thrown when connecting to Mongo')),
Expand Down
2 changes: 1 addition & 1 deletion test/unit/mongo/MongoTripodDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ public function testSaveChangesWithInvalidCardinality()
$config["data_sources"] = array(
"db"=>array(
"type"=>"mongo",
"connection"=>"mongodb://localhost"
"connection"=>"mongodb://localhost:27017/"
),
"tlog"=>array(
"type"=>"mongo",
Expand Down
4 changes: 2 additions & 2 deletions test/unit/mongo/data/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
"data_sources" : {
"rs1" : {
"type" : "mongo",
"connection": "mongodb:\/\/localhost",
"connection": "mongodb:\/\/localhost:27017/",
"replicaSet": ""
},
"rs2" : {
"type" : "mongo",
"connection": "mongodb:\/\/localhost",
"connection": "mongodb:\/\/localhost:27017/",
"replicaSet": ""
}
},
Expand Down

0 comments on commit fc29337

Please sign in to comment.