Ejemplo n.º 1
0
 public function testInitialState()
 {
     $Date = new Date();
     $this->assertSame(0, $Date->getDay());
     $this->assertSame(0, $Date->getMonth());
     $Listing = new Listing();
     $this->assertEmpty($Listing->getDescription());
     $this->assertEmpty($Listing->getTitle());
     $Price = new Price();
     $this->assertEmpty($Price->getCurrency());
     $this->assertEmpty($Price->getPriceMicros());
     $Resource = new Resource();
     $this->assertEmpty($Resource->getDefaultLanguage());
     $this->assertNull($Resource->getDefaultPrice());
     $this->assertCount(0, $Resource->getListings());
     $this->assertEmpty($Resource->getPackageName());
     $this->assertCount(0, $Resource->getPrices());
     $this->assertEmpty($Resource->getPurchaseType());
     $this->assertNull($Resource->getSeason());
     $this->assertEmpty($Resource->getSku());
     $this->assertEmpty($Resource->getStatus());
     $this->assertEmpty($Resource->getSubscriptionPeriod());
     $this->assertEmpty($Resource->getTrialPeriod());
 }
Ejemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public static function initializeByString($string)
 {
     $Object = json_decode($string);
     $Resource = new Resource();
     $Resource->defaultLanguage = (string) $Object->defaultLanguage;
     $Resource->defaultPrice = Price::initializeByObject($Object->defaultPrice);
     $Resource->packageName = (string) $Object->packageName;
     $Resource->purchaseType = (string) $Object->purchaseType;
     $Resource->sku = (string) $Object->sku;
     $Resource->status = (string) $Object->status;
     $Resource->subscriptionPeriod = (string) @$Object->subscriptionPeriod;
     $Resource->trialPeriod = (string) @$Object->trialPeriod;
     if (isset($Object->season)) {
         $Resource->season = Season::initializeByObject($Object->season);
     }
     foreach ($Object->listings as $key => $Item) {
         $Resource->listings[$key] = Listing::initializeByObject($Item);
     }
     foreach ($Object->prices as $key => $Item) {
         $Resource->prices[$key] = Price::initializeByObject($Item);
     }
     return $Resource;
 }