Exemple #1
0
 public function testUnsetProperty()
 {
     $event = new Event();
     $event->set('custom prop', 'value');
     $event->userId = 'user';
     $event->quantity = 50;
     $event->userProperties = ['prop' => 'value'];
     $this->assertEquals(['event_properties' => ['custom prop' => 'value'], 'user_id' => 'user', 'quantity' => 50, 'user_properties' => ['prop' => 'value']], $event->toArray(), 'Initialization Check');
     // Should just not care if not set...
     $event->unsetProperty('invalid');
     unset($event->invalid);
     // Should be able to successfully unset custom property
     $this->assertNotEmpty($event->get('custom prop'), 'Initialization check');
     $event->unsetProperty('custom prop');
     $this->assertEmpty($event->get('custom prop'), 'Should be able to unset custom properties');
     // also should work with magic methods
     $this->assertNotEmpty($event->userId, 'Initialization check');
     unset($event->userId);
     $this->assertEmpty($event->userId, 'Should unset built-in properties with magic unset');
 }