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
ae97a8d9
Commit
ae97a8d9
authored
Dec 16, 2015
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move invalid data providers to base TestCase class
parent
a4992db2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
40 deletions
+81
-40
BulkWriteTest.php
tests/Operation/BulkWriteTest.php
+5
-0
TestCase.php
tests/Operation/TestCase.php
+0
-40
TestCase.php
tests/TestCase.php
+76
-0
No files found.
tests/Operation/BulkWriteTest.php
View file @
ae97a8d9
...
...
@@ -341,6 +341,11 @@ class BulkWriteTest extends TestCase
);
}
public
function
provideInvalidBooleanValues
()
{
return
$this
->
wrapValuesForDataProvider
(
$this
->
getInvalidBooleanValues
());
}
public
function
provideInvalidConstructorOptions
()
{
$options
=
[];
...
...
tests/Operation/TestCase.php
View file @
ae97a8d9
...
...
@@ -3,50 +3,10 @@
namespace
MongoDB\Tests\Operation
;
use
MongoDB\Tests\TestCase
as
BaseTestCase
;
use
stdClass
;
/**
* Base class for Operation unit tests.
*/
abstract
class
TestCase
extends
BaseTestCase
{
public
function
provideInvalidDocumentValues
()
{
return
$this
->
wrapValuesForDataProvider
(
$this
->
getInvalidDocumentValues
());
}
public
function
provideInvalidBooleanValues
()
{
return
$this
->
wrapValuesForDataProvider
(
$this
->
getInvalidBooleanValues
());
}
protected
function
getInvalidArrayValues
()
{
return
[
123
,
3.14
,
'foo'
,
true
,
new
stdClass
];
}
protected
function
getInvalidBooleanValues
()
{
return
[
123
,
3.14
,
'foo'
,
[],
new
stdClass
];
}
protected
function
getInvalidDocumentValues
()
{
return
[
123
,
3.14
,
'foo'
,
true
];
}
protected
function
getInvalidIntegerValues
()
{
return
[
3.14
,
'foo'
,
true
,
[],
new
stdClass
];
}
protected
function
getInvalidStringValues
()
{
return
[
123
,
3.14
,
true
,
[],
new
stdClass
];
}
protected
function
wrapValuesForDataProvider
(
array
$values
)
{
return
array_map
(
function
(
$value
)
{
return
[
$value
];
},
$values
);
}
}
tests/TestCase.php
View file @
ae97a8d9
...
...
@@ -7,6 +7,11 @@ use stdClass;
abstract
class
TestCase
extends
\PHPUnit_Framework_TestCase
{
public
function
provideInvalidDocumentValues
()
{
return
$this
->
wrapValuesForDataProvider
(
$this
->
getInvalidDocumentValues
());
}
/**
* Return the test collection name.
*
...
...
@@ -29,11 +34,71 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
return
getenv
(
'MONGODB_DATABASE'
)
?:
'phplib_test'
;
}
/**
* Return a list of invalid array values.
*
* @return array
*/
protected
function
getInvalidArrayValues
()
{
return
[
123
,
3.14
,
'foo'
,
true
,
new
stdClass
];
}
/**
* Return a list of invalid boolean values.
*
* @return array
*/
protected
function
getInvalidBooleanValues
()
{
return
[
123
,
3.14
,
'foo'
,
[],
new
stdClass
];
}
/**
* Return a list of invalid document values.
*
* @return array
*/
protected
function
getInvalidDocumentValues
()
{
return
[
123
,
3.14
,
'foo'
,
true
];
}
/**
* Return a list of invalid integer values.
*
* @return array
*/
protected
function
getInvalidIntegerValues
()
{
return
[
3.14
,
'foo'
,
true
,
[],
new
stdClass
];
}
/**
* Return a list of invalid ReadPreference values.
*
* @return array
*/
protected
function
getInvalidReadPreferenceValues
()
{
return
[
123
,
3.14
,
'foo'
,
true
,
[],
new
stdClass
];
}
/**
* Return a list of invalid string values.
*
* @return array
*/
protected
function
getInvalidStringValues
()
{
return
[
123
,
3.14
,
true
,
[],
new
stdClass
];
}
/**
* Return a list of invalid WriteConcern values.
*
* @return array
*/
protected
function
getInvalidWriteConcernValues
()
{
return
[
123
,
3.14
,
'foo'
,
true
,
[],
new
stdClass
];
...
...
@@ -58,4 +123,15 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
{
return
getenv
(
'MONGODB_URI'
)
?:
'mongodb://127.0.0.1:27017'
;
}
/**
* Wrap a list of values for use as a single-argument data provider.
*
* @param array $values List of values
* @return array
*/
protected
function
wrapValuesForDataProvider
(
array
$values
)
{
return
array_map
(
function
(
$value
)
{
return
[
$value
];
},
$values
);
}
}
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