99final class QueueTest extends \PHPUnit_Framework_TestCase
1010{
1111 private $ _collection ;
12+ private $ _mongoUrl ;
1213 private $ _queue ;
1314
1415 public function setUp ()
1516 {
16- $ mongo = new \MongoClient ('mongodb://localhost ' );
17+ $ this ->_mongoUrl = getenv ('TESTING_MONGO_URL ' ) ?: 'mongodb://localhost:27017 ' ;
18+ $ mongo = new \MongoClient ($ this ->_mongoUrl );
1719 $ this ->_collection = $ mongo ->selectDB ('testing ' )->selectCollection ('messages ' );
1820 $ this ->_collection ->drop ();
1921
20- $ this ->_queue = new Queue (' mongodb://localhost ' , 'testing ' , 'messages ' );
22+ $ this ->_queue = new Queue ($ this -> _mongoUrl , 'testing ' , 'messages ' );
2123 }
2224
2325 /**
@@ -37,7 +39,7 @@ public function constructWithNonStringUrl()
3739 */
3840 public function constructWithNonStringDb ()
3941 {
40- new Queue (' mongodb://localhost ' , true , 'messages ' );
42+ new Queue ($ this -> _mongoUrl , true , 'messages ' );
4143 }
4244
4345 /**
@@ -47,7 +49,7 @@ public function constructWithNonStringDb()
4749 */
4850 public function constructWithNonStringCollection ()
4951 {
50- new Queue (' mongodb://localhost ' , 'testing ' , new \stdClass ());
52+ new Queue ($ this -> _mongoUrl , 'testing ' , new \stdClass ());
5153 }
5254
5355 /**
@@ -84,7 +86,7 @@ public function ensureGetIndexWithTooLongCollectionName()
8486 $ collectionName = 'messages012345678901234567890123456789012345678901234567890123456789 ' ;
8587 $ collectionName .= '012345678901234567890123456789012345678901234567890123456789 ' ;//128 chars
8688
87- $ queue = new Queue (' mongodb://localhost ' , 'testing ' , $ collectionName );
89+ $ queue = new Queue ($ this -> _mongoUrl , 'testing ' , $ collectionName );
8890 $ queue ->ensureGetIndex (array ());
8991 }
9092
0 commit comments