Beispiel #1
0
 /**
  * Gets an instance of a data storage adapter
  *
  * @return StorageInterface
  */
 public function getDataStorage()
 {
     if (!is_null($this->storage)) {
         return $this->storage;
     }
     // Use default data storage (cookie-based)
     $cookie = new DataStorage\Cookie();
     $cookie->setProjectToken($this->token);
     // Set data storage adapter
     $this->setDataStorage($cookie);
     // Only set user ID after data storage has been initialized
     $this->storage->setUserUuid($this->getDistinctId());
     return $this->storage;
 }
 /**
  * Test that generateStorageKey creates the correct storage key
  *
  * @covers Mixpanel\DataStorage\StorageAbstract::setUserUuid
  * @covers Mixpanel\DataStorage\StorageAbstract::setProjectToken
  * @covers Mixpanel\DataStorage\StorageAbstract::getStorageKey
  * @covers Mixpanel\DataStorage\StorageAbstract::generateStorageKey
  */
 public function testGenerateStorageKeyReturnsCorrectStorageKey()
 {
     $this->storage->setUserUuid(1337);
     $this->assertEquals($this->storage, $this->storage->setProjectToken('project-token'));
     $this->assertSame('mixpanel:project-token:1337', $this->storage->getStorageKey());
 }