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
2ae7980f
Commit
2ae7980f
authored
Apr 14, 2014
by
Jens Segers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding tests for connection
parent
3c0edb03
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletion
+33
-1
Connection.php
src/Jenssegers/Mongodb/Connection.php
+1
-1
ConnectionTest.php
tests/ConnectionTest.php
+32
-0
No files found.
src/Jenssegers/Mongodb/Connection.php
View file @
2ae7980f
...
...
@@ -180,7 +180,7 @@ class Connection extends \Illuminate\Database\Connection {
*/
public
function
getDriverName
()
{
return
''
;
return
'
mongodb
'
;
}
/**
...
...
tests/ConnectionTest.php
View file @
2ae7980f
...
...
@@ -20,6 +20,9 @@ class ConnectionTest extends TestCase {
{
$connection
=
DB
::
connection
(
'mongodb'
);
$this
->
assertInstanceOf
(
'MongoDB'
,
$connection
->
getMongoDB
());
$connection
=
DB
::
connection
(
'mongodb'
);
$this
->
assertInstanceOf
(
'MongoClient'
,
$connection
->
getMongoClient
());
}
public
function
testCollection
()
...
...
@@ -81,4 +84,33 @@ class ConnectionTest extends TestCase {
$this
->
assertInstanceOf
(
'Jenssegers\Mongodb\Schema\Builder'
,
$schema
);
}
public
function
testDriverName
()
{
$driver
=
DB
::
connection
(
'mongodb'
)
->
getDriverName
();
$this
->
assertEquals
(
'mongodb'
,
$driver
);
}
public
function
testAuth
()
{
Config
::
set
(
'database.connections.mongodb.username'
,
'foo'
);
Config
::
set
(
'database.connections.mongodb.password'
,
'bar'
);
$host
=
Config
::
get
(
'database.connections.mongodb.host'
);
$port
=
Config
::
get
(
'database.connections.mongodb.port'
,
27017
);
$database
=
Config
::
get
(
'database.connections.mongodb.database'
);
$this
->
setExpectedException
(
'MongoConnectionException'
,
"Failed to connect to:
$host
:
$port
: Authentication failed on database '
$database
' with username 'foo': auth fails"
);
$connection
=
DB
::
connection
(
'mongodb'
);
}
public
function
testCustomPort
()
{
$port
=
27000
;
Config
::
set
(
'database.connections.mongodb.port'
,
$port
);
$host
=
Config
::
get
(
'database.connections.mongodb.host'
);
$database
=
Config
::
get
(
'database.connections.mongodb.database'
);
$this
->
setExpectedException
(
'MongoConnectionException'
,
"Failed to connect to:
$host
:
$port
: Connection refused"
);
$connection
=
DB
::
connection
(
'mongodb'
);
}
}
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