public function testGoalWithoutReferer()
 {
     // Register fake named route
     Route::any('/foobar', ['as' => 'buy', function () {
         return 'hello world';
     }]);
     $headers = Request::instance()->server->getHeaders();
     $request = Request::create('http://localhost/foobar', 'get', [], [], [], $headers);
     Route::dispatch($request);
     $ab = App::make('ab');
     $ab->experiment();
     $ab->track($request);
     $this->assertEquals(1, Experiment::find('a')->visitors);
     $this->assertEquals(1, Experiment::find('a')->engagement);
     $this->assertEquals(1, Goal::where('name', 'buy')->where('experiment', 'a')->first()->count);
 }
Пример #2
0
 /**
  * Mark a goal as completed for the current experiment.
  *
  * @return void
  */
 public function complete($name)
 {
     // Only complete once per experiment.
     if ($this->session->get("completed_{$name}")) {
         return;
     }
     $goal = Goal::firstOrCreate(['name' => $name, 'experiment' => $this->experiment()]);
     Goal::where('name', $name)->where('experiment', $this->experiment())->update(['count' => $goal->count + 1]);
     // Mark current experiment as completed.
     $this->session->set("completed_{$name}", 1);
 }