Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #52 from timmillwood/master
Browse files Browse the repository at this point in the history
Adding path support for url
  • Loading branch information
beberlei committed Nov 11, 2015
2 parents b9e14fd + 936d591 commit 9441f05
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/Doctrine/CouchDB/CouchDBClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ static public function create(array $options)
break;

case 'path':
$options['dbname'] = ltrim($value, '/');
$path = explode('/', $value);
$options['dbname'] = array_pop($path);
$options['path'] = trim(implode('/', $path), '/');
break;

case 'pass':
Expand Down
21 changes: 21 additions & 0 deletions tests/Doctrine/Tests/CouchDB/CouchDBClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,27 @@ public function testCreateClientFromUrl()
);
}

public function testCreateClientFromUrlWithPath()
{
$client = CouchDBClient::create(array('url' => 'https://foo:bar@localhost:5555/baz/qux/norf'));

$this->assertEquals('norf', $client->getDatabase());
$this->assertEquals(
array(
'host' => 'localhost',
'port' => 5555,
'ip' => '127.0.0.1',
'username' => 'foo',
'password' => 'bar',
'ssl' => true,
'timeout' => 0.01,
'keep-alive' => true,
'path' => 'baz/qux',
),
$client->getHttpClient()->getOptions()
);
}

public function testCreateClientWithLogging()
{
$client = CouchDBClient::create(array('dbname' => 'test', 'logging' => true));
Expand Down

0 comments on commit 9441f05

Please sign in to comment.