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

Commit 9441f05

Browse files
committed
Merge pull request #52 from timmillwood/master
Adding path support for url
2 parents b9e14fd + 936d591 commit 9441f05

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lib/Doctrine/CouchDB/CouchDBClient.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ static public function create(array $options)
8888
break;
8989

9090
case 'path':
91-
$options['dbname'] = ltrim($value, '/');
91+
$path = explode('/', $value);
92+
$options['dbname'] = array_pop($path);
93+
$options['path'] = trim(implode('/', $path), '/');
9294
break;
9395

9496
case 'pass':

tests/Doctrine/Tests/CouchDB/CouchDBClientTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,27 @@ public function testCreateClientFromUrl()
4444
);
4545
}
4646

47+
public function testCreateClientFromUrlWithPath()
48+
{
49+
$client = CouchDBClient::create(array('url' => 'https://foo:bar@localhost:5555/baz/qux/norf'));
50+
51+
$this->assertEquals('norf', $client->getDatabase());
52+
$this->assertEquals(
53+
array(
54+
'host' => 'localhost',
55+
'port' => 5555,
56+
'ip' => '127.0.0.1',
57+
'username' => 'foo',
58+
'password' => 'bar',
59+
'ssl' => true,
60+
'timeout' => 0.01,
61+
'keep-alive' => true,
62+
'path' => 'baz/qux',
63+
),
64+
$client->getHttpClient()->getOptions()
65+
);
66+
}
67+
4768
public function testCreateClientWithLogging()
4869
{
4970
$client = CouchDBClient::create(array('dbname' => 'test', 'logging' => true));

0 commit comments

Comments
 (0)