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
24d34dcc
Commit
24d34dcc
authored
Mar 17, 2015
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create base classes for unit and functional tests
parent
c035baed
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
0 deletions
+67
-0
phpunit.xml.dist
phpunit.xml.dist
+2
-0
FunctionalTestCase.php
tests/FunctionalTestCase.php
+15
-0
TestCase.php
tests/TestCase.php
+50
-0
No files found.
phpunit.xml.dist
View file @
24d34dcc
...
...
@@ -16,6 +16,8 @@
<php>
<ini
name=
"error_reporting"
value=
"-1"
/>
<env
name=
"MONGODB_URI"
value=
"mongodb://localhost:27017"
/>
<env
name=
"MONGODB_DATABASE"
value=
"phplib_test"
/>
</php>
<testsuites>
...
...
tests/FunctionalTestCase.php
0 → 100644
View file @
24d34dcc
<?php
namespace
MongoDB\Tests
;
use
MongoDB\Driver\Manager
;
abstract
class
FunctionalTestCase
extends
TestCase
{
protected
$manager
;
public
function
setUp
()
{
$this
->
manager
=
new
Manager
(
$this
->
getUri
());
}
}
tests/TestCase.php
0 → 100644
View file @
24d34dcc
<?php
namespace
MongoDB\Tests
;
use
ReflectionClass
;
abstract
class
TestCase
extends
\PHPUnit_Framework_TestCase
{
/**
* Return the test collection name.
*
* @return string
*/
public
function
getCollectionName
()
{
$class
=
new
ReflectionClass
(
$this
);
return
sprintf
(
'%s.%s'
,
$class
->
getShortName
(),
$this
->
getName
(
false
));
}
/**
* Return the test database name.
*
* @return string
*/
public
function
getDatabaseName
()
{
return
getenv
(
'MONGODB_DATABASE'
)
?:
'phplib_test'
;
}
/**
* Return the test namespace.
*
* @return string
*/
public
function
getNamespace
()
{
return
sprintf
(
'%s.%s'
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
());
}
/**
* Return the connection URI.
*
* @return string
*/
public
function
getUri
()
{
return
getenv
(
'MONGODB_URI'
)
?:
'mongodb://localhost:27017'
;
}
}
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