initDatabase(); $this->addUsers(); $stats = new Stats($this->database); $this->assertEquals(2, $stats->newUsers()); } /** * @covers \Engelsystem\Controllers\Metrics\Stats::arrivedUsers */ public function testArrivedUsers() { $this->initDatabase(); $this->addUsers(); $stats = new Stats($this->database); $this->assertEquals(3, $stats->arrivedUsers()); } /** * Add some example users */ protected function addUsers() { $this->addUser(); $this->addUser(); $this->addUser(['arrived' => 1]); $this->addUser(['arrived' => 1, 'active' => 1]); $this->addUser(['arrived' => 1, 'active' => 1]); } /** * @param array $state */ protected function addUser(array $state = []) { $name = 'user_' . Str::random(5); $user = new User([ 'name' => $name, 'password' => '', 'email' => $name . '@engel.example.com', 'api_key' => '', ]); $user->save(); $state = new State($state); $state->user() ->associate($user) ->save(); } }