usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rockers...@apache.org
Subject [27/45] incubator-usergrid git commit: done tests and added example file. To run the tests you need to add your details to the test_config.php file in the tests folder Also for tests use client_id & client_secret and a auth_type of Organisation . Example
Date Wed, 12 Nov 2014 01:15:32 GMT
done tests and added example file. To run the tests you need to add your details to the test_config.php file in the tests folder Also for tests use client_id & client_secret and a auth_type of Organisation .
Examples.php file contain most api calls but its more then enough to work out whats what. Also going through the manifest files you can see which param are required for which calls and the api will let you know if there is a param missing that is required.


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/3c6ebe83
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/3c6ebe83
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/3c6ebe83

Branch: refs/heads/master
Commit: 3c6ebe835547c39236c7eb2aed5e92291af680f8
Parents: b79f615
Author: Jason Kristian <jasonk@apps4u.com.au>
Authored: Sat Nov 1 16:37:17 2014 +1000
Committer: Jason Kristian <jasonk@apps4u.com.au>
Committed: Sat Nov 1 16:37:17 2014 +1000

----------------------------------------------------------------------
 sdks/php5/apache-usergrid/examples.php          | 244 ++++++++++++
 .../src/Manifests/1.0.1/Application.php         | 169 +++++++--
 .../src/Manifests/1.0.1/Custom.php              | 380 +++++++++++++++++++
 .../src/Manifests/1.0.1/Groups.php              | 106 +++++-
 .../tests/Api/ApplicationTest.php               |  43 +--
 .../Api/Exception/BadRequestExceptionTest.php   |  58 +++
 .../Api/Exception/InvalidIdExceptionTest.php    |  58 +++
 .../Api/Exception/NotFoundExceptionTest.php     |  58 +++
 .../Api/Exception/ServerErrorExceptionTest.php  |  58 +++
 .../Api/Exception/UnauthorizedExceptionTest.php |  59 +++
 .../tests/Api/ManagementTest.php                |  45 +--
 .../apache-usergrid/tests/Api/UsergridTest.php  |  64 +---
 .../apache-usergrid/tests/Api/test_config.php   |  65 ++++
 13 files changed, 1265 insertions(+), 142 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3c6ebe83/sdks/php5/apache-usergrid/examples.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/examples.php b/sdks/php5/apache-usergrid/examples.php
new file mode 100644
index 0000000..f139808
--- /dev/null
+++ b/sdks/php5/apache-usergrid/examples.php
@@ -0,0 +1,244 @@
+<?php
+/**
+ * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+include('vendor/autoload.php');
+
+
+use Apache\Usergrid\Native\UsergridBootstrapper;
+use Apache\Usergrid\Native\Facades\Usergrid;
+
+/** Source your config from file I'm using array here just for ease of use.
+ * When using Laravel Framework publish the package config file when using with
+ * other modern PHP frameworks just use their default config system .
+ */
+$config = [
+    'usergrid' => [
+        'url' => 'https://api.usergrid.com',
+        'version' => '1.0.1', // set manifest version
+        'orgName' => '',
+        'appName' => '',
+        'manifestPath' => './src/Manifests', //leave as default or change to your own custom folder
+        'clientId' => '',
+        'clientSecret' => '',
+        'username' => '',
+        'password' => '',
+        /**
+         * The Auth Type setting is the Oauth 2 end point you want to get the OAuth 2
+         * Token from.  You have two options here one is 'application' the other is 'organization'
+         *
+         *  organization will get the the token from http://example.com/management using  client_credentials or password grant type
+         *  application will get the token from http://example.com/managment/org_name/app_name using client_credentials or password grant type
+         */
+        'auth_type' => 'application',
+        /** The Grant Type to use
+         *
+         * This has to be set to one of the 2 grant types that Apache Usergrid
+         * supports which at the moment is client_credentials or password but at
+         * 2 level organization or application
+         */
+        'grant_type' => 'password',
+        /**
+         * if you want to manage your own auth flow by calling the token api and setting the token your self just set this to false
+         * */
+        'enable_oauth2_plugin' => true
+    ]
+];
+
+/** Usergrid Facades Off */
+
+//call the bootstrap class that will create the api client then get the usergrid instance from the bootstrapper
+$bootstrapper = new UsergridBootstrapper($config);
+$usergrid = $bootstrapper->createUsergrid();
+
+/** Note: I'm using Users for the first lot of example's but you could do the same for all default collections eg: groups, devices, roles, notification etc*/
+
+//find users with query
+$user = $usergrid->users()->find(['ql' => 'select * where activated=true']);
+
+//var_dump($user->first());
+
+//request that throw exception in this case 404 not found
+try {
+
+    $user2 = $usergrid->users()->findById(['uuid' => 'uuid-number']);
+//    var_dump($user2->get('entities'));
+} catch (Apache\Usergrid\Api\Exception\NotFoundException $e) {
+
+//    var_dump($e->getResponse());
+}
+/**
+ * There a errors for all Usergrid response errors and http errors so you can create a catch all error class or plug it into your fav php frameworks error handling.
+ * Apache\Usergrid\Api\Exception\BadRequestException = http 400
+ * Apache\Usergrid\Api\Exception\UnauthorizedException = http 401
+ * Apache\Usergrid\Api\Exception\RequestFailedException = http 402
+ * Apache\Usergrid\Api\Exception\NotFoundException = http 404
+ * Apache\Usergrid\Api\Exception\ServerErrorException = http 500
+ * Apache\Usergrid\Api\Exception\ServerErrorException = http 502
+ * Apache\Usergrid\Api\Exception\ServerErrorException = http 503
+ * Apache\Usergrid\Api\Exception\ServerErrorException = http 504
+ */
+
+// collection Iterators no need to keep calling request with a cursor to get all entities in a collection
+// UserIterator(), DeviceIterator() GroupsIterator() , RolesIterator() etc.
+$user_iterator = $usergrid->usersIterator();
+
+foreach ($user_iterator as $iUser) {
+    var_dump($iUser);
+    var_dump("---------------------------------------------------------------------------------");
+}
+
+// create new user
+$new_user = ['name' => 'jasonk', 'username' => 'JasonK', 'email' => 'jason@example.com', 'password' => 'some_password'];
+//$created_user = $usergrid->users()->create($new_user);
+//var_dump($created_user);
+
+//Update Users by name or uuid
+$new_email = ['email' => 'jason@example', 'entity_name_or_uuid' => 'benn'];
+$updated_user = $usergrid->users()->update($new_email);
+//var_dump($updated_user);
+
+// delete a user
+//$deleted_user = $usergrid->users()->delete(['entity_name_or_uuid' => 'benn']);
+//var_dump($deleted_user);
+
+//get custom collection
+$custom_collection = $usergrid->application()->EntityGet(['collection' => 'shops']);
+//var_dump($custom_collection->get('entities'));
+
+//get custom collection with query
+$custom_collection_query = $usergrid->application()->EntityGet([
+    'collection' => 'shops',
+    'ql' => "select * where country='aus'"
+]);
+//var_dump($custom_collection_query->get('entities'));
+
+// Post custom collection as JSON data
+$custom_entity = [
+    'collection' => 'shops',
+    'name' => 'shop_name',
+    'adr' => ['street' => '1 main st', 'location' => 'sydney', 'post_code' => '2323'],
+    'type' => 'pet_shop'
+];
+//$created_entity = $usergrid->application()->EntityJsonPost($custom_entity);
+//var_dump($created_entity);
+
+// update custom Entity
+$custom_entity_edit = [
+    'collection' => 'shops',
+    'entity_name_or_uuid' => '918a044a-618a-11e4-8c11-253e9c3723a9',
+    ['adr' => ['street' => '3 main st', 'location' => 'act', 'post_code' => '3323']]
+];
+$edited_entity = $usergrid->application()->EntityPut($custom_entity_edit);
+
+
+/** Usergrid Facades On */
+
+//create a bootstrap instance and then call the static instance method on the Usergrid facade
+$bootstrapper2 = new UsergridBootstrapper($config);
+Usergrid::instance($bootstrapper2);
+
+
+// find users with query
+$fUser = Usergrid::users()->find(['ql' => 'select * where activated=true']);
+
+$fUser_iterator = Usergrid::usersIterator();
+
+foreach ($fUser_iterator as $iUser) {
+    var_dump($iUser);
+    var_dump("---------------------------------------------------------------------------------");
+}
+
+// create new user
+$fNew_user = [
+    'name' => 'jasonk',
+    'username' => 'JasonK2',
+    'email' => 'jaso2n@example.com',
+    'password' => 'some_password'
+];
+$fCreated_user = Usergrid::users()->create($fNew_user);
+//var_dump($fCreated_user);
+
+//Update Users by name or uuid
+$fNew_email = ['email' => 'jason@example', 'entity_name_or_uuid' => 'benn'];
+$fUpdated_user = Usergrid::users()->update($fNew_email);
+//var_dump($fUpdated_user);
+
+// delete a user
+$fDeleted_user = Usergrid::users()->delete(['entity_name_or_uuid' => 'benn']);
+//var_dump($fDeleted_user);
+
+//get custom collection
+$fCustom_collection = Usergrid::application()->EntityGet(['collection' => 'shops']);
+//var_dump($custom_collection->get('entities'));
+
+//get custom collection with query
+$fCustom_collection_query = Usergrid::application()->EntityGet([
+    'collection' => 'shops',
+    'ql' => "select * where country='aus'"
+]);
+//var_dump($custom_collection_query->get('entities'));
+
+// Post custom collection as JSON data
+$fCustom_entity = [
+    'collection' => 'shops',
+    'name' => 'shop_name3',
+    'adr' => ['street' => '1 main st', 'location' => 'sydney', 'post_code' => '2323'],
+    'type' => 'pet_shop'
+];
+$fCreated_entity = Usergrid::applictions()->EntityJsonPost($custom_entity);
+//var_dump($fCreated_entity);
+
+// update entity
+$fCustom_entity_edit = [
+    'collection' => 'shops',
+    'entity_name_or_uuid' => 'shop_name2',
+    ['adr' => ['street' => '3 main st', 'location' => 'act', 'post_code' => '3323']]
+];
+$fEdited_entity = Usergrid::applications()->EntityPut($fCustom_entity_edit);
+//var_dump($fEdited_entity);
+
+
+
+/** Relationships */
+$related_data =[
+    'collection' => 'required',
+    'entity_id' => 'required',
+    'relationship' => 'required',
+    'ql' => 'optional'
+];
+$get_relationship = Usergrid::application()->GetRelationship($related_data);
+
+
+$create_relationship_data = [
+    'collection' => 'required',
+    'first_entity_id' => 'required',
+    'relationship' => 'required',
+    'second_entity_id' => 'required'
+];
+$new_relationship = Usergrid::application()->CreateRelationship($create_relationship_data);
+
+
+/** Groups  */
+
+//add user to group
+$fAdd_user_to_group_data = [
+    'entity_name_or_uuid' => 'group_name',
+    'user_name_or_uuid' => 'username'
+];
+$fAdded_user_to_group = Usergrid::groups()->addUser($fAdd_user_to_group_data);
+
+//delete user from group
+$fDeleted_user_from_group = Usergrid::groups()->deleteUser($fAdd_user_to_group_data);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3c6ebe83/sdks/php5/apache-usergrid/src/Manifests/1.0.1/Application.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Manifests/1.0.1/Application.php b/sdks/php5/apache-usergrid/src/Manifests/1.0.1/Application.php
index 64f8cbc..f0d49fb 100644
--- a/sdks/php5/apache-usergrid/src/Manifests/1.0.1/Application.php
+++ b/sdks/php5/apache-usergrid/src/Manifests/1.0.1/Application.php
@@ -965,36 +965,147 @@ return [
         ]
     ],
 
-    //Application Groups
-    'CreateGroups' => [],
-    'AddUserToGroups' => [],
-    'GetGroups' => [],
-    'PutGroups' => [],
-    'DeleteUserFromGroups' => [],
-    'GetGroupsFeeds' => [],
-    'AddGroupUser' => [],
 
 
-    //Application Roles
-    'CreateRole' => [],
-    'GetRole' => [],
-    'DeleteRole' => [],
-    'GetRolePermission' => [],
-    'AddRolePermission' => [],
-    'DeleteRolePermission' => [],
-    'AddRoleUser' => [],
-    'GetRoleUsers' => [],
-    'DeleteRoleUser' => [],
-
-    //Application Users
-    'CreateUser' => [],
-    'GetUser' => [],
-    'UpdateUser' => [],
-    'DeleteUser' => [],
-    'AddUserConnection' => [],
-    'DeleteUserConnection' => [],
-    'GetUserConnections' => [],
-    'GetUserFeed' => []
-
     //Application Collection Relationships
+    'GetRelationship' => [
+        'httpMethod' => 'GET',
+        'uri' => '/{org_name_or_uuid}/{app_name_or_uuid}/{collection}/{entity_id}/{relationship}',
+        'notes' => 'Query an Entity Relationship ',
+        'summary' => 'Query an Entity Relationship',
+        'responseClass' => 'Apache\Usergrid\Api\Models\Collection',
+        'responseType' => 'class',
+        'errorResponses' => $errors,
+        'parameters' => [
+            'app_name_or_uuid' => [
+                'description' => 'app name or uuid',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'collection' => [
+                'description' => 'collection name (entity type)',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'entity_id' => [
+                'description' => 'Entity  ID (uuid)',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'relationship' => [
+                'description' => 'Relationship',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'access_token' => [
+                'description' => 'The OAuth2 access token',
+                'location' => 'query',
+                'type' => 'string',
+                'required' => false,
+            ],
+            'ql' => [
+                'description' => 'a query in the query language',
+                'location' => 'query',
+                'type' => 'string',
+                'required' => false,
+            ],
+            'reversed' => [
+                'description' => 'return results in reverse order',
+                'location' => 'query',
+                'type' => 'boolean',
+                'required' => false,
+            ],
+            'start' => [
+                'description' => 'the first entity UUID to return',
+                'location' => 'query',
+                'type' => 'string',
+                'required' => false,
+            ],
+            'cursor' => [
+                'description' => 'an encoded representation of the query position for paging',
+                'location' => 'query',
+                'type' => 'string',
+                'required' => false,
+            ],
+            'limit' => [
+                'description' => 'an encoded representation of the query position for paging',
+                'location' => 'query',
+                'type' => 'integer',
+                'required' => false,
+            ],
+            'filter' => [
+                'description' => 'a condition to filter on',
+                'location' => 'query',
+                'type' => 'integer',
+                'required' => false,
+            ],
+            'org_name_or_uuid' => [
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+                'description' => 'Organization name or uuid'
+            ]
+        ]
+    ],
+    'CreateRelationship' => [
+        'httpMethod' => 'POST',
+        'uri' => '/{org_name_or_uuid}/{app_name_or_uuid}/{collection}/{first_entity_id}/{relationship}/{second_entity_id}',
+        'notes' => 'Create new app entity.  See Usergrid documentation for JSON format of body.',
+        'summary' => 'Create new app entity',
+        'responseClass' => '',
+        'responseType' => 'model',
+        'errorResponses' => $errors,
+        'parameters' => [
+            'app_name_or_uuid' => [
+                'description' => 'app name or uuid',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'collection' => [
+                'description' => 'collection name (entity type)',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'first_entity_id' => [
+                'description' => 'first entity id (uuid)',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'relationship' => [
+                'description' => 'relationship',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'second_entity_id' => [
+                'description' => '2nd entity id (uuid)',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'access_token' => [
+                'description' => 'The OAuth2 access token',
+                'location' => 'query',
+                'type' => 'string',
+                'required' => false,
+            ],
+            'org_name_or_uuid' => [
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+                'description' => 'Organization name or uuid'
+            ]
+        ],
+        'additionalParameters' => [
+            "description" => "Entity data",
+            'location' => 'json'
+        ]
+    ],
 ];
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3c6ebe83/sdks/php5/apache-usergrid/src/Manifests/1.0.1/Custom.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Manifests/1.0.1/Custom.php b/sdks/php5/apache-usergrid/src/Manifests/1.0.1/Custom.php
new file mode 100644
index 0000000..e5b94b3
--- /dev/null
+++ b/sdks/php5/apache-usergrid/src/Manifests/1.0.1/Custom.php
@@ -0,0 +1,380 @@
+<?php
+/**
+ * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+return [
+
+    'all' => [
+        'httpMethod' => 'GET',
+        'uri' => '/{org_name_or_uuid}/{app_name_or_uuid}/{collection}',
+        'notes' => 'Query an app collection.',
+        'summary' => 'Query an app collection',
+        'responseClass' => 'Apache\Usergrid\Api\Models\Collection',
+        'responseType' => 'model',
+        'errorResponses' => $errors,
+        'parameters' => [
+            'app_name_or_uuid' => [
+                'description' => 'app name or uuid',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'org_name_or_uuid' => [
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+                'description' => 'Organization name or uuid'
+            ],
+            'collection' => [
+                'description' => 'collection name (entity type)',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+                'default' => $custom
+            ],
+            'access_token' => [
+                'description' => 'The OAuth2 access token',
+                'location' => 'query',
+                'type' => 'string',
+                'required' => false,
+            ],
+            'ql' => [
+                'description' => 'a query in the query language',
+                'location' => 'query',
+                'type' => 'string',
+                'required' => false,
+            ],
+            'reversed' => [
+                'description' => 'return results in reverse order',
+                'location' => 'query',
+                'type' => 'boolean',
+                'required' => false,
+            ],
+            'start' => [
+                'description' => 'the first entity UUID to return',
+                'location' => 'query',
+                'type' => 'string',
+                'required' => false,
+            ],
+            'cursor' => [
+                'description' => 'an encoded representation of the query position for paging',
+                'location' => 'query',
+                'type' => 'string',
+                'required' => false,
+            ],
+            'limit' => [
+                'description' => 'an encoded representation of the query position for paging',
+                'location' => 'query',
+                'type' => 'integer',
+                'required' => false,
+            ],
+            'filter' => [
+                'description' => 'a condition to filter on',
+                'location' => 'query',
+                'type' => 'integer',
+                'required' => false,
+            ]
+        ],
+        'additionalParameters' => [
+            "description" => "Other parameters",
+            'location' => 'query'
+        ]
+    ],
+    'find' => [
+        'httpMethod' => 'GET',
+        'uri' => '/{org_name_or_uuid}/{app_name_or_uuid}/{collection}',
+        'notes' => 'Query Users.',
+        'summary' => 'Query the users collection',
+        'responseClass' => 'Apache\Usergrid\Api\Models\User',
+        'responseType' => 'model',
+        'errorResponses' => $errors,
+        'parameters' => [
+            'app_name_or_uuid' => [
+                'description' => 'app name or uuid',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'org_name_or_uuid' => [
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+                'description' => 'Organization name or uuid'
+            ],
+            'collection' => [
+                'description' => 'collection name (entity type)',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+                'default' => $custom
+            ],
+            'access_token' => [
+                'description' => 'The OAuth2 access token',
+                'location' => 'query',
+                'type' => 'string',
+                'required' => false,
+            ],
+            'ql' => [
+                'description' => 'a query in the query language',
+                'location' => 'query',
+                'type' => 'string',
+                'required' => false,
+            ],
+            'reversed' => [
+                'description' => 'return results in reverse order',
+                'location' => 'query',
+                'type' => 'boolean',
+                'required' => false,
+            ],
+            'start' => [
+                'description' => 'the first entity UUID to return',
+                'location' => 'query',
+                'type' => 'string',
+                'required' => false,
+            ],
+            'cursor' => [
+                'description' => 'an encoded representation of the query position for paging',
+                'location' => 'query',
+                'type' => 'string',
+                'required' => false,
+            ],
+            'limit' => [
+                'description' => 'an encoded representation of the query position for paging',
+                'location' => 'query',
+                'type' => 'integer',
+                'required' => false,
+            ],
+            'filter' => [
+                'description' => 'a condition to filter on',
+                'location' => 'query',
+                'type' => 'integer',
+                'required' => false,
+            ]
+        ],
+        'additionalParameters' => [
+            "description" => "Other parameters",
+            'location' => 'query'
+        ]
+    ],
+    'findById' => ['httpMethod' => 'GET',
+        'uri' => '/{org_name_or_uuid}/{app_name_or_uuid}/{collection}/{uuid}',
+        'notes' => 'Find User by uuid.',
+        'summary' => 'Find user by uuid',
+        'responseClass' => 'Apache\Usergrid\Api\Models\User',
+        'responseType' => 'model',
+        'errorResponses' => $errors,
+        'parameters' => [
+            'app_name_or_uuid' => [
+                'description' => 'app name or uuid',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'org_name_or_uuid' => [
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+                'description' => 'Organization name or uuid'
+            ],
+            'collection' => [
+                'description' => 'collection name (entity type)',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+                'default' => $custom
+            ],
+            'uuid' => [
+                'description' => 'User UUID (entity uuid)',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true
+            ],
+            'access_token' => [
+                'description' => 'The OAuth2 access token',
+                'location' => 'query',
+                'type' => 'string',
+                'required' => false,
+            ],
+            'ql' => [
+                'description' => 'a query in the query language',
+                'location' => 'query',
+                'type' => 'string',
+                'required' => false,
+            ],
+            'reversed' => [
+                'description' => 'return results in reverse order',
+                'location' => 'query',
+                'type' => 'boolean',
+                'required' => false,
+            ],
+            'start' => [
+                'description' => 'the first entity UUID to return',
+                'location' => 'query',
+                'type' => 'string',
+                'required' => false,
+            ],
+            'cursor' => [
+                'description' => 'an encoded representation of the query position for paging',
+                'location' => 'query',
+                'type' => 'string',
+                'required' => false,
+            ],
+            'limit' => [
+                'description' => 'an encoded representation of the query position for paging',
+                'location' => 'query',
+                'type' => 'integer',
+                'required' => false,
+            ],
+            'filter' => [
+                'description' => 'a condition to filter on',
+                'location' => 'query',
+                'type' => 'integer',
+                'required' => false,
+            ]
+        ],
+        'additionalParameters' => [
+            "description" => "Other parameters",
+            'location' => 'query'
+        ]
+    ],
+    'create' => [
+        'httpMethod' => 'POST',
+        'uri' => '/{org_name_or_uuid}/{app_name_or_uuid}/{collection}',
+        'notes' => 'Create new User.  See Usergrid documentation for JSON format of body.',
+        'summary' => 'Create new User entity',
+        'responseClass' => 'Apache\Usergrid\Api\Models\User',
+        'responseType' => 'model',
+        'errorResponses' => $errors,
+        'parameters' => [
+            'app_name_or_uuid' => [
+                'description' => 'app name or uuid',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'collection' => [
+                'description' => 'collection name (entity type)',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+                'default' => $custom
+            ],
+            'access_token' => [
+                'description' => 'The OAuth2 access token',
+                'location' => 'query',
+                'type' => 'string',
+                'required' => false,
+            ],
+            'org_name_or_uuid' => [
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+                'description' => 'Organization name or uuid'
+            ]
+        ],
+        'additionalParameters' => [
+            "description" => "Entity data",
+            'location' => 'json'
+        ]
+    ],
+    'destroy' => [
+        'httpMethod' => 'DELETE',
+        'uri' => '/{org_name_or_uuid}/{app_name_or_uuid}/{collection}/{entity_name_or_uuid}',
+        'notes' => 'Delete a User entity.',
+        'summary' => 'Delete a User entity by name or uuid',
+        'responseClass' => 'Apache\Usergrid\Api\Models\User',
+        'responseType' => 'model',
+        'errorResponses' => $errors,
+        'parameters' => [
+            'app_name_or_uuid' => [
+                'description' => 'app name or uuid',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'entity_name_or_uuid' => [
+                'description' => 'entity name or uuid',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'collection' => [
+                'description' => 'collection name (entity type)',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+                'default' => $custom
+            ],
+            'access_token' => [
+                'description' => 'The OAuth2 access token',
+                'location' => 'query',
+                'type' => 'string',
+                'required' => false,
+            ],
+            'org_name_or_uuid' => [
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+                'description' => 'Organization name or uuid'
+            ]
+        ]
+    ],
+    'update' => [
+        'httpMethod' => 'PUT',
+        'uri' => '/{org_name_or_uuid}/{app_name_or_uuid}/{collection}/{entity_name_or_uuid}',
+        'notes' => 'Update a User entity.',
+        'summary' => 'Update a User entity by name or uuid and using JSON data',
+        'responseClass' => 'Apache\Usergrid\Api\Models\User',
+        'responseType' => 'model',
+        'errorResponses' => $errors,
+        'parameters' => [
+            'app_name_or_uuid' => [
+                'description' => 'app name or uuid',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'entity_name_or_uuid' => [
+                'description' => 'entity name or uuid',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'collection' => [
+                'description' => 'collection name (entity type)',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+                'default' => $custom
+            ],
+            'access_token' => [
+                'description' => 'The OAuth2 access token',
+                'location' => 'query',
+                'type' => 'string',
+                'required' => false,
+            ],
+            'org_name_or_uuid' => [
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+                'description' => 'Organization name or uuid'
+            ]
+        ],
+        'additionalParameters' => [
+            "description" => "Entity data",
+            'location' => 'json'
+        ]
+    ]
+];
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3c6ebe83/sdks/php5/apache-usergrid/src/Manifests/1.0.1/Groups.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/src/Manifests/1.0.1/Groups.php b/sdks/php5/apache-usergrid/src/Manifests/1.0.1/Groups.php
index 230f347..d0832d9 100644
--- a/sdks/php5/apache-usergrid/src/Manifests/1.0.1/Groups.php
+++ b/sdks/php5/apache-usergrid/src/Manifests/1.0.1/Groups.php
@@ -348,7 +348,111 @@ return [
                 'required' => true,
             ],
             'entity_name_or_uuid' => [
-                'description' => 'entity name or uuid',
+                'description' => 'group name or uuid',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'collection' => [
+                'description' => 'collection name (entity type)',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+                'default' => 'groups'
+            ],
+            'access_token' => [
+                'description' => 'The OAuth2 access token',
+                'location' => 'query',
+                'type' => 'string',
+                'required' => false,
+            ],
+            'org_name_or_uuid' => [
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+                'description' => 'Organization name or uuid'
+            ]
+        ],
+        'additionalParameters' => [
+            "description" => "Entity data",
+            'location' => 'json'
+        ]
+    ],
+    'addUser' => [
+        'httpMethod' => 'POST',
+        'uri' => '/{org_name_or_uuid}/{app_name_or_uuid}/{collection}/{entity_name_or_uuid}/users/{user_name_or_uuid}',
+        'notes' => 'Update a Group entity.',
+        'summary' => 'Update a Group entity by name or uuid and using JSON data',
+        'responseClass' => 'Apache\Usergrid\Api\Models\Entity',
+        'responseType' => 'model',
+        'errorResponses' => $errors,
+        'parameters' => [
+            'app_name_or_uuid' => [
+                'description' => 'app name or uuid',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'entity_name_or_uuid' => [
+                'description' => 'group name or uuid',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'user_name_or_uuid' => [
+                'description' => 'user name or uuid',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'collection' => [
+                'description' => 'collection name (entity type)',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+                'default' => 'groups'
+            ],
+            'access_token' => [
+                'description' => 'The OAuth2 access token',
+                'location' => 'query',
+                'type' => 'string',
+                'required' => false,
+            ],
+            'org_name_or_uuid' => [
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+                'description' => 'Organization name or uuid'
+            ]
+        ],
+        'additionalParameters' => [
+            "description" => "Entity data",
+            'location' => 'json'
+        ]
+    ],
+    'removeUser' => [
+        'httpMethod' => 'DELETE',
+        'uri' => '/{org_name_or_uuid}/{app_name_or_uuid}/{collection}/{entity_name_or_uuid}/users/{user_name_or_uuid}',
+        'notes' => 'Update a Group entity.',
+        'summary' => 'Update a Group entity by name or uuid and using JSON data',
+        'responseClass' => 'Apache\Usergrid\Api\Models\Entity',
+        'responseType' => 'model',
+        'errorResponses' => $errors,
+        'parameters' => [
+            'app_name_or_uuid' => [
+                'description' => 'app name or uuid',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'entity_name_or_uuid' => [
+                'description' => 'group name or uuid',
+                'location' => 'uri',
+                'type' => 'string',
+                'required' => true,
+            ],
+            'user_name_or_uuid' => [
+                'description' => 'user name or uuid',
                 'location' => 'uri',
                 'type' => 'string',
                 'required' => true,

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3c6ebe83/sdks/php5/apache-usergrid/tests/Api/ApplicationTest.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/tests/Api/ApplicationTest.php b/sdks/php5/apache-usergrid/tests/Api/ApplicationTest.php
index fa80e0c..b6c1829 100644
--- a/sdks/php5/apache-usergrid/tests/Api/ApplicationTest.php
+++ b/sdks/php5/apache-usergrid/tests/Api/ApplicationTest.php
@@ -40,47 +40,24 @@ class ApplicationTest extends PHPUnit_Framework_TestCase
      */
     protected $usergrid;
 
-    protected $config = [
-        'usergrid' => [
-            'url' => 'https://api.usergrid.com',
-            'version' => '1.0.0',
-            'orgName' => null,
-            'appName' => null,
-            'manifestPath' => './src/Manifests/1.0.1',
-            'clientId' => null,
-            'clientSecret' => null,
-            'username' => null,
-            'password' => null,
-            /**
-             * The Auth Type setting is the Oauth 2 end point you want to get the OAuth 2
-             * Token from.  You have two options here one is 'application' the other is 'organization'
-             *
-             *  organization will get the the token from http://example.com/management using  client_credentials or password grant type
-             *  application will get the token from http://example.com/managment/org_name/app_name using client_credentials or password grant type
-             */
-            'auth_type' => 'organization',
-            /** The Grant Type to use
-             *
-             * This has to be set to one of the 2 grant types that Apache Usergrid
-             * supports which at the moment is client_credentials or password but at
-             * 2 level organization or application
-             */
-            'grant_type' => 'client_credentials'
-        ]
-    ];
+    protected $config;
 
     /**
      *
      */
     public function setUp()
     {
-        $boostrap = new UsergridBootstrapper($this->config);
-        $this->usergrid = $boostrap->createUsergrid();
+        /** @noinspection PhpIncludeInspection */
+        $this->config = include  $_SERVER['CONFIG'];
+        $bootstrap = new UsergridBootstrapper($this->config);
+        $this->usergrid = $bootstrap->createUsergrid();
     }
 
-    /** @test */
-    public function it_can_get_oauth2_token()
-    {
+    /**
+     * @test
+     * @group internet
+     */
+    public function it_can_get_entity(){
 
     }
 } 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3c6ebe83/sdks/php5/apache-usergrid/tests/Api/Exception/BadRequestExceptionTest.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/tests/Api/Exception/BadRequestExceptionTest.php b/sdks/php5/apache-usergrid/tests/Api/Exception/BadRequestExceptionTest.php
new file mode 100644
index 0000000..e262cef
--- /dev/null
+++ b/sdks/php5/apache-usergrid/tests/Api/Exception/BadRequestExceptionTest.php
@@ -0,0 +1,58 @@
+<?php
+/**
+ * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+namespace Apache\Usergrid\Tests\Api\Exception;
+
+use PHPUnit_Framework_TestCase;
+use Guzzle\Http\Message\Response;
+use Apache\Usergrid\Api\Exception\BadRequestException;
+
+/**
+ * Class BadRequestExceptionTest
+ *
+ * @package    Apache/Usergrid
+ * @version    1.0.0
+ * @author     Jason Kristian <jasonkristian@gmail.com>
+ * @license    Apache License, Version  2.0
+ * @copyright  (c) 2008-2014, Baas Platform Pty. Ltd
+ * @link       http://baas-platform.com
+ */
+class BadRequestExceptionTest extends PHPUnit_Framework_TestCase {
+
+	/** @test */
+	public function it_can_create_the_exception()
+	{
+		$command = $this->getMock('Guzzle\Service\Command\CommandInterface');
+		$command
+			->expects($this->once())
+			->method('getRequest')
+			->will($this->returnValue(
+				$this->getMock('Guzzle\Http\Message\Request', [], [], '', false)
+			));
+
+		$response = new Response(400);
+		$response->setBody('');
+
+        /** @noinspection PhpParamsInspection */
+        $exception = BadRequestException::fromCommand($command, $response);
+
+		$this->assertInstanceOf(
+			'Apache\Usergrid\Api\Exception\BadRequestException',
+			$exception
+		);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3c6ebe83/sdks/php5/apache-usergrid/tests/Api/Exception/InvalidIdExceptionTest.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/tests/Api/Exception/InvalidIdExceptionTest.php b/sdks/php5/apache-usergrid/tests/Api/Exception/InvalidIdExceptionTest.php
new file mode 100644
index 0000000..d2256d1
--- /dev/null
+++ b/sdks/php5/apache-usergrid/tests/Api/Exception/InvalidIdExceptionTest.php
@@ -0,0 +1,58 @@
+<?php
+/**
+ * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+namespace Apache\Usergrid\Tests\Api\Exception;
+
+use PHPUnit_Framework_TestCase;
+use Guzzle\Http\Message\Response;
+use Apache\Usergrid\Api\Exception\InvalidIdException;
+
+/**
+ * Class InvalidIdExceptionTest
+ *
+ * @package    Apache/Usergrid
+ * @version    1.0.0
+ * @author     Jason Kristian <jasonkristian@gmail.com>
+ * @license    Apache License, Version  2.0
+ * @copyright  (c) 2008-2014, Baas Platform Pty. Ltd
+ * @link       http://baas-platform.com
+ */
+class InvalidIdExceptionTest extends PHPUnit_Framework_TestCase
+{
+    /** @test */
+    public function it_can_create_the_exception()
+    {
+        $command = $this->getMock('Guzzle\Service\Command\CommandInterface');
+        $command
+            ->expects($this->once())
+            ->method('getRequest')
+            ->will($this->returnValue(
+                $this->getMock('Guzzle\Http\Message\Request', [], [], '', false)
+            ));
+
+        $response = new Response(400);
+        $response->setBody('');
+
+        /** @noinspection PhpParamsInspection */
+        $exception = InvalidIdException::fromCommand($command, $response);
+
+        $this->assertInstanceOf(
+            'Apache\Usergrid\Api\Exception\InvalidIdException',
+            $exception
+        );
+    }
+
+} 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3c6ebe83/sdks/php5/apache-usergrid/tests/Api/Exception/NotFoundExceptionTest.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/tests/Api/Exception/NotFoundExceptionTest.php b/sdks/php5/apache-usergrid/tests/Api/Exception/NotFoundExceptionTest.php
new file mode 100644
index 0000000..78cdf3d
--- /dev/null
+++ b/sdks/php5/apache-usergrid/tests/Api/Exception/NotFoundExceptionTest.php
@@ -0,0 +1,58 @@
+<?php
+/**
+ * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+namespace Apache\Usergrid\Tests\Api\Exception;
+
+use PHPUnit_Framework_TestCase;
+use Guzzle\Http\Message\Response;
+use Apache\Usergrid\Api\Exception\NotFoundException;
+
+/**
+ * Class UnauthorizedExceptionTest
+ *
+ * @package    Apache/Usergrid
+ * @version    1.0.0
+ * @author     Jason Kristian <jasonkristian@gmail.com>
+ * @license    Apache License, Version  2.0
+ * @copyright  (c) 2008-2014, Baas Platform Pty. Ltd
+ * @link       http://baas-platform.com
+ */
+
+class NotFoundExceptionTest extends PHPUnit_Framework_TestCase
+{
+    /** @test */
+    public function it_can_create_the_exception()
+    {
+        $command = $this->getMock('Guzzle\Service\Command\CommandInterface');
+        $command
+            ->expects($this->once())
+            ->method('getRequest')
+            ->will($this->returnValue(
+                $this->getMock('Guzzle\Http\Message\Request', [], [], '', false)
+            ));
+
+        $response = new Response(404);
+        $response->setBody('');
+
+        /** @noinspection PhpParamsInspection */
+        $exception = NotFoundException::fromCommand($command, $response);
+
+        $this->assertInstanceOf(
+            'Apache\Usergrid\Api\Exception\NotFoundException',
+            $exception
+        );
+    }
+} 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3c6ebe83/sdks/php5/apache-usergrid/tests/Api/Exception/ServerErrorExceptionTest.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/tests/Api/Exception/ServerErrorExceptionTest.php b/sdks/php5/apache-usergrid/tests/Api/Exception/ServerErrorExceptionTest.php
new file mode 100644
index 0000000..7782bcc
--- /dev/null
+++ b/sdks/php5/apache-usergrid/tests/Api/Exception/ServerErrorExceptionTest.php
@@ -0,0 +1,58 @@
+<?php
+/**
+ * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+namespace Apache\Usergrid\Tests\Api\Exception;
+
+use PHPUnit_Framework_TestCase;
+use Guzzle\Http\Message\Response;
+use Apache\Usergrid\Api\Exception\ServerErrorException;
+
+/**
+ * Class ServerErrorException
+ *
+ * @package    Apache/Usergrid
+ * @version    1.0.0
+ * @author     Jason Kristian <jasonkristian@gmail.com>
+ * @license    Apache License, Version  2.0
+ * @copyright  (c) 2008-2014, Baas Platform Pty. Ltd
+ * @link       http://baas-platform.com
+ */
+class ServerErrorExceptionTest extends PHPUnit_Framework_TestCase
+{
+    /** @test */
+    public function it_can_create_the_exception()
+    {
+        $command = $this->getMock('Guzzle\Service\Command\CommandInterface');
+        $command
+            ->expects($this->once())
+            ->method('getRequest')
+            ->will($this->returnValue(
+                $this->getMock('Guzzle\Http\Message\Request', [], [], '', false)
+            ));
+
+        $response = new Response(400);
+        $response->setBody('');
+
+        /** @noinspection PhpParamsInspection */
+        $exception = ServerErrorException::fromCommand($command, $response);
+
+        $this->assertInstanceOf(
+            'Apache\Usergrid\Api\Exception\ServerErrorException',
+            $exception
+        );
+    }
+
+} 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3c6ebe83/sdks/php5/apache-usergrid/tests/Api/Exception/UnauthorizedExceptionTest.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/tests/Api/Exception/UnauthorizedExceptionTest.php b/sdks/php5/apache-usergrid/tests/Api/Exception/UnauthorizedExceptionTest.php
new file mode 100644
index 0000000..14dad49
--- /dev/null
+++ b/sdks/php5/apache-usergrid/tests/Api/Exception/UnauthorizedExceptionTest.php
@@ -0,0 +1,59 @@
+<?php
+/**
+ * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+namespace Apache\Usergrid\Tests\Api\Exception;
+
+
+use PHPUnit_Framework_TestCase;
+use Guzzle\Http\Message\Response;
+use Apache\Usergrid\Api\Exception\UnauthorizedException;
+
+/**
+ * Class UnauthorizedExceptionTest
+ *
+ * @package    Apache/Usergrid
+ * @version    1.0.0
+ * @author     Jason Kristian <jasonkristian@gmail.com>
+ * @license    Apache License, Version  2.0
+ * @copyright  (c) 2008-2014, Baas Platform Pty. Ltd
+ * @link       http://baas-platform.com
+ */
+
+class UnauthorizedExceptionTest extends PHPUnit_Framework_TestCase
+{
+    /** @test */
+    public function it_can_create_the_exception()
+    {
+        $command = $this->getMock('Guzzle\Service\Command\CommandInterface');
+        $command
+            ->expects($this->once())
+            ->method('getRequest')
+            ->will($this->returnValue(
+                $this->getMock('Guzzle\Http\Message\Request', [], [], '', false)
+            ));
+
+        $response = new Response(401);
+        $response->setBody('');
+
+        /** @noinspection PhpParamsInspection */
+        $exception = UnauthorizedException::fromCommand($command, $response);
+
+        $this->assertInstanceOf(
+            'Apache\Usergrid\Api\Exception\UnauthorizedException',
+            $exception
+        );
+    }
+} 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3c6ebe83/sdks/php5/apache-usergrid/tests/Api/ManagementTest.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/tests/Api/ManagementTest.php b/sdks/php5/apache-usergrid/tests/Api/ManagementTest.php
index 3df4824..056d402 100644
--- a/sdks/php5/apache-usergrid/tests/Api/ManagementTest.php
+++ b/sdks/php5/apache-usergrid/tests/Api/ManagementTest.php
@@ -33,45 +33,20 @@ use PHPUnit_Framework_TestCase;
 class ManagementTest extends PHPUnit_Framework_TestCase
 {
     protected $usergrid;
-    protected $config = [
-        'usergrid' => [
-            'url' => 'https://api.usergrid.com',
-            'version' => '1.0.0',
-            'orgName' => null,
-            'appName' => null,
-            'manifestPath' => './src/Manifests/1.0.1',
-            'clientId' => null,
-            'clientSecret' => null,
-            'username' => null,
-            'password' => null,
-            /**
-             * The Auth Type setting is the Oauth 2 end point you want to get the OAuth 2
-             * Token from.  You have two options here one is 'application' the other is 'organization'
-             *
-             *  organization will get the the token from http://example.com/management using  client_credentials or password grant type
-             *  application will get the token from http://example.com/managment/org_name/app_name using client_credentials or password grant type
-             */
-            'auth_type' => 'organization',
-            /** The Grant Type to use
-             *
-             * This has to be set to one of the 2 grant types that Apache Usergrid
-             * supports which at the moment is client_credentials or password but at
-             * 2 level organization or application
-             */
-            'grant_type' => 'client_credentials'
-
-        ]
-    ];
+    protected $config;
 
     public function setUp()
     {
-        $boostrap = new UsergridBootstrapper($this->config);
-        $this->usergrid = $boostrap->createUsergrid();
+        /** @noinspection PhpIncludeInspection */
+        $this->config = include  $_SERVER['CONFIG'];
+        $bootstrap = new UsergridBootstrapper($this->config);
+        $this->usergrid = $bootstrap->createUsergrid();
     }
-
-    /** @test */
-    public function it_can_retrive_token()
-    {
+    /**
+     * @test
+     * @group internet
+     */
+    public function it_can_make_management_call(){
 
     }
 } 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3c6ebe83/sdks/php5/apache-usergrid/tests/Api/UsergridTest.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/tests/Api/UsergridTest.php b/sdks/php5/apache-usergrid/tests/Api/UsergridTest.php
index 80b919a..5fab892 100644
--- a/sdks/php5/apache-usergrid/tests/Api/UsergridTest.php
+++ b/sdks/php5/apache-usergrid/tests/Api/UsergridTest.php
@@ -16,6 +16,7 @@
 
 namespace Apache\Usergrid\Tests\Api;
 
+use Apache\Usergrid\Api\Exception\UnauthorizedException;
 use Apache\Usergrid\Native\UsergridBootstrapper;
 use PHPUnit_Framework_TestCase;
 
@@ -35,35 +36,7 @@ class UsergridTest extends PHPUnit_Framework_TestCase
     /** @var  Usergrid Api Client */
     protected $usergrid;
 
-    protected $config = [
-        'usergrid' => [
-            'url' => 'https://api.usergrid.com',
-            'version' => '1.0.0',
-            'orgName' => null,
-            'appName' => null,
-            'manifestPath' => './src/Manifests/1.0.1',
-            'clientId' => null,
-            'clientSecret' => null,
-            'username' => null,
-            'password' => null,
-            /**
-             * The Auth Type setting is the Oauth 2 end point you want to get the OAuth 2
-             * Token from.  You have two options here one is 'application' the other is 'organization'
-             *
-             *  organization will get the the token from http://example.com/management using  client_credentials or password grant type
-             *  application will get the token from http://example.com/managment/org_name/app_name using client_credentials or password grant type
-             */
-            'auth_type' => 'organization',
-            /** The Grant Type to use
-             *
-             * This has to be set to one of the 2 grant types that Apache Usergrid
-             * supports which at the moment is client_credentials or password but at
-             * 2 level organization or application
-             */
-            'grant_type' => 'client_credentials'
-
-        ]
-    ];
+    protected $config;
     /**
      * Setup resources and dependencies
      *
@@ -71,14 +44,27 @@ class UsergridTest extends PHPUnit_Framework_TestCase
      */
     public function setup()
     {
-        $boostrap = new UsergridBootstrapper($this->config);
-        $this->usergrid = $boostrap->createUsergrid();
+        /** @noinspection PhpIncludeInspection */
+        $this->config = include  $_SERVER['CONFIG'];
+        $bootstrap = new UsergridBootstrapper($this->config);
+        $this->usergrid = $bootstrap->createUsergrid();
     }
 
-    /** @test */
+    /**
+     * @test
+     * @group internet
+     */
     public function it_can_retrieve_oauth2_token()
     {
-        //TODO: phpunit test method implementation
+        $error = null;
+
+        try {
+            $this->usergrid->application()->EntityGet(['collection' => 'roles']);
+        } catch(UnauthorizedException $e) {
+            $error = $e;
+        }
+
+        $this->assertNull($error, 'Exception should be null if authorized');
     }
 
     /** @test */
@@ -109,7 +95,7 @@ class UsergridTest extends PHPUnit_Framework_TestCase
     public function it_can_retrieve_the_manifest_path()
     {
 
-        $this->assertEquals('./src/Manifests/1.0.1', $this->usergrid->getManifestPath());
+        $this->assertEquals('/Users/admin/PhpstormProjects/Apache-Usergrid/src/Manifests', $this->usergrid->getManifestPath());
     }
 
     /** @test */
@@ -164,17 +150,7 @@ class UsergridTest extends PHPUnit_Framework_TestCase
         $this->assertEquals($headers, $expected);
     }
 
-    /** @test */
-    public function it_can_retrieve_client_id_and_secret()
-    {
-        //TODO: phpunit test method implementation
-    }
 
-    /** @test */
-    public function it_can_set_client_id_and_secret()
-    {
-        //TODO: phpunit test method implementation
-    }
 
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3c6ebe83/sdks/php5/apache-usergrid/tests/Api/test_config.php
----------------------------------------------------------------------
diff --git a/sdks/php5/apache-usergrid/tests/Api/test_config.php b/sdks/php5/apache-usergrid/tests/Api/test_config.php
new file mode 100644
index 0000000..cd1df43
--- /dev/null
+++ b/sdks/php5/apache-usergrid/tests/Api/test_config.php
@@ -0,0 +1,65 @@
+<?php
+/**
+ * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+return [
+
+    'usergrid' => [
+
+        'url' => 'https://api.usergrid.com',
+
+        'version' => '1.0.0',
+
+        'orgName' => "",
+
+        'appName' => "",
+
+        'manifestPath' => null,
+
+        //its better not to set the real values here if using laravel set them in a .env file or
+        // if your not using Laravel set them as environment variable and include them here using $_ENV global.
+        // so that way you can be sure not to commit privates ID to a public repo
+        'clientId' => '',
+
+        'clientSecret' => '',
+
+        'username' => null,
+
+        'password' => null,
+
+
+        /**
+         * The Auth Type setting is the Oauth 2 end point you want to get the OAuth 2
+         * Token from.  You have two options here one is 'application' the other is 'organization'
+         *
+         *  organization will get the the token from http://example.com/management using  client_credentials or password grant type
+         *  application will get the token from http://example.com/managment/org_name/app_name using client_credentials or password grant type
+         */
+        'auth_type' => 'organization',
+
+        /** The Grant Type to use
+         *
+         * This has to be set to one of the 2 grant types that Apache Usergrid
+         * supports which at the moment is client_credentials or password but at
+         * 2 level organization or application
+         */
+        'grant_type' => 'client_credentials',
+
+        /**
+         * if you want to manage your own auth flow by calling the token api and setting the token your self just set this to false
+         * */
+        'enable_oauth2_plugin' => true
+    ]
+];
\ No newline at end of file


Mime
View raw message