예제 #1
0
 public function __construct($expectedGID = NULL)
 {
     $this->headers = array();
     $this->headers[SONIC_HEADER__RANDOM] = Random::getRandom();
     $this->headers[SONIC_HEADER__DATE] = XSDDateTime::getXSDDatetime();
     $this->headers[SONIC_HEADER__TARGET_API] = SONIC_SDK__API_VERSION;
     $this->headers[SONIC_HEADER__PLATFORM_GID] = Sonic::getPlatformGlobalID();
     $this->headers[SONIC_HEADER__SOURCE_GID] = Sonic::getContextGlobalID();
 }
예제 #2
0
 /**
  * constructor for building a Sonic compliant HTTP response.
  */
 public function __construct()
 {
     $this->headers = array();
     $this->headers[SONIC_HEADER__RANDOM] = Random::getRandom();
     $this->headers[SONIC_HEADER__DATE] = XSDDateTime::getXSDDatetime();
     $this->headers[SONIC_HEADER__TARGET_API] = SONIC_SDK__API_VERSION;
     $this->headers[SONIC_HEADER__PLATFORM_GID] = Sonic::getPlatformGlobalID();
     $this->headers[SONIC_HEADER__SOURCE_GID] = Sonic::getContextGlobalID();
     $this->statusCode = 200;
     $this->statusMessage = 'OK';
 }
예제 #3
0
파일: UOID.php 프로젝트: sgoendoer/sonic
 /**
  * Creates a new UOID for the current Sonic context
  * 
  * @param $gid String The global id part of the UOID
  * @param $id String The local id part of the UOID
  * 
  * @return A UOID
  */
 public static function createUOID($gid = NULL, $id = NULL)
 {
     if ($gid == NULL) {
         $gid = Sonic::getContextGlobalID();
     }
     if ($id == NULL) {
         $id = Random::getUniqueRandom();
     }
     $uoid = $gid . UOID::SEPARATOR . $id;
     return $uoid;
 }
예제 #4
0
 public function testSonic()
 {
     $platformSR = SocialRecordManager::importSocialRecord($this->platformSRjson);
     $platformSocialRecord = $platformSR['socialRecord'];
     $platformAccountKeyPair = $platformSR['accountKeyPair'];
     $platformPersonalKeyPair = $platformSR['personalKeyPair'];
     $aliceSR = SocialRecordManager::importSocialRecord($this->aliceSRjson);
     $aliceSocialRecord = $aliceSR['socialRecord'];
     $aliceAccountKeyPair = $aliceSR['accountKeyPair'];
     $alicePersonalKeyPair = $aliceSR['personalKeyPair'];
     $sonic = Sonic::initInstance(new EntityAuthData($platformSocialRecord, $platformAccountKeyPair, $platformPersonalKeyPair));
     $this->assertEquals($platformSocialRecord->getGlobalID(), Sonic::getContextGlobalID());
     Sonic::setUserAuthData(new EntityAuthData($aliceSocialRecord, $aliceAccountKeyPair));
     Sonic::setContext(Sonic::CONTEXT_USER);
     $this->assertEquals($aliceSocialRecord->getGlobalID(), Sonic::getContextGlobalID());
 }
예제 #5
0
 public function testSearch()
 {
     $searchQuery = (new SearchQueryObjectBuilder())->initiatingGID(Sonic::getContextGlobalID())->query((new ESQueryBuilder())->type('profile')->match('displayName', 'alice')->build())->datetime()->build();
     $this->assertTrue($searchQuery->validate());
     $this->assertEquals($searchQuery, SearchQueryObjectBuilder::buildFromJSON($searchQuery->getJSONString()));
     $profile = (new ProfileObjectBuilder())->globalID(Sonic::getContextGlobalID())->displayName($this->aliceSocialRecord->getDisplayName())->param('x', 'y')->build();
     $searchResult = (new SearchResultObjectBuilder())->targetID($searchQuery->getObjectID())->resultOwnerGID($profile->getGlobalID())->resultObjectID($profile->getObjectID())->resultIndex($searchQuery->getQuery()->getIndex())->resultType($searchQuery->getQuery()->getType())->displayName($profile->getDisplayName())->datetime()->build();
     $this->assertTrue($searchResult->validate());
     $this->assertEquals($searchResult, SearchResultObjectBuilder::buildFromJSON($searchResult->getJSONString()));
     $searchResultCollection = (new SearchResultCollectionObjectBuilder())->objectID(UOID::createUOID($this->platformSocialRecord->getGlobalID()))->targetID($searchQuery->getObjectID())->platformGID($this->platformSocialRecord->getGlobalID())->datetime()->result($searchResult)->build();
     $this->assertTrue($searchResultCollection->validate());
     $this->assertEquals($searchResultCollection, SearchResultCollectionObjectBuilder::buildFromJSON($searchResultCollection->getJSONString()));
 }