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
3f12bc6a
Commit
3f12bc6a
authored
Sep 27, 2015
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DropDatabase functional tests
parent
cf351325
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
DropDatabaseFunctionalTest.php
tests/Operation/DropDatabaseFunctionalTest.php
+58
-0
No files found.
tests/Operation/DropDatabaseFunctionalTest.php
0 → 100644
View file @
3f12bc6a
<?php
namespace
MongoDB\Tests\Operation
;
use
MongoDB\Driver\Server
;
use
MongoDB\Operation\DropDatabase
;
use
MongoDB\Operation\ListDatabases
;
class
DropDatabaseFunctionalTest
extends
FunctionalTestCase
{
public
function
testDropExistingDatabase
()
{
$writeResult
=
$this
->
manager
->
executeInsert
(
$this
->
getNamespace
(),
array
(
'x'
=>
1
));
$this
->
assertEquals
(
1
,
$writeResult
->
getInsertedCount
());
$server
=
$this
->
getPrimaryServer
();
$operation
=
new
DropDatabase
(
$this
->
getDatabaseName
());
$operation
->
execute
(
$server
);
$this
->
assertDatabaseDoesNotExist
(
$server
,
$this
->
getDatabaseName
());
}
/**
* @depends testDropExistingDatabase
*/
public
function
testDropNonexistentDatabase
()
{
$server
=
$this
->
getPrimaryServer
();
$this
->
assertDatabaseDoesNotExist
(
$server
,
$this
->
getDatabaseName
());
$operation
=
new
DropDatabase
(
$this
->
getDatabaseName
());
$operation
->
execute
(
$server
);
}
/**
* Asserts that a database with the given name does not exist on the server.
*
* @param Server $server
* @param string $databaseName
*/
private
function
assertDatabaseDoesNotExist
(
Server
$server
,
$databaseName
)
{
$operation
=
new
ListDatabases
();
$databases
=
$operation
->
execute
(
$server
);
$foundDatabase
=
null
;
foreach
(
$databases
as
$database
)
{
if
(
$database
->
getName
()
===
$databaseName
)
{
$foundDatabase
=
$database
;
break
;
}
}
$this
->
assertNull
(
$foundDatabase
,
sprintf
(
'Database %s exists on the server'
,
$databaseName
));
}
}
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