From fc2933767870fcada9e237a17e5d28d65689dfe2 Mon Sep 17 00:00:00 2001 From: Richard Gubby Date: Tue, 18 Jul 2017 14:23:49 +0100 Subject: [PATCH] Reference fix for PHP 7.0 (#120) * Updated pass by reference * Updated refs * Fixed further issues with reference * Bumped mongo * Updated config * Updated config * Updated test * Updated connection string --- src/classes/ExtendedGraph.class.php | 11 +++++++---- test/unit/mongo/MongoTripodConfigTest.php | 10 +++++----- test/unit/mongo/MongoTripodDriverTest.php | 2 +- test/unit/mongo/data/config.json | 4 ++-- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/classes/ExtendedGraph.class.php b/src/classes/ExtendedGraph.class.php index 80aaa835..4285acd5 100644 --- a/src/classes/ExtendedGraph.class.php +++ b/src/classes/ExtendedGraph.class.php @@ -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); } } @@ -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); } } @@ -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); } } @@ -1872,4 +1875,4 @@ public function from_graph(ExtendedGraph $graph) { $this->add_graph($graph); } } -} \ No newline at end of file +} diff --git a/test/unit/mongo/MongoTripodConfigTest.php b/test/unit/mongo/MongoTripodConfigTest.php index fa76d1f1..8a9b11b4 100644 --- a/test/unit/mongo/MongoTripodConfigTest.php +++ b/test/unit/mongo/MongoTripodConfigTest.php @@ -150,7 +150,7 @@ 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() @@ -158,7 +158,7 @@ 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(){ @@ -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() { @@ -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); @@ -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')), diff --git a/test/unit/mongo/MongoTripodDriverTest.php b/test/unit/mongo/MongoTripodDriverTest.php index d85b4576..618613c5 100755 --- a/test/unit/mongo/MongoTripodDriverTest.php +++ b/test/unit/mongo/MongoTripodDriverTest.php @@ -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", diff --git a/test/unit/mongo/data/config.json b/test/unit/mongo/data/config.json index 9046d07f..c25596ea 100644 --- a/test/unit/mongo/data/config.json +++ b/test/unit/mongo/data/config.json @@ -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": "" } },