示例#1
0
 /**
  * Restrict entity test.
  *
  * @return void
  */
 public function testRestrictEntity()
 {
     $widget = self::createTestEntity();
     $testUser = self::createTestUser();
     // Login as the test user, attempt to read it.
     $command = Kinvey::getCommand('retrieveEntity', array('collection' => 'widgets', '_id' => $widget['_id'], 'authMode' => 'user', 'username' => $testUser['username'], 'password' => $testUser['password']));
     $command->execute();
     $this->assertEquals(200, $command->getResponse()->getStatusCode());
     // Update $widget to make it not globally readable or writable.
     $widget['_acl'] = array_merge($widget['_acl'], array('gr' => false, 'gw' => false));
     $widget['authMode'] = 'admin';
     $widget['collection'] = 'widgets';
     $widget = Kinvey::updateEntity($widget);
     // Login as the test user, attempt to read it.
     $this->setExpectedException('GovTribe\\LaravelKinvey\\Client\\Exception\\KinveyResponseException');
     Kinvey::retrieveEntity(array('collection' => 'widgets', '_id' => $widget['_id'], 'authMode' => 'user', 'username' => $testUser['username'], 'password' => $testUser['password']));
 }