示例#1
0
 /**
  * Generic
  */
 public function testGeneric()
 {
     $this->generic->setBackgroundColor('rgb(60, 65, 76)');
     $this->assertSame('rgb(60, 65, 76)', $this->generic->getBackgroundColor());
     $this->generic->setLogoText('Apple Inc.');
     $this->assertSame('Apple Inc.', $this->generic->getLogoText());
     $this->generic->setFormatVersion(1)->setDescription('description');
     // Create pass structure
     $structure = new Structure();
     // Add primary field
     $primary = new Field('event', 'The Beat Goes On');
     $primary->setLabel('Event');
     $structure->addPrimaryField($primary);
     // Add back field
     $back = new Field('back', 'Hello World!');
     $back->setLabel('Location');
     $structure->addSecondaryField($back);
     // Add auxiliary field
     $auxiliary = new Field('datetime', '2014 Aug 1');
     $auxiliary->setLabel('Date & Time');
     $structure->addAuxiliaryField($auxiliary);
     // Set pass structure
     $this->generic->setStructure($structure);
     // Add beacon
     $beacon = new Beacon('abcdef01-2345-6789-abcd-ef0123456789');
     $this->generic->addBeacon($beacon);
     $json = PassFactory::serialize($this->generic);
     $array = json_decode($json, true);
     $this->assertArrayHasKey('beacons', $array);
     $this->assertArrayHasKey('generic', $array);
 }