function testSpecifyCredentials() { $configuration = new Configuration(array('username' => 'foobar', 'password' => 'baz')); $transport = new Transport\Curl(self::host, self::port); $transport->setAuth('foobar', 'baz'); $this->assertEquals(new Client($transport), $configuration->getClient()); }
/** * @param string $host * @param string $port * @param string|null $username * @param string|null $password */ public function __construct($host = 'localhost', $port = '7474', $username = null, $password = null) { $transport = new Curl($host, $port); $transport->setAuth($username, $password); $this->client = new Client($transport); }
static function getClient($config) { //Add default options $config->options += array('host' => 'localhost', 'port' => '7474'); $url = 'http://' . $config->options['host'] . ':' . $config->options['port']; if (!isset($connections[$url])) { //Set basic auth options if (isset($config->options['auth'])) { $transport = new Transport($config->options['host'], $config->options['port']); $transport->setAuth($config->options['user'], $config->options['pass']); $client = new Client($transport); } else { $client = new Client($config->options['host'], $config->options['port']); } $connections[$url] = new Neo($client); } return $connections[$url]; }