<?php use Doctrine\OrientDB\Binding\HttpBinding; use Doctrine\OrientDB\Binding\BindingParameters; require __DIR__ . '/../autoload.php'; $parameters = BindingParameters::create('http://*****:*****@127.0.0.1:2480/friends'); $binding = new HttpBinding($parameters); $friends = $binding->query('select from friends where any() traverse(0,1) ( @rid = #5:3 ) and @rid <> #5:3'); foreach ($friends as $friend) { echo $friend->name, "\n"; }
public function testOptionalDatabaseArgumentDoesNotSwitchCurrentDatabase() { $host = TEST_ODB_HOST; $port = TEST_ODB_PORT; $database = TEST_ODB_DATABASE; $adapter = $this->getMock('Doctrine\\OrientDB\\Binding\\Adapter\\HttpClientAdapterInterface'); $adapter->expects($this->at(0))->method('request')->with('POST', "http://{$host}:{$port}/command/{$database}/sql/SELECT%201", null, null); $adapter->expects($this->at(1))->method('request')->with('POST', "http://{$host}:{$port}/command/HIJACKED/sql/SELECT%202", null, null); $adapter->expects($this->at(2))->method('request')->with('POST', "http://{$host}:{$port}/command/{$database}/sql/SELECT%203", null, null); $parameters = new BindingParameters(TEST_ODB_HOST, TEST_ODB_PORT, TEST_ODB_USER, TEST_ODB_PASSWORD, TEST_ODB_DATABASE); $binding = new HttpBinding($parameters); $binding->setAdapter($adapter); $binding->command('SELECT 1'); $binding->command('SELECT 2', HttpBinding::LANGUAGE_SQLPLUS, "HIJACKED"); $binding->command('SELECT 3'); }
/** * @see https://github.com/Reinmar/Orient/commit/6110c61778cd7592f4c1e4f5530ea84e79c0f9cd */ public function testFetchPlansAreProperlyEncoded() { $host = TEST_ODB_HOST; $port = TEST_ODB_HTTP_PORT; $database = TEST_ODB_DATABASE; /** @var HttpClientAdapterInterface|ObjectProphecy $adapter */ $adapter = $this->prophesize(HttpClientAdapterInterface::class); $adapter->setAuthentication(null, null)->shouldBeCalled(); /** @var CurlClientResponse|ObjectProphecy $res */ $res = $this->prophesize(CurlClientResponse::class); $res->getStatusCode()->willReturn(200); /** @var HttpBindingResultInterface|ObjectProphecy $br */ $br = $this->prophesize(HttpBindingResultInterface::class); $br->getInnerResponse()->willReturn($res->reveal()); $br->getData()->willReturn(json_decode('{"result":{}}', true)); $adapter->request('GET', "http://{$host}:{$port}/query/{$database}/sql/SELECT%20OMNOMNOMN/2/%2A%3A1%20field1%3A3", null, null)->willReturn($br->reveal()); $parameters = new BindingParameters($host, $port, null, null, $database); $binding = new HttpBinding($parameters, $adapter->reveal()); $binding->query("SELECT OMNOMNOMN", 2, "*:1 field1:3"); }