public function testMetaDataStorage() { include 'source/helper.php'; $meta = laravel_ab_meta(); Session::forget(config('laravel-ab.cache_key')); Session::flush(); $ab = app()->make('Ab'); $ab->forceReset(); Ab::saveSession(); $instance = Instance::where(['instance' => Ab::getSession()->instance])->get()->first(); $metadata = $instance->metadata; $this->assertTrue(is_array($metadata)); $this->assertEquals($metadata, $meta); }
public function ensureUser($forceSession = false) { if (!Session::has(config('laravel-ab.cache_key')) || $forceSession) { $uid = md5(uniqid() . $this->request->getClientIp()); $laravel_ab_id = $this->request->cookie(config('laravel-ab.cache_key'), $uid); Session::set(config('laravel-ab.cache_key'), $uid); } if (empty(self::$session)) { self::$session = Instance::firstOrCreate(['instance' => Session::get(config('laravel-ab.cache_key')), 'identifier' => $this->request->getClientIp(), 'metadata' => function_exists('laravel_ab_meta') ? call_user_func('laravel_ab_meta') : null]); } }