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
97ab718e
Commit
97ab718e
authored
Apr 26, 2015
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-79: Add __debugInfo() handlers for info classes
parent
87932a56
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
70 additions
and
1 deletion
+70
-1
CollectionInfo.php
src/Model/CollectionInfo.php
+11
-0
DatabaseInfo.php
src/Model/DatabaseInfo.php
+11
-0
IndexInfo.php
src/Model/IndexInfo.php
+11
-0
CollectionInfoTest.php
tests/Model/CollectionInfoTest.php
+11
-0
DatabaseInfoTest.php
tests/Model/DatabaseInfoTest.php
+13
-1
IndexInfoTest.php
tests/Model/IndexInfoTest.php
+13
-0
No files found.
src/Model/CollectionInfo.php
View file @
97ab718e
...
@@ -76,4 +76,15 @@ class CollectionInfo
...
@@ -76,4 +76,15 @@ class CollectionInfo
{
{
return
isset
(
$this
->
info
[
'options'
][
'size'
])
?
(
integer
)
$this
->
info
[
'options'
][
'size'
]
:
null
;
return
isset
(
$this
->
info
[
'options'
][
'size'
])
?
(
integer
)
$this
->
info
[
'options'
][
'size'
]
:
null
;
}
}
/**
* Return the collection info as an array.
*
* @see http://php.net/oop5.magic#language.oop5.magic.debuginfo
* @return array
*/
public
function
__debugInfo
()
{
return
$this
->
info
;
}
}
}
src/Model/DatabaseInfo.php
View file @
97ab718e
...
@@ -55,4 +55,15 @@ class DatabaseInfo
...
@@ -55,4 +55,15 @@ class DatabaseInfo
{
{
return
(
boolean
)
$this
->
info
[
'empty'
];
return
(
boolean
)
$this
->
info
[
'empty'
];
}
}
/**
* Return the collection info as an array.
*
* @see http://php.net/oop5.magic#language.oop5.magic.debuginfo
* @return array
*/
public
function
__debugInfo
()
{
return
$this
->
info
;
}
}
}
src/Model/IndexInfo.php
View file @
97ab718e
...
@@ -157,4 +157,15 @@ class IndexInfo implements ArrayAccess
...
@@ -157,4 +157,15 @@ class IndexInfo implements ArrayAccess
{
{
throw
new
BadMethodCallException
(
'IndexInfo is immutable'
);
throw
new
BadMethodCallException
(
'IndexInfo is immutable'
);
}
}
/**
* Return the collection info as an array.
*
* @see http://php.net/oop5.magic#language.oop5.magic.debuginfo
* @return array
*/
public
function
__debugInfo
()
{
return
$this
->
info
;
}
}
}
tests/Model/CollectionInfoTest.php
View file @
97ab718e
...
@@ -39,4 +39,15 @@ class CollectionInfoTest extends TestCase
...
@@ -39,4 +39,15 @@ class CollectionInfoTest extends TestCase
$this
->
assertSame
(
100
,
$info
->
getCappedMax
());
$this
->
assertSame
(
100
,
$info
->
getCappedMax
());
$this
->
assertSame
(
1048576
,
$info
->
getCappedSize
());
$this
->
assertSame
(
1048576
,
$info
->
getCappedSize
());
}
}
public
function
testDebugInfo
()
{
$expectedInfo
=
array
(
'name'
=>
'foo'
,
'options'
=>
array
(
'capped'
=>
true
,
'size'
=>
1048576
),
);
$info
=
new
CollectionInfo
(
$expectedInfo
);
$this
->
assertSame
(
$expectedInfo
,
$info
->
__debugInfo
());
}
}
}
tests/Model/DatabaseInfoTest.php
View file @
97ab718e
...
@@ -15,7 +15,7 @@ class DatabaseInfoTest extends TestCase
...
@@ -15,7 +15,7 @@ class DatabaseInfoTest extends TestCase
public
function
testGetSizeOnDisk
()
public
function
testGetSizeOnDisk
()
{
{
$info
=
new
DatabaseInfo
(
array
(
'sizeOnDisk'
=>
'1048576'
));
$info
=
new
DatabaseInfo
(
array
(
'sizeOnDisk'
=>
1048576
));
$this
->
assertSame
(
1048576
,
$info
->
getSizeOnDisk
());
$this
->
assertSame
(
1048576
,
$info
->
getSizeOnDisk
());
}
}
...
@@ -27,4 +27,16 @@ class DatabaseInfoTest extends TestCase
...
@@ -27,4 +27,16 @@ class DatabaseInfoTest extends TestCase
$info
=
new
DatabaseInfo
(
array
(
'empty'
=>
true
));
$info
=
new
DatabaseInfo
(
array
(
'empty'
=>
true
));
$this
->
assertTrue
(
$info
->
isEmpty
());
$this
->
assertTrue
(
$info
->
isEmpty
());
}
}
public
function
testDebugInfo
()
{
$expectedInfo
=
array
(
'name'
=>
'foo'
,
'sizeOnDisk'
=>
1048576
,
'empty'
=>
false
,
);
$info
=
new
DatabaseInfo
(
$expectedInfo
);
$this
->
assertSame
(
$expectedInfo
,
$info
->
__debugInfo
());
}
}
}
tests/Model/IndexInfoTest.php
View file @
97ab718e
...
@@ -83,4 +83,17 @@ class IndexInfoTest extends TestCase
...
@@ -83,4 +83,17 @@ class IndexInfoTest extends TestCase
$this
->
assertTrue
(
isset
(
$info
[
'expireAfterSeconds'
]));
$this
->
assertTrue
(
isset
(
$info
[
'expireAfterSeconds'
]));
$this
->
assertSame
(
100
,
$info
[
'expireAfterSeconds'
]);
$this
->
assertSame
(
100
,
$info
[
'expireAfterSeconds'
]);
}
}
public
function
testDebugInfo
()
{
$expectedInfo
=
array
(
'v'
=>
1
,
'key'
=>
array
(
'x'
=>
1
),
'name'
=>
'x_1'
,
'ns'
=>
'foo.bar'
,
);
$info
=
new
IndexInfo
(
$expectedInfo
);
$this
->
assertSame
(
$expectedInfo
,
$info
->
__debugInfo
());
}
}
}
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