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
78e4db1e
Commit
78e4db1e
authored
Feb 02, 2018
by
Jeremy Mikola
Committed by
Katherine Walker
Feb 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Consolidate TypeMapArrayIterator bad method tests
parent
f869a65a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
211 deletions
+14
-211
TypeMapArrayIteratorTest.php
tests/Model/TypeMapArrayIteratorTest.php
+14
-211
No files found.
tests/Model/TypeMapArrayIteratorTest.php
View file @
78e4db1e
...
@@ -85,130 +85,14 @@ class TypeMapArrayIteratorTest extends TestCase
...
@@ -85,130 +85,14 @@ class TypeMapArrayIteratorTest extends TestCase
$iterator
->
rewind
();
$iterator
->
rewind
();
$iterator
->
asort
();
$iterator
->
asort
();
}
/**
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessage MongoDB\Model\TypeMapArrayIterator is immutable
*/
public
function
testAsortThrowsException
()
{
$document
=
[
'array'
=>
[
1
,
2
,
3
],
'object'
=>
[
'foo'
=>
'bar'
],
];
$typeMap
=
[
'root'
=>
'object'
,
'document'
=>
'object'
,
'array'
=>
'array'
,
];
$iterator
=
new
TypeMapArrayIterator
([
$document
],
$typeMap
);
$expectedDocument
=
(
object
)
[
'array'
=>
[
1
,
2
,
3
],
'object'
=>
(
object
)
[
'foo'
=>
'bar'
],
];
$iterator
->
rewind
();
$iterator
->
asort
();
}
/**
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessage MongoDB\Model\TypeMapArrayIterator is immutable
*/
public
function
testKsortThrowsException
()
{
$document
=
[
'array'
=>
[
1
,
2
,
3
],
'object'
=>
[
'foo'
=>
'bar'
],
];
$typeMap
=
[
'root'
=>
'object'
,
'document'
=>
'object'
,
'array'
=>
'array'
,
];
$iterator
=
new
TypeMapArrayIterator
([
$document
],
$typeMap
);
$expectedDocument
=
(
object
)
[
'array'
=>
[
1
,
2
,
3
],
'object'
=>
(
object
)
[
'foo'
=>
'bar'
],
];
$iterator
->
rewind
();
$iterator
->
ksort
();
}
/**
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessage MongoDB\Model\TypeMapArrayIterator is immutable
*/
public
function
testNatcasessortThrowsException
()
{
$document
=
[
'array'
=>
[
1
,
2
,
3
],
'object'
=>
[
'foo'
=>
'bar'
],
];
$typeMap
=
[
'root'
=>
'object'
,
'document'
=>
'object'
,
'array'
=>
'array'
,
];
$iterator
=
new
TypeMapArrayIterator
([
$document
],
$typeMap
);
$expectedDocument
=
(
object
)
[
'array'
=>
[
1
,
2
,
3
],
'object'
=>
(
object
)
[
'foo'
=>
'bar'
],
];
$iterator
->
rewind
();
$iterator
->
natcasesort
();
}
/**
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessage MongoDB\Model\TypeMapArrayIterator is immutable
*/
public
function
testNatsortThrowsException
()
{
$document
=
[
'array'
=>
[
1
,
2
,
3
],
'object'
=>
[
'foo'
=>
'bar'
],
];
$typeMap
=
[
'root'
=>
'object'
,
'document'
=>
'object'
,
'array'
=>
'array'
,
];
$iterator
=
new
TypeMapArrayIterator
([
$document
],
$typeMap
);
$expectedDocument
=
(
object
)
[
'array'
=>
[
1
,
2
,
3
],
'object'
=>
(
object
)
[
'foo'
=>
'bar'
],
];
$iterator
->
rewind
();
$iterator
->
natsort
();
}
}
/**
/**
* @dataProvider provideMutateMethods
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessage MongoDB\Model\TypeMapArrayIterator is immutable
* @expectedExceptionMessage MongoDB\Model\TypeMapArrayIterator is immutable
*/
*/
public
function
test
OffsetSetThrowsException
(
)
public
function
test
MutateMethodsCannotBeCalled
(
$method
,
$args
)
{
{
$document
=
[
$document
=
[
'array'
=>
[
1
,
2
,
3
],
'array'
=>
[
1
,
2
,
3
],
...
@@ -223,104 +107,23 @@ class TypeMapArrayIteratorTest extends TestCase
...
@@ -223,104 +107,23 @@ class TypeMapArrayIteratorTest extends TestCase
$iterator
=
new
TypeMapArrayIterator
([
$document
],
$typeMap
);
$iterator
=
new
TypeMapArrayIterator
([
$document
],
$typeMap
);
$expectedDocument
=
(
object
)
[
'array'
=>
[
1
,
2
,
3
],
'object'
=>
(
object
)
[
'foo'
=>
'bar'
],
];
$iterator
->
rewind
();
$iterator
->
rewind
();
$iterator
->
offsetSet
(
0
,
3
);
call_user_func_array
([
$iterator
,
$method
],
$args
);
}
}
/**
public
function
provideMutateMethods
()
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessage MongoDB\Model\TypeMapArrayIterator is immutable
*/
public
function
testOffsetUnsetThrowsException
()
{
{
$document
=
[
return
[
'array'
=>
[
1
,
2
,
3
],
[
'append'
,
[[
'x'
=>
1
]]],
'object'
=>
[
'foo'
=>
'bar'
],
[
'asort'
,
[]],
];
[
'ksort'
,
[]],
[
'natcasesort'
,
[]],
$typeMap
=
[
[
'natsort'
,
[]],
'root'
=>
'object'
,
[
'offsetSet'
,
[
0
,
[
'x'
=>
1
]]],
'document'
=>
'object'
,
[
'offsetUnset'
,
[
0
]],
'array'
=>
'array'
,
[
'uasort'
,
[
function
(
$a
,
$b
)
{
return
0
;
}]],
];
[
'uksort'
,
[
function
(
$a
,
$b
)
{
return
0
;
}]],
$iterator
=
new
TypeMapArrayIterator
([
$document
],
$typeMap
);
$expectedDocument
=
(
object
)
[
'array'
=>
[
1
,
2
,
3
],
'object'
=>
(
object
)
[
'foo'
=>
'bar'
],
];
];
$iterator
->
rewind
();
$iterator
->
offsetUnset
(
0
);
}
/**
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessage MongoDB\Model\TypeMapArrayIterator is immutable
*/
public
function
testUasortThrowsException
()
{
$document
=
[
'array'
=>
[
1
,
2
,
3
],
'object'
=>
[
'foo'
=>
'bar'
],
];
$typeMap
=
[
'root'
=>
'object'
,
'document'
=>
'object'
,
'array'
=>
'array'
,
];
$iterator
=
new
TypeMapArrayIterator
([
$document
],
$typeMap
);
$expectedDocument
=
(
object
)
[
'array'
=>
[
1
,
2
,
3
],
'object'
=>
(
object
)
[
'foo'
=>
'bar'
],
];
$iterator
->
rewind
();
$cmp_function
=
function
(
$a
,
$b
)
{
return
$a
;
};
$iterator
->
uasort
(
$cmp_function
(
0
,
1
));
}
/**
* @expectedException MongoDB\Exception\BadMethodCallException
* @expectedExceptionMessage MongoDB\Model\TypeMapArrayIterator is immutable
*/
public
function
testUksortThrowsException
()
{
$document
=
[
'array'
=>
[
1
,
2
,
3
],
'object'
=>
[
'foo'
=>
'bar'
],
];
$typeMap
=
[
'root'
=>
'object'
,
'document'
=>
'object'
,
'array'
=>
'array'
,
];
$iterator
=
new
TypeMapArrayIterator
([
$document
],
$typeMap
);
$expectedDocument
=
(
object
)
[
'array'
=>
[
1
,
2
,
3
],
'object'
=>
(
object
)
[
'foo'
=>
'bar'
],
];
$iterator
->
rewind
();
$cmp_function
=
function
(
$a
,
$b
)
{
return
$a
;
};
$iterator
->
uksort
(
$cmp_function
(
0
,
1
));
}
}
}
}
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