/**
  * Setup the test environment.
  *
  * @return array
  */
 public function setup()
 {
     parent::setup();
     if (getenv("TRAVIS")) {
         $appName = getenv("KINVEY_APP_NAME");
         $appKey = getenv("KINVEY_APP_KEY");
         $appSecret = getenv("KINVEY_APP_SECRET");
         $masterSecret = getenv("KINVEY_MASTER_SECRET");
         $testMail = getenv("TEST_MAIL");
     } else {
         extract(include __DIR__ . '/TestConfig.php');
     }
     // Kinvey client configuration.
     $this->app['config']->set('kinvey::appName', $appName);
     $this->app['config']->set('kinvey::appKey', $appKey);
     $this->app['config']->set('kinvey::appSecret', $appSecret);
     $this->app['config']->set('kinvey::masterSecret', $masterSecret);
     // Test mail account.
     $this->app['config']->set('kinvey::testMail', $testMail);
     // Eloquent user model.
     $authConfig = $this->app['config']['auth'];
     $authConfig['model'] = 'GovTribe\\LaravelKinvey\\Database\\Eloquent\\User';
     $this->app['config']->set('auth', $authConfig);
     // Default database
     $this->app['config']->set('database.connections.kinvey', array('driver' => 'kinvey'));
     $this->app['config']->set('database.default', 'kinvey');
     // Set the auth mode to admin.
     Kinvey::setAuthMode('admin');
 }
 /**
  * Retrieve a user by the given credentials.
  *
  * @param  array  $credentials
  * @return \Illuminate\Auth\UserInterface|null
  */
 public function retrieveByCredentials(array $credentials)
 {
     Kinvey::setAuthMode('admin');
     $result = parent::retrieveByCredentials($credentials);
     Kinvey::setAuthMode('app');
     return $result;
 }
示例#3
0
 /**
  * Create a test user.
  *
  * @return GovTribe\LaravelKinvey\Database\Eloquent\User
  */
 public static function createTestUser()
 {
     Kinvey::setAuthMode('app');
     $user = new User();
     $user->setRawAttributes(array('email' => '*****@*****.**', 'first_name' => 'Test', 'last_name' => 'Guy', 'password' => str_random(8), 'original' => 'baz'));
     $user->save();
     Kinvey::setAuthMode('admin');
     return $user;
 }
示例#4
0
 /**
  * Delete the test collection.
  *
  * @param  string $id
  * @return void
  */
 public static function deleteTestCollection()
 {
     Kinvey::deleteCollection(array('collection' => 'widgets', 'authMode' => 'admin'));
 }
示例#5
0
 /**
  * Tear down the test environment.
  *
  * @return array
  */
 public function tearDown()
 {
     Kinvey::setAuthMode('admin');
     $user = User::withTrashed()->where('_id', $this->testUser->_id)->first()->forceDelete();
     Kinvey::setAuthMode('app');
 }