This repository has been archived by the owner on Feb 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
279 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--TEST-- | ||
Mongo::selectCollection() | ||
--SKIPIF-- | ||
<?php require_once "tests/utils/standalone.inc"; ?> | ||
--FILE-- | ||
<?php | ||
require_once "tests/utils/server.inc"; | ||
|
||
$host = MongoShellServer::getStandaloneInfo(); | ||
$mc = new MongoClient($host); | ||
|
||
$collection = $mc->selectCollection('db', 'collection'); | ||
|
||
echo get_class($collection), "\n"; | ||
echo (string) $collection, "\n"; | ||
?> | ||
--EXPECT-- | ||
MongoCollection | ||
db.collection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--TEST-- | ||
MongoClient::selectCollection() with invalid database name | ||
--SKIPIF-- | ||
<?php require_once "tests/utils/standalone.inc" ?> | ||
--FILE-- | ||
<?php | ||
require_once "tests/utils/server.inc"; | ||
|
||
$host = MongoShellServer::getStandaloneInfo(); | ||
$mc = new MongoClient($host); | ||
|
||
echo "Testing missing database name parameter\n"; | ||
|
||
$mc->selectCollection(); | ||
|
||
echo "\nTesting database name with invalid types\n"; | ||
|
||
$mc->selectCollection(array(), 'collection'); | ||
$mc->selectCollection(new stdClass, 'collection'); | ||
|
||
echo "\nTesting empty database name\n"; | ||
|
||
try { | ||
$mc->selectCollection('', 'collection'); | ||
} catch (Exception $e) { | ||
printf("exception class: %s\n", get_class($e)); | ||
printf("exception message: %s\n", $e->getMessage()); | ||
printf("exception code: %d\n", $e->getCode()); | ||
} | ||
|
||
echo "\nTesting database name with null bytes\n"; | ||
|
||
try { | ||
$mc->selectCollection("foo\0bar", 'collection'); | ||
} catch (Exception $e) { | ||
printf("exception class: %s\n", get_class($e)); | ||
printf("exception message: %s\n", $e->getMessage()); | ||
printf("exception code: %d\n", $e->getCode()); | ||
} | ||
|
||
echo "\nTesting database name with invalid characters\n"; | ||
|
||
try { | ||
$mc->selectCollection("foo.bar", 'collection'); | ||
} catch (Exception $e) { | ||
printf("exception class: %s\n", get_class($e)); | ||
printf("exception message: %s\n", $e->getMessage()); | ||
printf("exception code: %d\n", $e->getCode()); | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
Testing missing database name parameter | ||
|
||
Warning: MongoClient::selectCollection() expects exactly 2 parameters, 0 given in %s on line %d | ||
|
||
Testing database name with invalid types | ||
|
||
Warning: MongoClient::selectCollection() expects parameter 1 to be string, array given in %s on line %d | ||
|
||
Warning: MongoClient::selectCollection() expects parameter 1 to be string, object given in %s on line %d | ||
|
||
Testing empty database name | ||
exception class: MongoException | ||
exception message: Database name cannot be empty | ||
exception code: 2 | ||
|
||
Testing database name with null bytes | ||
exception class: MongoException | ||
exception message: Database name cannot contain null bytes: foo\0... | ||
exception code: 2 | ||
|
||
Testing database name with invalid characters | ||
exception class: MongoException | ||
exception message: Database name contains invalid characters: foo.bar | ||
exception code: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--TEST-- | ||
MongoClient::selectCollection() with invalid collection name | ||
--SKIPIF-- | ||
<?php require_once "tests/utils/standalone.inc" ?> | ||
--FILE-- | ||
<?php | ||
require_once "tests/utils/server.inc"; | ||
|
||
$host = MongoShellServer::getStandaloneInfo(); | ||
$mc = new MongoClient($host); | ||
|
||
echo "Testing missing collection name parameter\n"; | ||
|
||
$mc->selectCollection('db'); | ||
|
||
echo "\nTesting collection name with invalid types\n"; | ||
|
||
$mc->selectCollection('db', array()); | ||
$mc->selectCollection('db', new stdClass); | ||
|
||
echo "\nTesting empty collection name\n"; | ||
|
||
try { | ||
$mc->selectCollection('db', ''); | ||
} catch (Exception $e) { | ||
printf("exception class: %s\n", get_class($e)); | ||
printf("exception message: %s\n", $e->getMessage()); | ||
printf("exception code: %d\n", $e->getCode()); | ||
} | ||
|
||
echo "\nTesting collection name with null bytes\n"; | ||
|
||
try { | ||
$mc->selectCollection('db', "foo\0bar"); | ||
} catch (Exception $e) { | ||
printf("exception class: %s\n", get_class($e)); | ||
printf("exception message: %s\n", $e->getMessage()); | ||
printf("exception code: %d\n", $e->getCode()); | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
Testing missing collection name parameter | ||
|
||
Warning: MongoClient::selectCollection() expects exactly 2 parameters, 1 given in %s on line %d | ||
|
||
Testing collection name with invalid types | ||
|
||
Warning: MongoClient::selectCollection() expects parameter 2 to be string, array given in %s on line %d | ||
|
||
Warning: MongoClient::selectCollection() expects parameter 2 to be string, object given in %s on line %d | ||
|
||
Testing empty collection name | ||
exception class: MongoException | ||
exception message: Collection name cannot be empty | ||
exception code: 2 | ||
|
||
Testing collection name with null bytes | ||
exception class: MongoException | ||
exception message: Collection name cannot contain null bytes: foo\0... | ||
exception code: 2 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--TEST-- | ||
Mongo::selectDB() | ||
--SKIPIF-- | ||
<?php require_once "tests/utils/standalone.inc"; ?> | ||
--FILE-- | ||
<?php | ||
require_once "tests/utils/server.inc"; | ||
|
||
$host = MongoShellServer::getStandaloneInfo(); | ||
$mc = new MongoClient($host); | ||
|
||
$db = $mc->selectDB('db'); | ||
|
||
echo get_class($db), "\n"; | ||
echo (string) $db, "\n"; | ||
?> | ||
--EXPECT-- | ||
MongoDB | ||
db |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--TEST-- | ||
MongoClient::selectDB() with invalid database name | ||
--SKIPIF-- | ||
<?php require_once "tests/utils/standalone.inc" ?> | ||
--FILE-- | ||
<?php | ||
require_once "tests/utils/server.inc"; | ||
|
||
$host = MongoShellServer::getStandaloneInfo(); | ||
$mc = new MongoClient($host); | ||
|
||
echo "Testing missing database name parameter\n"; | ||
|
||
$mc->selectDB(); | ||
|
||
echo "\nTesting database name with invalid types\n"; | ||
|
||
$mc->selectDB(array()); | ||
$mc->selectDB(new stdClass); | ||
|
||
echo "\nTesting empty database name\n"; | ||
|
||
try { | ||
$mc->selectDB(''); | ||
} catch (Exception $e) { | ||
printf("exception class: %s\n", get_class($e)); | ||
printf("exception message: %s\n", $e->getMessage()); | ||
printf("exception code: %d\n", $e->getCode()); | ||
} | ||
|
||
echo "\nTesting database name with null bytes\n"; | ||
|
||
try { | ||
$mc->selectDB("foo\0bar"); | ||
} catch (Exception $e) { | ||
printf("exception class: %s\n", get_class($e)); | ||
printf("exception message: %s\n", $e->getMessage()); | ||
printf("exception code: %d\n", $e->getCode()); | ||
} | ||
|
||
echo "\nTesting database name with invalid characters\n"; | ||
|
||
try { | ||
$mc->selectDB("foo.bar"); | ||
} catch (Exception $e) { | ||
printf("exception class: %s\n", get_class($e)); | ||
printf("exception message: %s\n", $e->getMessage()); | ||
printf("exception code: %d\n", $e->getCode()); | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
Testing missing database name parameter | ||
|
||
Warning: MongoClient::selectDB() expects exactly 1 parameter, 0 given in %s on line %d | ||
|
||
Testing database name with invalid types | ||
|
||
Warning: MongoClient::selectDB() expects parameter 1 to be string, array given in %s on line %d | ||
|
||
Warning: MongoClient::selectDB() expects parameter 1 to be string, object given in %s on line %d | ||
|
||
Testing empty database name | ||
exception class: MongoException | ||
exception message: Database name cannot be empty | ||
exception code: 2 | ||
|
||
Testing database name with null bytes | ||
exception class: MongoException | ||
exception message: Database name cannot contain null bytes: foo\0... | ||
exception code: 2 | ||
|
||
Testing database name with invalid characters | ||
exception class: MongoException | ||
exception message: Database name contains invalid characters: foo.bar | ||
exception code: 2 |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.