Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
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
mongo-php-library
Commits
3db125f1
Commit
3db125f1
authored
Mar 18, 2015
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5
parents
27543788
ea6da09f
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
683 additions
and
542 deletions
+683
-542
Client.php
src/Client.php
+14
-2
Collection.php
src/Collection.php
+596
-538
Database.php
src/Database.php
+49
-1
CollectionTest.php
tests/CollectionTest.php
+24
-1
No files found.
src/Client.php
View file @
3db125f1
...
...
@@ -2,9 +2,10 @@
namespace
MongoDB
;
use
MongoDB\Driver\Manager
;
use
MongoDB\Database
;
use
MongoDB\Collection
;
use
MongoDB\Database
;
use
MongoDB\Driver\Manager
;
use
MongoDB\Driver\Result
;
class
Client
{
...
...
@@ -29,6 +30,17 @@ class Client
$this
->
manager
=
new
Manager
(
$uri
,
$options
,
$driverOptions
);
}
/**
* Drop a database.
*
* @param string $databaseName
* @return Result
*/
public
function
dropDatabase
(
$databaseName
)
{
// TODO
}
/**
* Select a database
*
...
...
src/Collection.php
View file @
3db125f1
This diff is collapsed.
Click to expand it.
src/Database.php
View file @
3db125f1
...
...
@@ -2,8 +2,9 @@
namespace
MongoDB
;
use
MongoDB\Driver\Manager
;
use
MongoDB\Collection
;
use
MongoDB\Driver\Manager
;
use
MongoDB\Driver\Result
;
class
Database
{
...
...
@@ -32,6 +33,53 @@ class Database
$this
->
rp
=
$rp
;
}
/**
* Create a new collection explicitly.
*
* @see http://docs.mongodb.org/manual/reference/command/create/
* @see http://docs.mongodb.org/manual/reference/method/db.createCollection/
* @param string $collectionName
* @param array $options
* @return Result
*/
public
function
createCollection
(
$collectionName
,
array
$options
=
array
())
{
// TODO
}
/**
* Drop this database.
*
* @return Result
*/
public
function
drop
()
{
// TODO
}
/**
* Drop a collection within this database.
*
* @param string $collectionName
* @return Result
*/
public
function
dropCollection
(
$collectionName
)
{
// TODO
}
/**
* Returns information for all collections in this database.
*
* @see http://docs.mongodb.org/manual/reference/command/listCollections/
* @param array $options
* @return Result
*/
public
function
listCollections
(
array
$options
=
array
())
{
// TODO
}
/**
* Select a specific collection in this database
*
...
...
tests/CollectionTest.php
View file @
3db125f1
...
...
@@ -6,7 +6,7 @@ use MongoDB\Driver\Manager;
class
CollectionTest
extends
PHPUnit_Framework_TestCase
{
function
setUp
()
{
require
__DIR__
.
"/"
.
"utils.inc"
;
require
_once
__DIR__
.
"/"
.
"utils.inc"
;
$this
->
faker
=
Faker\Factory
::
create
();
$this
->
faker
->
seed
(
1234
);
...
...
@@ -44,5 +44,28 @@ class CollectionTest extends PHPUnit_Framework_TestCase {
}
$this
->
assertEquals
(
0
,
$n
);
}
public
function
testMethodOrder
()
{
$class
=
new
ReflectionClass
(
'MongoDB\Collection'
);
$filters
=
array
(
'public'
=>
ReflectionMethod
::
IS_PUBLIC
,
'protected'
=>
ReflectionMethod
::
IS_PROTECTED
,
'private'
=>
ReflectionMethod
::
IS_PRIVATE
,
);
foreach
(
$filters
as
$visibility
=>
$filter
)
{
$methods
=
array_map
(
function
(
ReflectionMethod
$method
)
{
return
$method
->
getName
();
},
$class
->
getMethods
(
$filter
)
);
$sortedMethods
=
$methods
;
sort
(
$sortedMethods
);
$this
->
assertEquals
(
$methods
,
$sortedMethods
,
sprintf
(
'%s methods are declared alphabetically'
,
ucfirst
(
$visibility
)));
}
}
}
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