Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-mongodb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
laravel-mongodb
Commits
657da133
Unverified
Commit
657da133
authored
Apr 25, 2018
by
Jens Segers
Committed by
GitHub
Apr 25, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1457 from halaei/fix-dsn-when-not-unix-socket
fix dsn config when not unix socket
parents
9df75b74
0e693886
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
12 deletions
+24
-12
Connection.php
src/Jenssegers/Mongodb/Connection.php
+3
-12
DsnTest.php
tests/DsnTest.php
+14
-0
TestCase.php
tests/TestCase.php
+1
-0
database.php
tests/config/database.php
+6
-0
No files found.
src/Jenssegers/Mongodb/Connection.php
View file @
657da133
...
@@ -4,7 +4,6 @@ namespace Jenssegers\Mongodb;
...
@@ -4,7 +4,6 @@ namespace Jenssegers\Mongodb;
use
Illuminate\Database\Connection
as
BaseConnection
;
use
Illuminate\Database\Connection
as
BaseConnection
;
use
Illuminate\Support\Arr
;
use
Illuminate\Support\Arr
;
use
Illuminate\Support\Str
;
use
MongoDB\Client
;
use
MongoDB\Client
;
class
Connection
extends
BaseConnection
class
Connection
extends
BaseConnection
...
@@ -151,7 +150,7 @@ class Connection extends BaseConnection
...
@@ -151,7 +150,7 @@ class Connection extends BaseConnection
}
}
/**
/**
* Determine if the given configuration array has a
UNIX socket value
.
* Determine if the given configuration array has a
dsn string
.
*
*
* @param array $config
* @param array $config
* @return bool
* @return bool
...
@@ -162,22 +161,14 @@ class Connection extends BaseConnection
...
@@ -162,22 +161,14 @@ class Connection extends BaseConnection
}
}
/**
/**
* Get the DSN string for
a socket
configuration.
* Get the DSN string for
m
configuration.
*
*
* @param array $config
* @param array $config
* @return string
* @return string
*/
*/
protected
function
getDsnString
(
array
$config
)
protected
function
getDsnString
(
array
$config
)
{
{
$dsn_string
=
$config
[
'dsn'
];
return
$config
[
'dsn'
];
if
(
Str
::
contains
(
$dsn_string
,
'mongodb://'
))
{
$dsn_string
=
Str
::
replaceFirst
(
'mongodb://'
,
''
,
$dsn_string
);
}
$dsn_string
=
rawurlencode
(
$dsn_string
);
return
"mongodb://
{
$dsn_string
}
"
;
}
}
/**
/**
...
...
tests/DsnTest.php
0 → 100644
View file @
657da133
<?php
class
DsnTest
extends
TestCase
{
public
function
test_dsn_works
()
{
$this
->
assertInstanceOf
(
\Illuminate\Database\Eloquent\Collection
::
class
,
DsnAddress
::
all
());
}
}
class
DsnAddress
extends
Address
{
protected
$connection
=
'dsn_mongodb'
;
}
tests/TestCase.php
View file @
657da133
...
@@ -51,6 +51,7 @@ class TestCase extends Orchestra\Testbench\TestCase
...
@@ -51,6 +51,7 @@ class TestCase extends Orchestra\Testbench\TestCase
$app
[
'config'
]
->
set
(
'database.default'
,
'mongodb'
);
$app
[
'config'
]
->
set
(
'database.default'
,
'mongodb'
);
$app
[
'config'
]
->
set
(
'database.connections.mysql'
,
$config
[
'connections'
][
'mysql'
]);
$app
[
'config'
]
->
set
(
'database.connections.mysql'
,
$config
[
'connections'
][
'mysql'
]);
$app
[
'config'
]
->
set
(
'database.connections.mongodb'
,
$config
[
'connections'
][
'mongodb'
]);
$app
[
'config'
]
->
set
(
'database.connections.mongodb'
,
$config
[
'connections'
][
'mongodb'
]);
$app
[
'config'
]
->
set
(
'database.connections.dsn_mongodb'
,
$config
[
'connections'
][
'dsn_mongodb'
]);
$app
[
'config'
]
->
set
(
'auth.model'
,
'User'
);
$app
[
'config'
]
->
set
(
'auth.model'
,
'User'
);
$app
[
'config'
]
->
set
(
'auth.providers.users.model'
,
'User'
);
$app
[
'config'
]
->
set
(
'auth.providers.users.model'
,
'User'
);
...
...
tests/config/database.php
View file @
657da133
...
@@ -11,6 +11,12 @@ return [
...
@@ -11,6 +11,12 @@ return [
'database'
=>
'unittest'
,
'database'
=>
'unittest'
,
],
],
'dsn_mongodb'
=>
[
'driver'
=>
'mongodb'
,
'dsn'
=>
'mongodb://mongodb:27017'
,
'database'
=>
'unittest'
,
],
'mysql'
=>
[
'mysql'
=>
[
'driver'
=>
'mysql'
,
'driver'
=>
'mysql'
,
'host'
=>
'mysql'
,
'host'
=>
'mysql'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment